Re: [PATCH] mm/vmscan: respect mems_effective in demote_folio_list()
From: Andrew Morton
Date: Sat Dec 20 2025 - 14:20:45 EST
On Sat, 20 Dec 2025 06:10:21 +0000 Bing Jiao <bingjiao@xxxxxxxxxx> wrote:
> Commit 7d709f49babc ("vmscan,cgroup: apply mems_effective to reclaim")
> introduces the cpuset.mems_effective check and applies it to
> can_demote().
So we'll want
Fixes: 7d709f49babc ("vmscan,cgroup: apply mems_effective to reclaim")
in the changelog.
> However, it does not apply this check in
> demote_folio_list(), which leads to situations where pages are demoted
> to nodes that are explicitly excluded from the task's cpuset.mems.
>
> To address the issue that demotion targets do not respect
> cpuset.mem_effective in demote_folio_list(), implement a new function
> get_demotion_targets(), which returns a preferred demotion target
> and all allowed (fallback) nodes against mems_effective,
> and update demote_folio_list() and can_demote() accordingly to
> use get_demotion_targets().
7d709f49babc fist appeared in 6.16, so we must decide whether to
backport this fix into -stable kernels, via a Cc:
<stable@xxxxxxxxxxxxxxx>.
To make this decision it's best to have a clear understanding of the
userspace visible impact of the bug. Putting pages into improper nodes
is undesirable, but how much does it affect real-world workloads?
Please include in the changelog some words about this to help others
understand why we should backport the fix.
> Furthermore, update some supporting functions:
> - Add a parameter for next_demotion_node() to return a copy of
> node_demotion[]->preferred, allowing get_demotion_targets()
> to select the next-best node for demotion.
> - Change the parameters for cpuset_node_allowed() and
> mem_cgroup_node_allowed() from nid to nodemask * to allow
> for direct logic-and operations with mems_effective.
If we do decide to backport the fix into earlier kernels then it's best
to keep the patch as small and as simple as possible. So non-bugfix
changes such as these are best made via a second followup patch which
can be merged via the normal -rc staging process.