From patchwork Fri Sep 15 02:52:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13386323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 538D8EDE989 for ; Fri, 15 Sep 2023 03:01:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACD246B031A; Thu, 14 Sep 2023 23:01:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7D2B6B031C; Thu, 14 Sep 2023 23:01:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96B916B031D; Thu, 14 Sep 2023 23:01:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 87B3C6B031A for ; Thu, 14 Sep 2023 23:01:15 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 58B9C4079A for ; Fri, 15 Sep 2023 03:01:15 +0000 (UTC) X-FDA: 81237330510.17.0368158 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id B4DE740018 for ; Fri, 15 Sep 2023 03:01:13 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EyWd6QeH; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694746873; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=s9CCrAW2k5JfZmWyxspFJIvVkuWytxqxD9bxjnqhVns=; b=MhvejbR3IcS/yn7qRlzZxGxWdZh30SG0xCJkMKOQwSq47gaHYjoz+MKJDdklc2NgSZK17K 7TqqIcpfQoTXF/Fu5kJfiL4E7EDns7IRPNVFWjOUMPeicbtXlkpQAcClfBSiDOAv+uAMxY LKJiFUX1iobPRNFEfOLl4JmkIcKbrJE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EyWd6QeH; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694746873; a=rsa-sha256; cv=none; b=CFh3h5Mi5D/FE7M6pd1Qm10A68pnPOfkN7DvxH1hc3Q3vDp4qZTeIgWYfhPamUPBSsr8lm RCM6tr3/WhROoupSUd1D4qDw/EKANZFmRCG+fL7LSebIqMJujOKxG3y0zKOBKgAEIK3CZW rR7/diS/G47G8Q6Q24wLemXW7hFTHms= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0B61161EF8; Fri, 15 Sep 2023 02:53:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68B15C433CA; Fri, 15 Sep 2023 02:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746383; bh=i00VYLhoAf7cwF/8O1Xi88bbaOl2lSsV4k5ng0qJ0ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EyWd6QeH+I+otwhxDe5iLd5XAOviRv5NU62+pG7wOYSt1RxJd562R/9kRGV/14S6k wqwgK3S/aoyzhC6ERZqSSiw7JvU7BAbifNwCKIe6Ic1N++Fm4YodPXqekKh7wy5E4c frf4PtL+Dv7zzGaMntbeugmrQFPZnEwcCuwZ6MVTdQMvr7clAKApk58dlqzx4D9XB7 gFmgUFdVfZXcHnVsiUAYX4nj2eQscAJwIuXzXjzAOvHwZF0ZRQvEYWdpSJfowFNMuu CkJENgkBPYUg94GulS9lebSqQJdp3mZ2b0vLC1KWqzgCeo/tyq22w10Ies9ncnlHit 8JGVkX6Fe/OWA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] mm/damon/vaddr: call damon_update_region_access_rate() always Date: Fri, 15 Sep 2023 02:52:45 +0000 Message-Id: <20230915025251.72816-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915025251.72816-1-sj@kernel.org> References: <20230915025251.72816-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: B4DE740018 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: w7sifzc9sboz5aecuitpyh7rqm9ggm7x X-HE-Tag: 1694746873-203814 X-HE-Meta: U2FsdGVkX1/rPbBBkKdtCTCdmtJ3TMkPwregMEH33F6t7dxngNFaMTv+IiaIzB1De16NSMJHosfneIdDaK+49C3MHGVKYBx6EWCYHrz7lyibo+DkCC5yx9AyrvLzqds09O+h3xh8a+xgxMFxiO6cnMcJN06w7FHWdKjAMZ9zMVtJVKzj7FTc9IiFYqGUvsj2oAoYX52dYq3UMJpxHY3ujgRMyUX87jHHmIMgLWYeji6Z9v/kGnqRdl1R4rvnAXLeDWLrYwO4IH73FWXrduqQkcYReCvbcYRB1KjdXVcCfRXizRrFQC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ity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When getting mm_struct of the monitoring target process fails, there wil be no need to increase the access rate counter (nr_accesses) of the regions for the process. Hence, damon_va_check_accesses() skips calling damon_update_region_access_rate() in the case. This breaks the assumption that damon_update_region_access_rate() is called for every region, for every sampling interval. Call the function for every region even in the case. This might increase the overhead in some cases, but such case would not be frequent, so no significant impact is really expected. Signed-off-by: SeongJae Park --- mm/damon/vaddr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 7fc0bda73b4c..e36303271f9d 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -563,6 +563,11 @@ static void __damon_va_check_access(struct mm_struct *mm, static unsigned long last_folio_sz = PAGE_SIZE; static bool last_accessed; + if (!mm) { + damon_update_region_access_rate(r, false); + return; + } + /* If the region is in the last checked page, reuse the result */ if (same_target && (ALIGN_DOWN(last_addr, last_folio_sz) == ALIGN_DOWN(r->sampling_addr, last_folio_sz))) { @@ -586,15 +591,14 @@ static unsigned int damon_va_check_accesses(struct damon_ctx *ctx) damon_for_each_target(t, ctx) { mm = damon_get_mm(t); - if (!mm) - continue; same_target = false; damon_for_each_region(r, t) { __damon_va_check_access(mm, r, same_target); max_nr_accesses = max(r->nr_accesses, max_nr_accesses); same_target = true; } - mmput(mm); + if (mm) + mmput(mm); } return max_nr_accesses;