* [RFC PATCH] mm/damon/reclaim: allow disabling watermarks to force reclaim of cold pages
@ 2026-10-20 13:32 Jinjie Ruan
2026-10-20 13:58 ` SJ Park
2026-10-20 14:00 ` sashiko-bot
0 siblings, 2 replies; 4+ messages in thread
From: Jinjie Ruan @ 2026-10-20 13:32 UTC (permalink / raw)
To: sj, akpm, david, ljs, liam, vbabka, rppt, surenb, mhocko, corbet,
skhan, rdunlap, damon, linux-mm, linux-doc, linux-kernel
Cc: ruanjinjie
DAMON_RECLAIM runs its scheme only while the free memory rate is in
[wmarks_low, wmarks_mid]. Reclaiming cold pages raises the rate, so the
scheme self-stops as soon as memory looks plentiful again, which is wrong
for a VMM parking an idle sandbox that wants cold anonymous pages
reclaimed immediately.
So add an ignore_wmarks module parameter. When set, the scheme uses
DAMOS_WMARK_NONE, so damos_wmark_wait_us() always returns zero and the
scheme stays active, bounded only by min_age and the quota.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
.../admin-guide/mm/damon/reclaim.rst | 17 ++++++++++++++++
mm/damon/reclaim.c | 20 +++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/Documentation/admin-guide/mm/damon/reclaim.rst b/Documentation/admin-guide/mm/damon/reclaim.rst
index ec7e3e32b4ac..ef57f60a9105 100644
--- a/Documentation/admin-guide/mm/damon/reclaim.rst
+++ b/Documentation/admin-guide/mm/damon/reclaim.rst
@@ -159,6 +159,23 @@ this auto-tuning feature.
Disabled by default.
+ignore_wmarks
+-------------
+
+Ignore the watermarks-based scheme activation condition.
+
+If set to ``Y``, DAMON_RECLAIM runs its scheme regardless of the system's
+free memory rate, so the reclaim is bounded only by ``min_age`` and the
+quota. This is useful when cold pages should be reclaimed even while the
+system still has free memory, e.g. to squeeze the cold anonymous pages of a
+just-parked virtual machine out immediately.
+
+By default, ``N``, so the scheme is activated based on the system's free
+memory rate, as described for the watermarks below.
+
+Changes take effect when the scheme is rebuilt, i.e. on the next ``enabled``
+``0 -> 1`` transition, like the other DAMON_RECLAIM parameters.
+
wmarks_interval
---------------
diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
index 45d5557cc575..03b9a57694a6 100644
--- a/mm/damon/reclaim.c
+++ b/mm/damon/reclaim.c
@@ -112,6 +112,23 @@ static struct damos_watermarks damon_reclaim_wmarks = {
};
DEFINE_DAMON_MODULES_WMARKS_PARAMS(damon_reclaim_wmarks);
+/*
+ * Ignore the watermarks-based scheme activation condition.
+ *
+ * With the default ``N``, DAMON_RECLAIM runs its scheme only while the
+ * system's free memory rate is inside [wmarks_low, wmarks_mid].
+ * Reclaiming cold pages itself raises the free rate, so the scheme
+ * deactivates as soon as memory looks plentiful again. For a VMM parking
+ * an idle sandbox, cold anonymous pages should be reclaimed immediately
+ * even while the host still has plenty of free memory; setting this ``Y``
+ * makes the scheme ignore the watermarks, so the reclaim is bounded only
+ * by min_age and the quota.
+ */
+static bool ignore_wmarks __read_mostly;
+module_param(ignore_wmarks, bool, 0600);
+MODULE_PARM_DESC(ignore_wmarks,
+ "Ignore watermarks: reclaim cold pages even while free memory is plentiful (default: false)");
+
static struct damon_attrs damon_reclaim_mon_attrs = {
.sample_interval = 5000, /* 5 ms */
.aggr_interval = 100000, /* 100 ms */
@@ -226,6 +243,9 @@ static int damon_reclaim_apply_parameters(void)
if (err)
goto out;
+ damon_reclaim_wmarks.metric = ignore_wmarks ?
+ DAMOS_WMARK_NONE : DAMOS_WMARK_FREE_MEM_RATE;
+
err = -ENOMEM;
scheme = damon_reclaim_new_scheme(attrs.aggr_interval);
if (!scheme)
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] mm/damon/reclaim: allow disabling watermarks to force reclaim of cold pages
2026-10-20 13:32 [RFC PATCH] mm/damon/reclaim: allow disabling watermarks to force reclaim of cold pages Jinjie Ruan
@ 2026-10-20 13:58 ` SJ Park
2026-10-20 16:07 ` Aveline Noir
2026-10-20 14:00 ` sashiko-bot
1 sibling, 1 reply; 4+ messages in thread
From: SJ Park @ 2026-10-20 13:58 UTC (permalink / raw)
To: Jinjie Ruan
Cc: SJ Park, akpm, david, ljs, liam, vbabka, rppt, surenb, mhocko,
corbet, skhan, rdunlap, damon, linux-mm, linux-doc, linux-kernel
Hello Jinjie,
On Tue, 20 Oct 2026 21:32:33 +0800 Jinjie Ruan <ruanjinjie@huawei.com> wrote:
> DAMON_RECLAIM runs its scheme only while the free memory rate is in
> [wmarks_low, wmarks_mid]. Reclaiming cold pages raises the rate, so the
> scheme self-stops as soon as memory looks plentiful again, which is wrong
> for a VMM parking an idle sandbox that wants cold anonymous pages
> reclaimed immediately.
>
> So add an ignore_wmarks module parameter. When set, the scheme uses
> DAMOS_WMARK_NONE, so damos_wmark_wait_us() always returns zero and the
> scheme stays active, bounded only by min_age and the quota.
I agree there could be use cases that doesn't want the watermarks at all. I'd
like to avoid adding new DAMON_RECLAIM parameters if possible, though. That's
becasuse DAMON_RECLAIM is introduced to let people use it without complicated
setups. We will of course add new parameters if really needed, but I want to
see if there is a good alternative.
Have you considered some other alternatives? For example, could respectively
setting wmarks_high, wmarks_mid and wmarks_low to 100%, 100% and 0% effectively
disable watermarks? Have you tried that? If that works, how about updating
document to clearly explain the usage? Also, have you considered using DAMON
sysfs interface instead of DAMON_RECLAIM?
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] mm/damon/reclaim: allow disabling watermarks to force reclaim of cold pages
2026-10-20 13:32 [RFC PATCH] mm/damon/reclaim: allow disabling watermarks to force reclaim of cold pages Jinjie Ruan
2026-10-20 13:58 ` SJ Park
@ 2026-10-20 14:00 ` sashiko-bot
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-10-20 14:00 UTC (permalink / raw)
To: Jinjie Ruan, sj, akpm, david, ljs, liam, vbabka, rppt, surenb,
mhocko, corbet, skhan, rdunlap, damon, linux-mm
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] mm/damon/reclaim: missing kernel-parameters.txt entry for ignore_wmarks
- [Low] mm/damon/reclaim: inaccurate ignore_wmarks parameter apply documentation
--
commit 8e407c81e469d1e743666b3331a460c372ffea07
Author: Jinjie Ruan <ruanjinjie@huawei.com>
mm/damon/reclaim: allow disabling watermarks to force reclaim of cold pages
This commit adds the ignore_wmarks module parameter to DAMON_RECLAIM so
that the scheme can use DAMOS_WMARK_NONE and reclaim cold pages even when
free memory is plentiful.
> diff --git a/Documentation/admin-guide/mm/damon/reclaim.rst b/Documentation/admin-guide/mm/damon/reclaim.rst
> index ec7e3e32b4ac6..ef57f60a91059 100644
> --- a/Documentation/admin-guide/mm/damon/reclaim.rst
> +++ b/Documentation/admin-guide/mm/damon/reclaim.rst
> @@ -159,6 +159,23 @@ this auto-tuning feature.
>
> Disabled by default.
>
> +ignore_wmarks
> +-------------
> +
> +Ignore the watermarks-based scheme activation condition.
> +
> +If set to ``Y``, DAMON_RECLAIM runs its scheme regardless of the system's
> +free memory rate, so the reclaim is bounded only by ``min_age`` and the
> +quota. This is useful when cold pages should be reclaimed even while the
> +system still has free memory, e.g. to squeeze the cold anonymous pages of a
> +just-parked virtual machine out immediately.
> +
> +By default, ``N``, so the scheme is activated based on the system's free
> +memory rate, as described for the watermarks below.
> +
> +Changes take effect when the scheme is rebuilt, i.e. on the next ``enabled``
> +``0 -> 1`` transition, like the other DAMON_RECLAIM parameters.
[Severity: Low]
Is this description of when changes take effect accurate?
In mm/damon/reclaim.c, ignore_wmarks is applied in
damon_reclaim_apply_parameters() and committed via damon_commit_ctx().
Because damon_reclaim_commit_inputs_store() invokes
damon_reclaim_commit_inputs_fn() -> damon_reclaim_apply_parameters():
static int damon_reclaim_commit_inputs_fn(void *arg)
{
return damon_reclaim_apply_parameters();
}
writing Y to commit_inputs also applies ignore_wmarks changes online while
DAMON_RECLAIM is already running, without requiring an enabled 0 -> 1
transition.
Could the documentation note that changes can also be applied online via
commit_inputs?
> wmarks_interval
> ---------------
>
> diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
> index 014b0779ea6dd..effd963f3c783 100644
> --- a/mm/damon/reclaim.c
> +++ b/mm/damon/reclaim.c
> @@ -112,6 +112,23 @@ static struct damos_watermarks damon_reclaim_wmarks = {
> };
> DEFINE_DAMON_MODULES_WMARKS_PARAMS(damon_reclaim_wmarks);
>
> +/*
> + * Ignore the watermarks-based scheme activation condition.
> + *
> + * With the default ``N``, DAMON_RECLAIM runs its scheme only while the
> + * system's free memory rate is inside [wmarks_low, wmarks_mid].
> + * Reclaiming cold pages itself raises the free rate, so the scheme
> + * deactivates as soon as memory looks plentiful again. For a VMM parking
> + * an idle sandbox, cold anonymous pages should be reclaimed immediately
> + * even while the host still has plenty of free memory; setting this ``Y``
> + * makes the scheme ignore the watermarks, so the reclaim is bounded only
> + * by min_age and the quota.
> + */
> +static bool ignore_wmarks __read_mostly;
> +module_param(ignore_wmarks, bool, 0600);
> +MODULE_PARM_DESC(ignore_wmarks,
> + "Ignore watermarks: reclaim cold pages even while free memory is plentiful (default: false)");
[Severity: Low]
Since mm/damon/reclaim.c defines MODULE_PARAM_PREFIX as "damon_reclaim.",
registering ignore_wmarks via module_param() exposes
damon_reclaim.ignore_wmarks as a kernel command-line parameter at boot.
Should this patch also document damon_reclaim.ignore_wmarks in
Documentation/admin-guide/kernel-parameters.txt?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261020133233.3920818-1-ruanjinjie@huawei.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] mm/damon/reclaim: allow disabling watermarks to force reclaim of cold pages
2026-10-20 13:58 ` SJ Park
@ 2026-10-20 16:07 ` Aveline Noir
0 siblings, 0 replies; 4+ messages in thread
From: Aveline Noir @ 2026-10-20 16:07 UTC (permalink / raw)
To: SJ Park, Jinjie Ruan
Cc: akpm, david, ljs, liam, vbabka, rppt, surenb, mhocko, corbet,
skhan, rdunlap, damon, linux-mm, linux-doc, linux-kernel
Hi SJ,
> setting wmarks_high, wmarks_mid and wmarks_low to 100%, 100% and 0%
> effectively disable watermarks? Have you tried that?
That worked in my test with swap enabled. Agree that documenting this
combination might be useful.
Thanks,
Aveline Noir
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-20 16:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20 13:32 [RFC PATCH] mm/damon/reclaim: allow disabling watermarks to force reclaim of cold pages Jinjie Ruan
2026-10-20 13:58 ` SJ Park
2026-10-20 16:07 ` Aveline Noir
2026-10-20 14:00 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox