The patch titled Subject: mm/damon/core: ensure max threshold attempt for max_nr_regions violation has been added to the -mm mm-hotfixes-unstable branch. Its filename is mm-damon-core-merge-regions-aggressively-when-max_nr_regions-is-unmet-fix-2.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-core-merge-regions-aggressively-when-max_nr_regions-is-unmet-fix-2.patch This patch will later appear in the mm-hotfixes-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: SeongJae Park <sj@xxxxxxxxxx> Subject: mm/damon/core: ensure max threshold attempt for max_nr_regions violation Date: Thu, 27 Jun 2024 09:31:52 -0700 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. Link: https://lkml.kernel.org/r/20240627163153.75969-1-sj@xxxxxxxxxx Fixes: ed6cb9d022c8 ("mm/damon/core: increase regions merge aggressiveness while respecting min_nr_regions") # mm-unstable Signed-off-by: SeongJae Park <sj@xxxxxxxxxx> Closes: https://lore.kernel.org/20240626214954.46143-1-sj@xxxxxxxxxx Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/damon/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/damon/core.c~mm-damon-core-merge-regions-aggressively-when-max_nr_regions-is-unmet-fix-2 +++ a/mm/damon/core.c @@ -1382,7 +1382,7 @@ static void kdamond_merge_regions(struct } threshold = max(1, threshold * 2); } while (nr_regions > c->attrs.max_nr_regions && - threshold <= max_thres); + threshold / 2 < max_thres); } /* _ Patches currently in -mm which might be from sj@xxxxxxxxxx are mm-damon-core-merge-regions-aggressively-when-max_nr_regions-is-unmet.patch mm-damon-core-merge-regions-aggressively-when-max_nr_regions-is-unmet-fix.patch mm-damon-core-merge-regions-aggressively-when-max_nr_regions-is-unmet-fix-2.patch docs-mm-damon-maintainer-profile-introduce-hackermail.patch docs-mm-damon-maintainer-profile-document-damon-community-meetups.patch selftests-damon-access_memory-use-user-defined-region-size.patch selftests-damon-_damon_sysfs-support-schemes_update_tried_regions.patch selftests-damon-implement-a-program-for-even-numbered-memory-regions-access.patch selftests-damon-implement-damos-tried-regions-test.patch selftests-damon-_damon_sysfs-implement-kdamonds-stop-function.patch selftests-damon-implement-test-for-min-max_nr_regions.patch _damon_sysfs-implement-commit-for-online-parameters-update.patch selftests-damon-damon_nr_regions-test-online-tuned-max_nr_regions.patch