This is a note to let you know that I've just added the patch titled mm/damon/core: check apply interval in damon_do_apply_schemes() to the 6.7-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-damon-core-check-apply-interval-in-damon_do_apply_schemes.patch and it can be found in the queue-6.7 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From e9e3db69966d5e9e6f7e7d017b407c0025180fe5 Mon Sep 17 00:00:00 2001 From: SeongJae Park <sj@xxxxxxxxxx> Date: Mon, 5 Feb 2024 12:13:06 -0800 Subject: mm/damon/core: check apply interval in damon_do_apply_schemes() From: SeongJae Park <sj@xxxxxxxxxx> commit e9e3db69966d5e9e6f7e7d017b407c0025180fe5 upstream. 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(). Link: https://lkml.kernel.org/r/20240205201306.88562-1-sj@xxxxxxxxxx Fixes: 42f994b71404 ("mm/damon/core: implement scheme-specific apply interval") Signed-off-by: SeongJae Park <sj@xxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> [6.7.x] Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- mm/damon/core.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1026,6 +1026,9 @@ static void damon_do_apply_schemes(struc 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; @@ -1126,10 +1129,6 @@ static void kdamond_apply_schemes(struct 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; @@ -1145,6 +1144,14 @@ static void kdamond_apply_schemes(struct 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; + } } /* Patches currently in stable-queue which might be from sj@xxxxxxxxxx are queue-6.7/mm-damon-lru_sort-fix-quota-status-loss-due-to-online-tunings.patch queue-6.7/mm-damon-reclaim-fix-quota-stauts-loss-due-to-online-tunings.patch queue-6.7/mm-damon-core-check-apply-interval-in-damon_do_apply_schemes.patch queue-6.7/mm-swap-fix-race-when-skipping-swapcache.patch