Re: [PATCH v1 1/2] mm/vmscan: balance demotion allocation in alloc_demote_folio()
From: Donet Tom
Date: Thu Jan 08 2026 - 10:49:08 EST
On 1/7/26 12:58 PM, Bing Jiao wrote:
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@xxxxxxxxxx>
---
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);
This random selection can cause allocations to fall back to distant memory even when the nearer demotion target has sufficient free memory, correct? Could this also lead to increased promotion latency?
+ node_clear(mtc->nid, *allowed_mask);
+ }
mtc->gfp_mask &= ~__GFP_THISNODE;
mtc->nmask = allowed_mask;
--
2.52.0.358.g0dd7633a29-goog