Skip to content

Commit 73d7a69

Browse files
sjp38akpm00
authored andcommitted
mm/damon/core: initialize damos->walk_completed in damon_new_scheme()
The function for allocating and initialize a 'struct damos' object, damon_new_scheme(), is not initializing damos->walk_completed field. Only damos_walk_complete() is setting the field. Hence the field will be eventually set and used correctly from second damos_walk() call for the scheme. But the first damos_walk() could mistakenly not walk on the regions. Actually, a common usage of DAMOS for taking an access pattern snapshot is installing a monitoring-purpose DAMOS scheme, doing damos_walk() to retrieve the snapshot, and then removing the scheme. DAMON user-space tool (damo) also gets runtime snapshot in the way. Hence the problem can continuously happen in such use cases. Initialize it properly in the allocation function. Link: https://lkml.kernel.org/r/20250228174450.41472-1-sj@kernel.org Fixes: bf0eaba ("mm/damon/core: implement damos_walk()") Signed-off-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 39a326e commit 73d7a69

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/damon/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern,
373373
* or damon_attrs are updated.
374374
*/
375375
scheme->next_apply_sis = 0;
376+
scheme->walk_completed = false;
376377
INIT_LIST_HEAD(&scheme->filters);
377378
scheme->stat = (struct damos_stat){};
378379
INIT_LIST_HEAD(&scheme->list);

0 commit comments

Comments
 (0)