summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorSeongJae Park <sj@kernel.org>2025-09-15 20:35:10 -0700
committerAndrew Morton <akpm@linux-foundation.org>2025-09-21 14:22:38 -0700
commit20c0ed5035fa81872a97c46d2d5beee5aab09800 (patch)
treecb3f78d7dbdea32cae079e50677b0641efb217f9 /samples
parent1f70367f7b6720ca0d3280b202317aa9d0167066 (diff)
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>
Diffstat (limited to 'samples')
-rw-r--r--samples/damon/prcl.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/samples/damon/prcl.c b/samples/damon/prcl.c
index 0226652f94d5..b7c50f2656ce 100644
--- a/samples/damon/prcl.c
+++ b/samples/damon/prcl.c
@@ -122,8 +122,6 @@ static void damon_sample_prcl_stop(void)
}
}
-static bool init_called;
-
static int damon_sample_prcl_enable_store(
const char *val, const struct kernel_param *kp)
{
@@ -137,7 +135,7 @@ static int damon_sample_prcl_enable_store(
if (enabled == is_enabled)
return 0;
- if (!init_called)
+ if (!damon_initialized())
return 0;
if (enabled) {
@@ -154,7 +152,12 @@ static int __init damon_sample_prcl_init(void)
{
int err = 0;
- init_called = true;
+ if (!damon_initialized()) {
+ if (enabled)
+ enabled = false;
+ return -ENOMEM;
+ }
+
if (enabled) {
err = damon_sample_prcl_start();
if (err)