Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/stat: use damon_initialized()

DAMON_STAT is assuming DAMON is ready to use in module_init time, and uses
its own hack to see if it is the time. Use damon_initialized(), which is
a way for seeing if DAMON is ready to be used that is more reliable and
better to maintain instead of the hack.

Link: https://lkml.kernel.org/r/20250916033511.116366-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
b663f17b ab152db3

+6 -4
+6 -4
mm/damon/stat.c
··· 214 214 damon_destroy_ctx(damon_stat_context); 215 215 } 216 216 217 - static bool damon_stat_init_called; 218 - 219 217 static int damon_stat_enabled_store( 220 218 const char *val, const struct kernel_param *kp) 221 219 { ··· 227 229 if (is_enabled == enabled) 228 230 return 0; 229 231 230 - if (!damon_stat_init_called) 232 + if (!damon_initialized()) 231 233 /* 232 234 * probably called from command line parsing (parse_args()). 233 235 * Cannot call damon_new_ctx(). Let damon_stat_init() handle. ··· 248 250 { 249 251 int err = 0; 250 252 251 - damon_stat_init_called = true; 253 + if (!damon_initialized()) { 254 + err = -ENOMEM; 255 + goto out; 256 + } 252 257 253 258 /* probably set via command line */ 254 259 if (enabled) 255 260 err = damon_stat_start(); 256 261 262 + out: 257 263 if (err && enabled) 258 264 enabled = false; 259 265 return err;