From patchwork Sat Sep 9 03:37:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13377951 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 40E56EEB580 for ; Sat, 9 Sep 2023 03:37:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C9356B010B; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92B046B010A; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 789AD6B0106; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 648676B0106 for ; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 391C2404FB for ; Sat, 9 Sep 2023 03:37:33 +0000 (UTC) X-FDA: 81215649186.13.92E46B8 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf16.hostedemail.com (Postfix) with ESMTP id 3C40918000B for ; Sat, 9 Sep 2023 03:37:30 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VD7vx44U; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1694230651; 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=ymCXWVcOGmA83USBg45N/qVNYjwiBUVRLqgx0UauUi77nwhfRIhy0iNy2B6L27ilToaPtm ZYvInvfjK46avMTbsUud0oQzgQXppDEAhZeTwAJbtjTmgGj092IqbkpKeYaG6o+JWbQ7MG mZfakX6hOtFl89fc/Q4/KnfIUQfFGQw= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VD7vx44U; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694230651; a=rsa-sha256; cv=none; b=JN+Kon3BjZ/BDzwNvmysxN5YT1P5LtnPUgRZoaerYcAlcjudh1iZTlO3p5VoRv/LB3oDRc RIQApc1tlWUt4CR/LJiDxW7APaj30IycHPUeDIjZQDGIqtckdYR634KazPayqkRiogfFcX +CMtLobXxF3oIduoGr05HpuHsZAFaJ8= 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 sin.source.kernel.org (Postfix) with ESMTPS id 08B2DCE179F; Sat, 9 Sep 2023 03:37:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE9D3C433CA; Sat, 9 Sep 2023 03:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694230645; bh=i00VYLhoAf7cwF/8O1Xi88bbaOl2lSsV4k5ng0qJ0ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VD7vx44U9dFth1mw8DD6/tF3vY8dJrY4i0AbyDhCeIvUZ0PjoyjTr0uDrc4XE++6n GKp6zJxyQBZgrTBQa3ylYI1tcapLevgnxvqbFpynlo61t/XVs6nxWadFFQ7Lh6ptWr Fo0v4zlMnz571bTWOm/PJ9kouinp00CWg6XtI/LEvgRfidGdzVyDiYmXcHo71yevdR vrv79Lsj0MmfleOGdqLnGH9DolmAid835/T8ZIwLIUkzZY2si3odwvphQjQNLxTdzD TltpVKUxSogUHAUYT7Fa7Ds0wUbsk6PPBcwzRrlSeZUTuzdfWn8WTwYW4jz5Ye7nkZ 9A7wodJebTOzw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC 2/8] mm/damon/vaddr: call damon_update_region_access_rate() always Date: Sat, 9 Sep 2023 03:37:05 +0000 Message-Id: <20230909033711.55794-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230909033711.55794-1-sj@kernel.org> References: <20230909033711.55794-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3C40918000B X-Stat-Signature: 9weg7rrku3bt9qmgh8wpe6o7u1dozwjg X-HE-Tag: 1694230650-248639 X-HE-Meta: U2FsdGVkX1/dxygF95iG8tU75/fQ96XmMWsNnTim+1Sg97Ub7Mmv6siDst7GaQJYVKcX7uXQKDYWxuIERXo2Hj+9zcIj0Cv4KfYDgzZuj9Vk1mqBf2LvakFWl6xgypwn/3ctnZNAJa7l7q5OCuYDonuZeLSLnK35vVrRCO+/KZ+6Jy7E8m5diOQgeGU4elX78fg4IHHwb6WHAp4JlTEkKtrAWWcTHu0BWjrr5qokuThJTofvewxDSMEhnErzXqFibpad/4cWNY/ejouqPctWJsmrFaiGCug3qPdnz6B9qKsrK1gUqLAaACdDUzHmK0qBOx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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;