From patchwork Mon Feb 5 20:13:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13546216 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 047E2C48292 for ; Mon, 5 Feb 2024 20:13:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67F6C6B0075; Mon, 5 Feb 2024 15:13:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 630A56B0078; Mon, 5 Feb 2024 15:13:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51F946B007B; Mon, 5 Feb 2024 15:13:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 420526B0075 for ; Mon, 5 Feb 2024 15:13:12 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D9F90A1FE4 for ; Mon, 5 Feb 2024 20:13:11 +0000 (UTC) X-FDA: 81758849382.05.6B467DB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id 5A93918000B for ; Mon, 5 Feb 2024 20:13:10 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gbwMetam; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.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=1707163990; 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:references:dkim-signature; bh=OXFHAfg/Sy0QYt16/HWs7lA5WOJANr3dV8ubWBBVsTk=; b=N5MlIU72eawWuCV2924ZRbqurGQmkamNy+SW+hPebJzvLyNYZli753nEFDTHNXd+ZTXWXt vw551Lo7L65gWeM62T7PhAk2hpzRzznZuNGp8Q1Q69i0KeBi9xfhJwCCumbgNifv1IHebn y5oEBOMssgv4Dj+qyZh1VHH0AivRuSg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gbwMetam; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.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=1707163990; a=rsa-sha256; cv=none; b=mQaqhHAcdy8QQFjeO76jLDSg1qIiB7cJ+JkEZXXFElUUCpQupYFr5BjI6Bj4tv6qMrtSr5 7HrnHUpOYdieaBgw4BIxJhC6WK0xGbSu4i3221iLyEJAB9tjOVB9JTMRl5N+sEnX9A9cdL TUACnqbnfIqiYw1jV5L+Pc69FJQkRoA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3528360AD9; Mon, 5 Feb 2024 20:13:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B3BAC43394; Mon, 5 Feb 2024 20:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707163988; bh=7ApW9U/PzSU6iKJ/LtKsXPuxdBO/3VMwuvwn+Gg1CK8=; h=From:To:Cc:Subject:Date:From; b=gbwMetamCLac9V45uSbSMx8UvaUkSokFP3rzkxc3h+C2pcjk1rBTcsAnTsA1duWne uXRLbySle00rPGrT8heYd8Q9dcCiixdSCJDYnXrAeqem4ZFTLkgr496LjtdWhFPQtN Te4+/E0se6NNT3w6eC+L+BgbU1ZmZcyTZKzjxpOtI9j2GgJubc57I+bPMCxS0l8MyR bZ8weMmMZvdgbH/VzZuXFm98KE9c8Mb3s4Z4njyZ/gbqCKGdXmUG2ax5a0Rdl/3//H 7RWuUJF3AY8d1dohXRVEMEO13MQPixIfqg+XSAHxNNoRr/f/cYtb+fmMZAhn9bkXlh jfeEOU8hmfh6g== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND] mm/damon/core: check apply interval in damon_do_apply_schemes() Date: Mon, 5 Feb 2024 12:13:06 -0800 Message-Id: <20240205201306.88562-1-sj@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: stq14m77e4rq55thkias7u95eaddis1p X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5A93918000B X-HE-Tag: 1707163990-126772 X-HE-Meta: U2FsdGVkX18gJax3q5IvM86KVa1Mxk0Urwhik5PeaqkuaTq8ASzE1s4Uf2dlT3+NNONQHXKACtAbdStdicvEWk8Dz2/71hABZNIp2u7BnbbSFON1WmZG50UdW7VbfzainqW9KOPnaBo/6oFHeWn0XNvtYJOJLQ4Q9YIE7Aqkicg/zYQAdOgv6PBgXhQlrifBSoNVDKh9zPMrg9/jSmP5yq8yZhgwE6hR7s0svaTfXP+2eaH44cSGLscLFtLHej502ltbbQ7WLjXOtzh/NGpdxB3NgLNIxyz8Ul5V3X60ELuwxTraexRdaalAxwKw9zhtThY1CDUE0f6ntvnJsifS1ka/Kp1GOw7B0vaYX7X/NKn8i9xP5Y3MvkVZys+ppMnQ1qEBsag3g6vP0N2CfwKQw3iEt79P1XA3MKL/odrrrtB3LIwixRGpLlaXccHyIpTHNfCWGXRuNV0IQpurXC+3GhZIFVGdC55YpZ/PCZpxPppJcIwi9LMtDdb8PIyo6ewWKiGTavsjZPZeVzbkVlnWVHR2rgHS48qu682I4PzNhTgYyBKCFcYZBkFfsKawmbnb6cLMbnSd44JRxghxwMGsJZrPaFzMVaDGG+HKJAfAOGbBvHVZudNnqpHVdwjMm9j2J1o7hQDWQvq6kuaKJF6RAtp+pkERkpUmXgsok4bqRGy241TpLfLFqlJn7KZcqD4pfjnGarSHNAWPzswKZXkE7jV7QVHz77L+/nAMSHeE7JGclepyli0xyY5MwiAlLuG4B6cueeXs0srMZ8ozh5UN5xhpZvxztXhp95/a8zNZehG07xrBv3COkvXDlILv6r6nuufRkFebV/Ld5x65jUs0Zy9RMwledXqfXq3uS+Oyk1i6tDhcxLleyUTqj3aZLUF2BErJ2807P6Q2F+tmLKKpiJ4iHL7PqNeL60TvxX0Y/CV11VN1pxqVPfJnwhNWNyM5bPdPaWP8A0UaQFXQSQ4 7d84MPSf HO4HyVOqswtlqaO+I4EplZUAB1XRssb46XJaLoZUAIVczB99ysHPRHymI7RW6bCeu1U1KBErft48UJTxbmxfIlN3wOsKGdi3IssygLd8UvqC5VcTsK0Sx1fyfJizN/7wo/b3RdLOb+U8ZQopsJFLT5e+SJYJT33RfpBfzbsibNmXIjsNC9Fc9ZoG3huR8WfpXle1nZdyAUph2IeZdt+nJyjhWgXWwrGb8ZNmyzua7n1a3z+eUGs7kRoe4Iyxa5eHutVMM/mF40EoxE7zQrBewTT1kWxWWfhA7XHYF X-Bogosity: 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: List-Subscribe: List-Unsubscribe: kdamond_apply_schemes() checks apply intervals of schemes and avoid further applying any schemes if no scheme passed its apply interval. However, the following schemes applying function, damon_do_apply_schemes() iterates all schemes without the apply interval check. As a result, the shortest apply interval is applied to all schemes. Fix the problem by checking the apply interval in damon_do_apply_schemes(). Fixes: 42f994b71404 ("mm/damon/core: implement scheme-specific apply interval") Cc: # 6.7.x Signed-off-by: SeongJae Park --- Sending the same patch[1] again because the subject of the patch was broken. [1] https://lore.kernel.org/linux-mm/20240204204946.87265-1-sj@kernel.org/ mm/damon/core.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 0c144fb466b8..f444734cc613 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1064,6 +1064,9 @@ static void damon_do_apply_schemes(struct damon_ctx *c, damon_for_each_scheme(s, c) { struct damos_quota *quota = &s->quota; + if (c->passed_sample_intervals != s->next_apply_sis) + continue; + if (!s->wmarks.activated) continue; @@ -1216,10 +1219,6 @@ static void kdamond_apply_schemes(struct damon_ctx *c) if (c->passed_sample_intervals != s->next_apply_sis) continue; - s->next_apply_sis += - (s->apply_interval_us ? s->apply_interval_us : - c->attrs.aggr_interval) / sample_interval; - if (!s->wmarks.activated) continue; @@ -1235,6 +1234,14 @@ static void kdamond_apply_schemes(struct damon_ctx *c) damon_for_each_region_safe(r, next_r, t) damon_do_apply_schemes(c, t, r); } + + damon_for_each_scheme(s, c) { + if (c->passed_sample_intervals != s->next_apply_sis) + continue; + s->next_apply_sis += + (s->apply_interval_us ? s->apply_interval_us : + c->attrs.aggr_interval) / sample_interval; + } } /*