[PATCH v7 0/2] mm/vmscan: fix demotion targets checks in reclaim/demotion

From: Bing Jiao

Date: Wed Jan 07 2026 - 22:35:10 EST


Hi Andrew,

I am sorry for issuing a new patch version after v6 has been merged into
mm-hotfixes-unstable.

Main updates in v7:

1. Fixed a bug in v6.

Specifically, next_demotion_node() may return NUMA_NO_NODE if nodes
were hot-unplugged. V6 directly checks
node_isset(target_nid, allowed_mask), which will cause out-of-boundary
bug if target_nid is NUMA_NO_NODE (-1).

2. Preferred node selection.

[Patch 1/2] originally implemented a random selection from
allowed nodes if the preferred node from next_demotion_node()
was missing from mems_allowed. This behavior contradicts the
purpose of migration_target_control.nid, which is intended to
identify the preferred node nearest to the source.

To resolve this inconsistency, incorporat the preferred node
selection patch into this series.


If there is a consensus among reviewers to backport Patch 2/2
alongside Patch 1/2, they can be combined.
Otherwise, I will post Patch 2/2 in another series.

Many thanks!

Best regards,
Bing

Bing Jiao (2):
mm/vmscan: fix demotion targets checks in reclaim/demotion
mm/vmscan: select the closest preferred node in demote_folio_list()

include/linux/cpuset.h | 6 ++--
include/linux/memcontrol.h | 6 ++--
include/linux/memory-tiers.h | 6 ++--
kernel/cgroup/cpuset.c | 54 ++++++++++++++++++++++++------------
mm/memcontrol.c | 16 +++++++++--
mm/memory-tiers.c | 11 +++++---
mm/vmscan.c | 49 +++++++++++++++++++++++++-------
7 files changed, 105 insertions(+), 43 deletions(-)

--
2.52.0.457.g6b5491de43-goog