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>
}
}
-static bool init_called;
-
static int damon_sample_prcl_enable_store(
const char *val, const struct kernel_param *kp)
{
if (enabled == is_enabled)
return 0;
- if (!init_called)
+ if (!damon_initialized())
return 0;
if (enabled) {
{
int err = 0;
- init_called = true;
+ if (!damon_initialized()) {
+ if (enabled)
+ enabled = false;
+ return -ENOMEM;
+ }
+
if (enabled) {
err = damon_sample_prcl_start();
if (err)