linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: SeongJae Park <sj@kernel.org>, Andrew Morton <akpm@linux-foundation.org>
Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH mm-unstable] mm/damon/core: ensure max threshold attempt for max_nr_regions violation
Date: Thu, 27 Jun 2024 09:31:52 -0700	[thread overview]
Message-ID: <20240627163153.75969-1-sj@kernel.org> (raw)

Since commit ed6cb9d022c8 ("mm/damon/core: increase regions merge
aggressiveness while respecting min_nr_regions") of mm-unstable,
kdamond_merge_regions() stops the repeated merge attempts for meeting
max_nr_regions if the merge threshold that increased for next iteration
is higher than the possible maximum threshold.  Hence, it can skip a
merge attempt with the maximum threshold depending on the amount of the
threshold increase, the maximum threshold, and the last-used threshold
value.  In extreme situations (e.g., region 1 has 100% access frequency,
region 2 has 0% access frequency, so on), this can degrade the
max_nr_regions violation recovery.

Fix this by stopping the loop by comparing the last-used threshold
instead of the to-be-used threshold, and if the last-used threshold is
same to or higher than the maximum possible threshold.

Fixes: ed6cb9d022c8 ("mm/damon/core: increase regions merge aggressiveness while respecting min_nr_regions") # mm-unstable
Closes: https://lore.kernel.org/20240626214954.46143-1-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index dac27b949403..7a87628b76ab 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1718,7 +1718,7 @@ static void kdamond_merge_regions(struct damon_ctx *c, unsigned int threshold,
 		}
 		threshold = max(1, threshold * 2);
 	} while (nr_regions > c->attrs.max_nr_regions &&
-			threshold <= max_thres);
+			threshold / 2 < max_thres);
 }
 
 /*
-- 
2.39.2



                 reply	other threads:[~2024-06-27 16:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240627163153.75969-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox