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.

samples/damon/mtier: use damon_initialized()

damon_sample_mtier 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-8-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
d93871f4 20c0ed50

+7 -4
+7 -4
samples/damon/mtier.c
··· 193 193 damon_destroy_ctx(ctxs[1]); 194 194 } 195 195 196 - static bool init_called; 197 - 198 196 static int damon_sample_mtier_enable_store( 199 197 const char *val, const struct kernel_param *kp) 200 198 { ··· 206 208 if (enabled == is_enabled) 207 209 return 0; 208 210 209 - if (!init_called) 211 + if (!damon_initialized()) 210 212 return 0; 211 213 212 214 if (enabled) { ··· 223 225 { 224 226 int err = 0; 225 227 226 - init_called = true; 228 + if (!damon_initialized()) { 229 + if (enabled) 230 + enabled = false; 231 + return -ENOMEM; 232 + } 233 + 227 234 if (enabled) { 228 235 err = damon_sample_mtier_start(); 229 236 if (err)