[PATCH 3/3] mm/vmscan: add demote= option to proactive reclaim
From: Bing Jiao
Date: Tue Mar 17 2026 - 19:15:39 EST
In tiered-memory systems, proactive memory reclaim (via the cgroup
memory.reclaim interface) can demote pages to a lower memory tier
before eventually reclaiming them to swap.
Add a 'demote=%u' option to memory.reclaim to allow users to control
this behavior. Setting 'demote=1' enables demotion, while 'demote=0'
disables it. By default, demote is disabled (0).
This change ensures that proactive reclaim behaves consistently with
cgroup limit-based reclaim (e.g., memory.high), where the goal is
typically to reduce the overall memory footprint rather than migrating
it to slower tiers.
Signed-off-by: Bing Jiao <bingjiao@xxxxxxxxxx>
---
mm/vmscan.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 7a8617ba1748..80194270fa2e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -7878,11 +7878,13 @@ static unsigned long __node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask,
enum {
MEMORY_RECLAIM_SWAPPINESS = 0,
MEMORY_RECLAIM_SWAPPINESS_MAX,
+ MEMORY_RECLAIM_ALLOW_DEMOTION,
MEMORY_RECLAIM_NULL,
};
static const match_table_t tokens = {
{ MEMORY_RECLAIM_SWAPPINESS, "swappiness=%d"},
{ MEMORY_RECLAIM_SWAPPINESS_MAX, "swappiness=max"},
+ { MEMORY_RECLAIM_ALLOW_DEMOTION, "demote=%u"},
{ MEMORY_RECLAIM_NULL, NULL },
};
@@ -7890,6 +7892,7 @@ int user_proactive_reclaim(char *buf,
struct mem_cgroup *memcg, pg_data_t *pgdat)
{
unsigned int nr_retries = MAX_RECLAIM_RETRIES;
+ unsigned int allow_demotion = 0;
unsigned long nr_to_reclaim, nr_reclaimed = 0;
int swappiness = -1;
char *old_buf, *start;
@@ -7922,6 +7925,10 @@ int user_proactive_reclaim(char *buf,
case MEMORY_RECLAIM_SWAPPINESS_MAX:
swappiness = SWAPPINESS_ANON_ONLY;
break;
+ case MEMORY_RECLAIM_ALLOW_DEMOTION:
+ if (match_uint(&args[0], &allow_demotion))
+ return -EINVAL;
+ break;
default:
return -EINVAL;
}
@@ -7947,6 +7954,8 @@ int user_proactive_reclaim(char *buf,
reclaim_options = MEMCG_RECLAIM_MAY_SWAP |
MEMCG_RECLAIM_PROACTIVE;
+ if (!allow_demotion)
+ reclaim_options |= MEMCG_RECLAIM_NO_DEMOTION;
reclaimed = try_to_free_mem_cgroup_pages(memcg,
batch_size, gfp_mask,
reclaim_options,
@@ -7962,6 +7971,7 @@ int user_proactive_reclaim(char *buf,
.may_unmap = 1,
.may_swap = 1,
.proactive = 1,
+ .no_demotion = !(allow_demotion),
};
if (test_and_set_bit_lock(PGDAT_RECLAIM_LOCKED,
--
2.53.0.851.ga537e3e6e9-goog