diff options
| author | SeongJae Park <sj@kernel.org> | 2025-09-15 20:35:11 -0700 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2025-09-21 14:22:39 -0700 |
| commit | d93871f473c57ed234d4549a602163019ea5b43f (patch) | |
| tree | 4e179f423d31f0f4f64c41398fa220c3c85dadab /samples | |
| parent | 20c0ed5035fa81872a97c46d2d5beee5aab09800 (diff) | |
| download | linux-d93871f473c57ed234d4549a602163019ea5b43f.tar.gz | |
samples/damon/mtier: use damon_initialized()
damon_sample_mtier 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-8-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/mtier.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c index beaf36657deacc..775838a23d9353 100644 --- a/samples/damon/mtier.c +++ b/samples/damon/mtier.c @@ -193,8 +193,6 @@ static void damon_sample_mtier_stop(void) damon_destroy_ctx(ctxs[1]); } -static bool init_called; - static int damon_sample_mtier_enable_store( const char *val, const struct kernel_param *kp) { @@ -208,7 +206,7 @@ static int damon_sample_mtier_enable_store( if (enabled == is_enabled) return 0; - if (!init_called) + if (!damon_initialized()) return 0; if (enabled) { @@ -225,7 +223,12 @@ static int __init damon_sample_mtier_init(void) { int err = 0; - init_called = true; + if (!damon_initialized()) { + if (enabled) + enabled = false; + return -ENOMEM; + } + if (enabled) { err = damon_sample_mtier_start(); if (err) |
