* FAILED: patch "[PATCH] samples/damon/mtier: avoid starting DAMON before" failed to apply to 6.16-stable tree
@ 2025-09-21 12:18 gregkh
2025-09-21 14:11 ` [PATCH 6.16.y 1/3] samples/damon/prcl: fix boot time enable crash Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2025-09-21 12:18 UTC (permalink / raw)
To: sj, akpm, stable; +Cc: stable
The patch below does not apply to the 6.16-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.16.y
git checkout FETCH_HEAD
git cherry-pick -x c62cff40481c037307a13becbda795f7afdcfebd
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025092116-ceramics-stratus-5d18@gregkh' --subject-prefix 'PATCH 6.16.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From c62cff40481c037307a13becbda795f7afdcfebd Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj@kernel.org>
Date: Mon, 8 Sep 2025 19:22:38 -0700
Subject: [PATCH] samples/damon/mtier: avoid starting DAMON before
initialization
Commit 964314344eab ("samples/damon/mtier: support boot time enable
setup") is somehow incompletely applying the origin patch [1]. It is
missing the part that avoids starting DAMON before module initialization.
Probably a mistake during a merge has happened. Fix it by applying the
missed part again.
Link: https://lkml.kernel.org/r/20250909022238.2989-4-sj@kernel.org
Link: https://lore.kernel.org/20250706193207.39810-4-sj@kernel.org [1]
Fixes: 964314344eab ("samples/damon/mtier: support boot time enable setup")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c
index 7ebd352138e4..beaf36657dea 100644
--- a/samples/damon/mtier.c
+++ b/samples/damon/mtier.c
@@ -208,6 +208,9 @@ static int damon_sample_mtier_enable_store(
if (enabled == is_enabled)
return 0;
+ if (!init_called)
+ return 0;
+
if (enabled) {
err = damon_sample_mtier_start();
if (err)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 6.16.y 1/3] samples/damon/prcl: fix boot time enable crash
2025-09-21 12:18 FAILED: patch "[PATCH] samples/damon/mtier: avoid starting DAMON before" failed to apply to 6.16-stable tree gregkh
@ 2025-09-21 14:11 ` Sasha Levin
2025-09-21 14:11 ` [PATCH 6.16.y 2/3] samples/damon: change enable parameters to enabled Sasha Levin
2025-09-21 14:11 ` [PATCH 6.16.y 3/3] samples/damon/mtier: avoid starting DAMON before initialization Sasha Levin
0 siblings, 2 replies; 4+ messages in thread
From: Sasha Levin @ 2025-09-21 14:11 UTC (permalink / raw)
To: stable; +Cc: SeongJae Park, Andrew Morton, Sasha Levin
From: SeongJae Park <sj@kernel.org>
[ Upstream commit 2780505ec2b42c07853b34640bc63279ac2bb53b ]
If 'enable' parameter of the 'prcl' DAMON sample module is set at boot
time via the kernel command line, memory allocation is tried before the
slab is initialized. As a result kernel NULL pointer dereference BUG can
happen. Fix it by checking the initialization status.
Link: https://lkml.kernel.org/r/20250706193207.39810-3-sj@kernel.org
Fixes: 2aca254620a8 ("samples/damon: introduce a skeleton of a smaple DAMON module for proactive reclamation")
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Stable-dep-of: c62cff40481c ("samples/damon/mtier: avoid starting DAMON before initialization")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
samples/damon/prcl.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/samples/damon/prcl.c b/samples/damon/prcl.c
index 5597e6a08ab22..a9d7629d70f0a 100644
--- a/samples/damon/prcl.c
+++ b/samples/damon/prcl.c
@@ -109,6 +109,8 @@ static void damon_sample_prcl_stop(void)
put_pid(target_pidp);
}
+static bool init_called;
+
static int damon_sample_prcl_enable_store(
const char *val, const struct kernel_param *kp)
{
@@ -134,6 +136,14 @@ static int damon_sample_prcl_enable_store(
static int __init damon_sample_prcl_init(void)
{
+ int err = 0;
+
+ init_called = true;
+ if (enable) {
+ err = damon_sample_prcl_start();
+ if (err)
+ enable = false;
+ }
return 0;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 6.16.y 2/3] samples/damon: change enable parameters to enabled
2025-09-21 14:11 ` [PATCH 6.16.y 1/3] samples/damon/prcl: fix boot time enable crash Sasha Levin
@ 2025-09-21 14:11 ` Sasha Levin
2025-09-21 14:11 ` [PATCH 6.16.y 3/3] samples/damon/mtier: avoid starting DAMON before initialization Sasha Levin
1 sibling, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-09-21 14:11 UTC (permalink / raw)
To: stable; +Cc: Honggyu Kim, SeongJae Park, Andrew Morton, Sasha Levin
From: Honggyu Kim <honggyu.kim@sk.com>
[ Upstream commit 793020545cea0c9e2a79de6ad5c9746ec4f5bd7e ]
The damon_{lru_sort,reclaim,stat} kernel modules use "enabled" parameter
knobs as follows.
/sys/module/damon_lru_sort/parameters/enabled
/sys/module/damon_reclaim/parameters/enabled
/sys/module/damon_stat/parameters/enabled
However, other sample modules of damon use "enable" parameter knobs so
it'd be better to rename them from "enable" to "enabled" to keep the
consistency with other damon modules.
Before:
/sys/module/damon_sample_wsse/parameters/enable
/sys/module/damon_sample_prcl/parameters/enable
/sys/module/damon_sample_mtier/parameters/enable
After:
/sys/module/damon_sample_wsse/parameters/enabled
/sys/module/damon_sample_prcl/parameters/enabled
/sys/module/damon_sample_mtier/parameters/enabled
There is no functional changes in this patch.
Link: https://lkml.kernel.org/r/20250707024548.1964-1-honggyu.kim@sk.com
Signed-off-by: Honggyu Kim <honggyu.kim@sk.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Stable-dep-of: c62cff40481c ("samples/damon/mtier: avoid starting DAMON before initialization")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
samples/damon/mtier.c | 22 +++++++++++-----------
samples/damon/prcl.c | 22 +++++++++++-----------
samples/damon/wsse.c | 22 +++++++++++-----------
3 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c
index ed6bed8b3d4d9..11cbfea1af675 100644
--- a/samples/damon/mtier.c
+++ b/samples/damon/mtier.c
@@ -27,14 +27,14 @@ module_param(node1_end_addr, ulong, 0600);
static int damon_sample_mtier_enable_store(
const char *val, const struct kernel_param *kp);
-static const struct kernel_param_ops enable_param_ops = {
+static const struct kernel_param_ops enabled_param_ops = {
.set = damon_sample_mtier_enable_store,
.get = param_get_bool,
};
-static bool enable __read_mostly;
-module_param_cb(enable, &enable_param_ops, &enable, 0600);
-MODULE_PARM_DESC(enable, "Enable of disable DAMON_SAMPLE_MTIER");
+static bool enabled __read_mostly;
+module_param_cb(enabled, &enabled_param_ops, &enabled, 0600);
+MODULE_PARM_DESC(enabled, "Enable or disable DAMON_SAMPLE_MTIER");
static struct damon_ctx *ctxs[2];
@@ -156,20 +156,20 @@ static bool init_called;
static int damon_sample_mtier_enable_store(
const char *val, const struct kernel_param *kp)
{
- bool enabled = enable;
+ bool is_enabled = enabled;
int err;
- err = kstrtobool(val, &enable);
+ err = kstrtobool(val, &enabled);
if (err)
return err;
- if (enable == enabled)
+ if (enabled == is_enabled)
return 0;
- if (enable) {
+ if (enabled) {
err = damon_sample_mtier_start();
if (err)
- enable = false;
+ enabled = false;
return err;
}
damon_sample_mtier_stop();
@@ -181,10 +181,10 @@ static int __init damon_sample_mtier_init(void)
int err = 0;
init_called = true;
- if (enable) {
+ if (enabled) {
err = damon_sample_mtier_start();
if (err)
- enable = false;
+ enabled = false;
}
return 0;
}
diff --git a/samples/damon/prcl.c b/samples/damon/prcl.c
index a9d7629d70f0a..223f13a5a4ad4 100644
--- a/samples/damon/prcl.c
+++ b/samples/damon/prcl.c
@@ -17,14 +17,14 @@ module_param(target_pid, int, 0600);
static int damon_sample_prcl_enable_store(
const char *val, const struct kernel_param *kp);
-static const struct kernel_param_ops enable_param_ops = {
+static const struct kernel_param_ops enabled_param_ops = {
.set = damon_sample_prcl_enable_store,
.get = param_get_bool,
};
-static bool enable __read_mostly;
-module_param_cb(enable, &enable_param_ops, &enable, 0600);
-MODULE_PARM_DESC(enable, "Enable of disable DAMON_SAMPLE_WSSE");
+static bool enabled __read_mostly;
+module_param_cb(enabled, &enabled_param_ops, &enabled, 0600);
+MODULE_PARM_DESC(enabled, "Enable or disable DAMON_SAMPLE_PRCL");
static struct damon_ctx *ctx;
static struct pid *target_pidp;
@@ -114,20 +114,20 @@ static bool init_called;
static int damon_sample_prcl_enable_store(
const char *val, const struct kernel_param *kp)
{
- bool enabled = enable;
+ bool is_enabled = enabled;
int err;
- err = kstrtobool(val, &enable);
+ err = kstrtobool(val, &enabled);
if (err)
return err;
- if (enable == enabled)
+ if (enabled == is_enabled)
return 0;
- if (enable) {
+ if (enabled) {
err = damon_sample_prcl_start();
if (err)
- enable = false;
+ enabled = false;
return err;
}
damon_sample_prcl_stop();
@@ -139,10 +139,10 @@ static int __init damon_sample_prcl_init(void)
int err = 0;
init_called = true;
- if (enable) {
+ if (enabled) {
err = damon_sample_prcl_start();
if (err)
- enable = false;
+ enabled = false;
}
return 0;
}
diff --git a/samples/damon/wsse.c b/samples/damon/wsse.c
index e941958b10324..d50730ee65a7e 100644
--- a/samples/damon/wsse.c
+++ b/samples/damon/wsse.c
@@ -18,14 +18,14 @@ module_param(target_pid, int, 0600);
static int damon_sample_wsse_enable_store(
const char *val, const struct kernel_param *kp);
-static const struct kernel_param_ops enable_param_ops = {
+static const struct kernel_param_ops enabled_param_ops = {
.set = damon_sample_wsse_enable_store,
.get = param_get_bool,
};
-static bool enable __read_mostly;
-module_param_cb(enable, &enable_param_ops, &enable, 0600);
-MODULE_PARM_DESC(enable, "Enable or disable DAMON_SAMPLE_WSSE");
+static bool enabled __read_mostly;
+module_param_cb(enabled, &enabled_param_ops, &enabled, 0600);
+MODULE_PARM_DESC(enabled, "Enable or disable DAMON_SAMPLE_WSSE");
static struct damon_ctx *ctx;
static struct pid *target_pidp;
@@ -94,20 +94,20 @@ static bool init_called;
static int damon_sample_wsse_enable_store(
const char *val, const struct kernel_param *kp)
{
- bool enabled = enable;
+ bool is_enabled = enabled;
int err;
- err = kstrtobool(val, &enable);
+ err = kstrtobool(val, &enabled);
if (err)
return err;
- if (enable == enabled)
+ if (enabled == is_enabled)
return 0;
- if (enable) {
+ if (enabled) {
err = damon_sample_wsse_start();
if (err)
- enable = false;
+ enabled = false;
return err;
}
damon_sample_wsse_stop();
@@ -119,10 +119,10 @@ static int __init damon_sample_wsse_init(void)
int err = 0;
init_called = true;
- if (enable) {
+ if (enabled) {
err = damon_sample_wsse_start();
if (err)
- enable = false;
+ enabled = false;
}
return err;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 6.16.y 3/3] samples/damon/mtier: avoid starting DAMON before initialization
2025-09-21 14:11 ` [PATCH 6.16.y 1/3] samples/damon/prcl: fix boot time enable crash Sasha Levin
2025-09-21 14:11 ` [PATCH 6.16.y 2/3] samples/damon: change enable parameters to enabled Sasha Levin
@ 2025-09-21 14:11 ` Sasha Levin
1 sibling, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-09-21 14:11 UTC (permalink / raw)
To: stable; +Cc: SeongJae Park, Andrew Morton, Sasha Levin
From: SeongJae Park <sj@kernel.org>
[ Upstream commit c62cff40481c037307a13becbda795f7afdcfebd ]
Commit 964314344eab ("samples/damon/mtier: support boot time enable
setup") is somehow incompletely applying the origin patch [1]. It is
missing the part that avoids starting DAMON before module initialization.
Probably a mistake during a merge has happened. Fix it by applying the
missed part again.
Link: https://lkml.kernel.org/r/20250909022238.2989-4-sj@kernel.org
Link: https://lore.kernel.org/20250706193207.39810-4-sj@kernel.org [1]
Fixes: 964314344eab ("samples/damon/mtier: support boot time enable setup")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
samples/damon/mtier.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c
index 11cbfea1af675..88156145172f1 100644
--- a/samples/damon/mtier.c
+++ b/samples/damon/mtier.c
@@ -166,6 +166,9 @@ static int damon_sample_mtier_enable_store(
if (enabled == is_enabled)
return 0;
+ if (!init_called)
+ return 0;
+
if (enabled) {
err = damon_sample_mtier_start();
if (err)
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-21 14:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-21 12:18 FAILED: patch "[PATCH] samples/damon/mtier: avoid starting DAMON before" failed to apply to 6.16-stable tree gregkh
2025-09-21 14:11 ` [PATCH 6.16.y 1/3] samples/damon/prcl: fix boot time enable crash Sasha Levin
2025-09-21 14:11 ` [PATCH 6.16.y 2/3] samples/damon: change enable parameters to enabled Sasha Levin
2025-09-21 14:11 ` [PATCH 6.16.y 3/3] samples/damon/mtier: avoid starting DAMON before initialization Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox