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: 197047 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1164703dyb; Mon, 5 Feb 2024 13:53:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3ogrTNsaUWNRuyq928VyfRzvdCRMm0XB2sO3YQaALg7apDNTep/pfb0Dm5qAfslA67b6g X-Received: by 2002:a05:6358:3a17:b0:176:543c:8ef0 with SMTP id g23-20020a0563583a1700b00176543c8ef0mr186938rwe.21.1707170020068; Mon, 05 Feb 2024 13:53:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707170020; cv=pass; d=google.com; s=arc-20160816; b=kG07qrm2wdb2O5m8TAI1lxXE2e+joCUoDPJpGW1nalWrHFW5rnTn4lgm3ytOw942Md MPsusBO5w4yzKa2ct8Il3OKhdh1+Znz+znsVJ73jGtvjWzINsK6qSXvEpKNbimuRreI6 qMMCYhq4ToDXtzf2Mazbbcr/YaU0zjbbH5QajVSkQnVuv4LYPnCsQXoJa05s1lDLzseh 0Mk/JdU+oW3aG5o03gDsMtbuWLPKdJy6u4dwtDuwk3GJv1fVEQO03tWYNcmzDzQ5UMwF FhI3nnejdZu5ERduT2y9qsgJ9TYexxPdHBfKz7sxsOHcBFHDTUYK662FDIy8jplgm6P/ spYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=OXFHAfg/Sy0QYt16/HWs7lA5WOJANr3dV8ubWBBVsTk=; fh=GmzStS/M2XT8BTg8Ll31+YhKD1ZRpiwrbOtLHKOs9yg=; b=LoScOpAwaQOab6ZMH8PIwRbV3ow/7SaHETlgji3aY2dHOnLMeIXVXi3/qhH/igbqzS eMJ+Zthgy72moA7hDdePqccDSI2ys6mVpMIO3invDZ4WNu6xJXyF0JqVAx5Ak0bw08Lf UZ1mRxvauolsZpY9ekViRkIqqV/i2BP+YFDwmbU6TSYRuvR8tJh0zxTb7L07CEJzpPRi AKQs7HQUgunmb/4ANXfTTsEkD0V2k1keohGEOlv9bRaERvrv2TXJ3OYUjrPrKjgGyHGm TDzlUVzFALhVmHHjbZljnRGCb/TK+dhjoesxHnKnXwzdtgC9w8thbagEcM9IanYlGTDf CKgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gbwMetam; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-53900-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53900-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWg3/in5aR7GaK76BOwMqFr6dlVQrFfT4Oj49nkHc3+AblQVloGTq81ILLMHr5IJqYZoLCVItt+YPDIebfF2jYTJD0mqQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bv192-20020a632ec9000000b005d80a51e1c2si488087pgb.329.2024.02.05.13.53.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:53:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53900-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gbwMetam; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-53900-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53900-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C1A66293759 for ; Mon, 5 Feb 2024 21:43:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03125130AE9; Mon, 5 Feb 2024 20:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gbwMetam" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59C9012FF91; Mon, 5 Feb 2024 20:13:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707163989; cv=none; b=oS8IYh5MjtLxTH3SfMj0AkrZJwUP5Bzk0CySnBZy5QTmQmFUtmc/GlB8C4Dx+dOJ8/71ONgIWiUAryi0BTs8m6eAX1gzrYQfSB+IUoK5I79GyTiu2s5vn0QyeAbq6YP3exLyBLMRR/z6aKq328P7zD/tPAxg0h/Pcspvgo7oqvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707163989; c=relaxed/simple; bh=7ApW9U/PzSU6iKJ/LtKsXPuxdBO/3VMwuvwn+Gg1CK8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=V62mTSmD/k9s62pGHj5GRIfBV1hhyV6uzQv6JHKLM8CTaOpOCNEvwuTYQIl1XYHEArDAY1wxZOw1fNG1j4LvZcNTJzRgBHMV6e7H8UAbe+Qo0WU/k5YPAXltTnrfXrnYeLKw9nnl3SG814VmJFeZlo7+86H0nI+cuDAsm3M55Jg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gbwMetam; arc=none smtp.client-ip=10.30.226.201 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790097511159649241 X-GMAIL-MSGID: 1790097511159649241 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; + } } /*