Skip to content

Commit 591c4c7

Browse files
sjp38akpm00
authored andcommitted
mm/damon/core: warn and fix nr_accesses[_bp] corruption
Patch series "mm/damon: minor fixups and improvements for code, tests, and documents". Yet another batch of miscellaneous DAMON changes. Fix and improve minor problems in code, tests and documents. This patch (of 6): For a bug such as double aggregation reset[1], ->nr_accesses and/or ->nr_accesses_bp of damon_region could be corrupted. Such corruption can make monitoring results pretty inaccurate, so the root causing bug should be investigated. Meanwhile, the corruption itself can easily be fixed but silently fixing it will hide the bug. Fix the corruption as soon as found, but WARN_ONCE() so that we can be aware of the existence of the bug while keeping the system running in a more sane way. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Link: https://lore.kernel.org/[email protected] [1] Signed-off-by: SeongJae Park <[email protected]> Cc: Brendan Higgins <[email protected]> Cc: David Gow <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 2aad4ed commit 591c4c7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mm/damon/core.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,19 @@ int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control)
13911391
return 0;
13921392
}
13931393

1394+
/*
1395+
* Warn and fix corrupted ->nr_accesses[_bp] for investigations and preventing
1396+
* the problem being propagated.
1397+
*/
1398+
static void damon_warn_fix_nr_accesses_corruption(struct damon_region *r)
1399+
{
1400+
if (r->nr_accesses_bp == r->nr_accesses * 10000)
1401+
return;
1402+
WARN_ONCE(true, "invalid nr_accesses_bp at reset: %u %u\n",
1403+
r->nr_accesses_bp, r->nr_accesses);
1404+
r->nr_accesses_bp = r->nr_accesses * 10000;
1405+
}
1406+
13941407
/*
13951408
* Reset the aggregated monitoring results ('nr_accesses' of each region).
13961409
*/
@@ -1404,6 +1417,7 @@ static void kdamond_reset_aggregated(struct damon_ctx *c)
14041417

14051418
damon_for_each_region(r, t) {
14061419
trace_damon_aggregated(ti, r, damon_nr_regions(t));
1420+
damon_warn_fix_nr_accesses_corruption(r);
14071421
r->last_nr_accesses = r->nr_accesses;
14081422
r->nr_accesses = 0;
14091423
}

0 commit comments

Comments
 (0)