]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/damon/core: initialize damos->walk_completed in damon_new_scheme()
authorSeongJae Park <sj@kernel.org>
Fri, 28 Feb 2025 17:44:50 +0000 (09:44 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 4 Mar 2025 05:48:35 +0000 (21:48 -0800)
commitb76d220bf9704cb578b0b0c79c9a8136130262eb
tree869d2b0241fd3145193f75bffdf04143174328af
parent9ebb5bf9c7300a5aee70b692be9d2e2660a5539d
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: bf0eaba0ff9c ("mm/damon/core: implement damos_walk()")
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/core.c