diff --git a/include/linux/damon.h b/include/linux/damon.h index cb6a50032a1e..380f9cf6ddd8 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -963,6 +963,11 @@ struct damon_ctx { * for more details. */ unsigned long last_nr_regions; + /* + * number of damon_split_some_regions() invocations for this context. + * Read damon_split_some_regions() for more details. + */ + unsigned long region_split_rotation; }; /* Get a random number in [@l, @r) using @ctx's lockless PRNG. */ diff --git a/mm/damon/core.c b/mm/damon/core.c index 09722257ce73..73b571b429cb 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -3753,12 +3753,13 @@ static void damon_split_regions_of(struct damon_ctx *ctx, static void damon_split_some_regions(struct damon_ctx *ctx, unsigned long split_step) { - static unsigned long rotation; struct damon_target *t; struct damon_region *r, *next; - unsigned long offset = rotation++ % split_step; + unsigned long offset; unsigned long idx = 0; + offset = ctx->region_split_rotation++ % split_step; + damon_for_each_target(t, ctx) { damon_for_each_region_safe(r, next, t) { unsigned long sz_region, sz_sub;