From 152d42584a98cb2e542932e63b25cc563224129f Mon Sep 17 00:00:00 2001 From: zhang jiao Date: Wed, 3 Sep 2025 15:30:59 +0800 Subject: samples/cgroup: rm unused MEMCG_EVENTS macro MEMCG_EVENTS is never referenced in the code. Just remove it. Link: https://lkml.kernel.org/r/20250903073100.2477-1-zhangjiao2@cmss.chinamobile.com Signed-off-by: zhang jiao Acked-by: Shakeel Butt Cc: Johannes Weiner Cc: Michal Hocko Cc: Muchun Song Cc: Roman Gushchin Signed-off-by: Andrew Morton --- samples/cgroup/memcg_event_listener.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'samples') diff --git a/samples/cgroup/memcg_event_listener.c b/samples/cgroup/memcg_event_listener.c index a1667fe2489a..41425edbd88a 100644 --- a/samples/cgroup/memcg_event_listener.c +++ b/samples/cgroup/memcg_event_listener.c @@ -18,8 +18,6 @@ #include #include -#define MEMCG_EVENTS "memory.events" - /* Size of buffer to use when reading inotify events */ #define INOTIFY_BUFFER_SIZE 8192 -- cgit v1.2.3 From 1f70367f7b6720ca0d3280b202317aa9d0167066 Mon Sep 17 00:00:00 2001 From: SeongJae Park Date: Mon, 15 Sep 2025 20:35:09 -0700 Subject: 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. Link: https://lkml.kernel.org/r/20250916033511.116366-6-sj@kernel.org Signed-off-by: SeongJae Park Signed-off-by: Andrew Morton --- samples/damon/wsse.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'samples') 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) -- cgit v1.2.3 From 20c0ed5035fa81872a97c46d2d5beee5aab09800 Mon Sep 17 00:00:00 2001 From: SeongJae Park Date: Mon, 15 Sep 2025 20:35:10 -0700 Subject: 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 Signed-off-by: Andrew Morton --- samples/damon/prcl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'samples') 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) -- cgit v1.2.3 From d93871f473c57ed234d4549a602163019ea5b43f Mon Sep 17 00:00:00 2001 From: SeongJae Park Date: Mon, 15 Sep 2025 20:35:11 -0700 Subject: 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 Signed-off-by: Andrew Morton --- samples/damon/mtier.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'samples') diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c index beaf36657dea..775838a23d93 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) -- cgit v1.2.3