[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250912023946.62337-6-sj@kernel.org>
Date: Thu, 11 Sep 2025 19:39:44 -0700
From: SeongJae Park <sj@...nel.org>
To:
Cc: SeongJae Park <sj@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
damon@...ts.linux.dev,
kernel-team@...a.com,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org
Subject: [RFC PATCH 5/7] samples/damon/wsse: use damon_initialized()
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.
Signed-off-by: SeongJae Park <sj@...nel.org>
---
samples/damon/wsse.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/samples/damon/wsse.c b/samples/damon/wsse.c
index 21eaf15f987d..799ad4443943 100644
--- a/samples/damon/wsse.c
+++ b/samples/damon/wsse.c
@@ -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)
--
2.39.5
Powered by blists - more mailing lists