]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
samples/damon/wsse: use damon_initialized()
authorSeongJae Park <sj@kernel.org>
Tue, 16 Sep 2025 03:35:09 +0000 (20:35 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 21 Sep 2025 21:22:38 +0000 (14:22 -0700)
damon_sample_wsse 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-6-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
samples/damon/wsse.c

index 21eaf15f987d47f5ec8e654365cf05ad37c9b61a..799ad44439434a8645f2f5a09370175e2e2a963b 100644 (file)
@@ -102,8 +102,6 @@ static void damon_sample_wsse_stop(void)
        }
 }
 
-static bool init_called;
-
 static int damon_sample_wsse_enable_store(
                const char *val, const struct kernel_param *kp)
 {
@@ -117,10 +115,10 @@ static int damon_sample_wsse_enable_store(
        if (enabled == is_enabled)
                return 0;
 
-       if (enabled) {
-               if (!init_called)
-                       return 0;
+       if (!damon_initialized())
+               return 0;
 
+       if (enabled) {
                err = damon_sample_wsse_start();
                if (err)
                        enabled = false;
@@ -134,7 +132,12 @@ static int __init damon_sample_wsse_init(void)
 {
        int err = 0;
 
-       init_called = true;
+       if (!damon_initialized()) {
+               err = -ENOMEM;
+               if (enabled)
+                       enabled = false;
+       }
+
        if (enabled) {
                err = damon_sample_wsse_start();
                if (err)