[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260107072814.2324646-2-bingjiao@google.com>
Date: Wed, 7 Jan 2026 07:28:13 +0000
From: Bing Jiao <bingjiao@...gle.com>
To: linux-mm@...ck.org
Cc: Bing Jiao <bingjiao@...gle.com>, Andrew Morton <akpm@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>, David Hildenbrand <david@...nel.org>, Michal Hocko <mhocko@...nel.org>,
Qi Zheng <zhengqi.arch@...edance.com>, Shakeel Butt <shakeel.butt@...ux.dev>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, Axel Rasmussen <axelrasmussen@...gle.com>,
Yuanchu Xie <yuanchu@...gle.com>, Wei Xu <weixugc@...gle.com>, linux-kernel@...r.kernel.org
Subject: [PATCH v1 1/2] mm/vmscan: balance demotion allocation in alloc_demote_folio()
When the preferred demotion node does not have enough free space,
alloc_demote_folio() attempts to allocate from fallback nodes.
Currently, it lacks a mechanism to distribute these fallback allocations,
which can lead to unbalanced memory pressure across fallback nodes.
Balance the allocation by randomly selecting a new preferred node from
the fallback nodes if the initial allocation from the old preferred
node fails.
Signed-off-by: Bing Jiao <bingjiao@...gle.com>
---
mm/vmscan.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 81828fa625ed..db2413c4bd26 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1009,6 +1009,11 @@ static struct folio *alloc_demote_folio(struct folio *src,
if (dst)
return dst;
+ /* Randomly select a node from fallback nodes for balanced allocation */
+ if (allowed_mask) {
+ mtc->nid = node_random(allowed_mask);
+ node_clear(mtc->nid, *allowed_mask);
+ }
mtc->gfp_mask &= ~__GFP_THISNODE;
mtc->nmask = allowed_mask;
--
2.52.0.358.g0dd7633a29-goog
Powered by blists - more mailing lists