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

samples/damon/prcl: use damon_initialized()

damon_sample_prcl 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-7-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
20c0ed50 1f70367f

+7 -4
+7 -4
samples/damon/prcl.c
··· 122 122 } 123 123 } 124 124 125 - static bool init_called; 126 - 127 125 static int damon_sample_prcl_enable_store( 128 126 const char *val, const struct kernel_param *kp) 129 127 { ··· 135 137 if (enabled == is_enabled) 136 138 return 0; 137 139 138 - if (!init_called) 140 + if (!damon_initialized()) 139 141 return 0; 140 142 141 143 if (enabled) { ··· 152 154 { 153 155 int err = 0; 154 156 155 - init_called = true; 157 + if (!damon_initialized()) { 158 + if (enabled) 159 + enabled = false; 160 + return -ENOMEM; 161 + } 162 + 156 163 if (enabled) { 157 164 err = damon_sample_prcl_start(); 158 165 if (err)