From patchwork Sun Feb 4 20:49:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 196580 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp526233dyb; Sun, 4 Feb 2024 12:50:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZKPW1++XIeLm2U5leHhnXQjH+hZp6CNXJYCXfnTDbggTcxN7I9s9apxSpgSBqiuPMEUGy X-Received: by 2002:a17:90b:118e:b0:296:2a15:5f27 with SMTP id gk14-20020a17090b118e00b002962a155f27mr5908031pjb.2.1707079805786; Sun, 04 Feb 2024 12:50:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707079805; cv=pass; d=google.com; s=arc-20160816; b=XoILZD6tBUjoS8aS1tHCALsqHc9pf8pyj88d+Bonqj+2U5em7vVmZBcXDJS7s1vWQF yKv9nFk0ZDhTkClFXqrT0EM1p8Zduyng8opiBOH5Uay4ERFk4u0JwhES9ALa566Z7kMd CdNj/+zh155hVGQ6J2PqhuuMjnY/KMS5i+kgD3BnNBhq/Wuuqk7va19/v+kAbtj6MmS1 /MbqAjVL3/XyU3+IQg8+Z31ffu/ekx1VEH9j8gsVNQ9I+NPyteZLoRN+rf37+KnHXg06 kktifhvB5mTGsJZG+3cP6CIndunDmT8+gzmtswyCvT+QkZZZsma2qIBMgMHDHKb2YBwy d8yQ== 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=paJfMwDaRpJJ39n/Dl7MgdQ5pk6gnmEdwIcTkVY0JVE=; fh=xkJyTVDA38lT+L/mO9syhkeoOB/vKZ79/D49bu4Z01s=; b=HsTAffWKSxRXxdkKc0E+Njay4UatiuLDAhQhAMfYi5tjqrUtgtbSg41B6ZUpOFH/h6 c1uZdgy3mpWCbQ7ckrRdYgBgtbCHjOFXdKoBwjTvS4Qe7UJulReTxrwYCPCUOzrRWxcH 8sp/9y9FSngrMRSLQ0Wf5znXx6G7sH7V1/6no5V671g62SX4ItyMu6D2mD1pNBG1MT/7 UhL79DTuyNxPyyYCkLpingyNKMZctjgih4l9XkcfEEKfkmncX8mqaa0t6ZnMep5TkvSU RFqFnSLFLY+Vq3AwnwIiyhwLxWYr6//81GcDHyzPGScsuzEWUfKWZmIGBtOUUce7y3pY ljrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KrVlmveh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-51893-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51893-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCV60wieGC/mxLY2VlmqUYHGmX7zBA9kNb0ZJ8pTEs7sbLet2Yle1OrlZ20CUWES7cwSpawGjfYzGzlkK4NUY6krhLMGdg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w21-20020a170902d3d500b001d94beef7c6si4197324plb.486.2024.02.04.12.50.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 12:50:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51893-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=KrVlmveh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-51893-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51893-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 8B839282CF5 for ; Sun, 4 Feb 2024 20:50:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB10D28E3F; Sun, 4 Feb 2024 20:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KrVlmveh" 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 ED5EE286A6; Sun, 4 Feb 2024 20:49:49 +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=1707079790; cv=none; b=Uezyccpl3FIjoHA/XM7jVytuIgvUi1VtYmHswzBV4yxGBLYQ4k0kk49OWy6gNi4bu7mZWwzVkr6fQ+1vCrsb/ad92Gk2mu1NgS68gNvYOCHsR82MXj6vEOa5BMQHJBmxKxF4OjcZH/0wPTv+PqgvQAAbHEiXb3OP1m/RbQbMsyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707079790; c=relaxed/simple; bh=ojWqsp/aBmsejpkcR12AdCvNFJNKEtttghVnPq6oxmo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=PegV9SgRU1+7nEsMY98g+gW2tP2YYqfAAyamoIllnZbI+sLFe6bnzWxUwW1C5aowpNi/E0zcSgrWJrJGca+ld3Xt9bB7B1fsnAEwuqPiWsXTYrJstKL28pbDHL3THymNnZJo+C726fa/oNA4eBTPXAKnJ/WowaQJ4Zt3VEz/x9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KrVlmveh; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECEA3C433F1; Sun, 4 Feb 2024 20:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707079789; bh=ojWqsp/aBmsejpkcR12AdCvNFJNKEtttghVnPq6oxmo=; h=From:To:Cc:Subject:Date:From; b=KrVlmvehk3qAqC+mImzdxev2eaBuCLiF9nGmJQWSJUbYP4cUxdbBXWqtTJ7yJWpgy mdPXBGLldb83ha+ULf1yZBkhZW4ONAWapMVJ6P6uWEp2HryAOamInDXSWiESvcUCXs gPnehXOU0ehnm+e0fYyZZUfUOjCX6wKN8Lq4sMsbHTDsvUlSEMCHvU7tWNdLAeSSLx k0ZEMQR9yk/gau7hzbDCH+uuW8x6KHADGc/66gqc4yl9j6H7JoKShegAoDdgFz8mhO 2P3UMLO9l5xdWM1dhBRiIpRVyUWE2H3XpmmH5zJg0SCkNGRvRs5cr6tRT+7TXO1p5c XdpsR48O2aXyw== 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] mm/damon/core: check apply interval in Date: Sun, 4 Feb 2024 12:49:46 -0800 Message-Id: <20240204204946.87265-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: 1790002914347446535 X-GMAIL-MSGID: 1790002914347446535 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 --- 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; + } } /*