* [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory
@ 2026-11-13 19:26 Gregory Price (Meta)
2026-11-13 19:47 ` Zi Yan
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Gregory Price (Meta) @ 2026-11-13 19:26 UTC (permalink / raw)
To: linux-mm
Cc: linux-kernel, kernel-team, akpm, david, gourry, ziy,
joshua.hahnjy, rakie.kim, ying.huang
apply_policy_zone() assumes that policy->nodes intersects N_MEMORY, so
it reads a bind policy with no N_HIGH_MEMORY node as movable-only.
On systems with CONFIG_CPUSETS=n, nothing rebinds policies when memory
is removed, so offlining all memory on the nodes a bind policy names
leaves it with none. The policy is then treated as movable-only, and
movable allocations are restricted to nodes without memory.
This results in allocations failures, a VM_FAULT_OOM leak, and then
an infinitely retrying fault that hangs the process.
page allocation failure: order:0, mode:0x140dca ... nodemask=2
Huh VM_FAULT_OOM leaked out to the #PF handler. Retrying PF
Ignore a bind policy whose nodes have no memory. policy_nodemask()
already ignores a bind policy that does not intersect the cpuset.
This covers hugetlb's policy_mbind_nodemask() as well.
If the nodes regain memory, the policy applies again.
CPUSETS=n with HOTREMOVE=y is unlikely a common configuration, so this
isn't marked for stable.
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
---
mm/mempolicy.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index ca7e744727b1..5dc2d7ef1544 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2096,6 +2096,10 @@ bool apply_policy_zone(struct mempolicy *policy, enum zone_type zone)
BUG_ON(dynamic_policy_zone == ZONE_MOVABLE);
+ /* Memory hot-remove can leave policy->nodes without memory. */
+ if (!nodes_intersects(policy->nodes, node_states[N_MEMORY]))
+ return false;
+
/*
* if policy->nodes has movable memory only,
* we apply policy when gfp_zone(gfp) = ZONE_MOVABLE only.
--
2.56.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory
2026-11-13 19:26 [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory Gregory Price (Meta)
@ 2026-11-13 19:47 ` Zi Yan
2026-11-13 20:14 ` Gregory Price (Meta)
2026-11-14 0:03 ` Joshua Hahn
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Zi Yan @ 2026-11-13 19:47 UTC (permalink / raw)
To: Gregory Price (Meta)
Cc: linux-mm, linux-kernel, kernel-team, akpm, david, joshua.hahnjy,
rakie.kim, ying.huang
On 13 Nov 2026, at 14:26, Gregory Price (Meta) wrote:
> apply_policy_zone() assumes that policy->nodes intersects N_MEMORY, so
> it reads a bind policy with no N_HIGH_MEMORY node as movable-only.
>
> On systems with CONFIG_CPUSETS=n, nothing rebinds policies when memory
> is removed, so offlining all memory on the nodes a bind policy names
> leaves it with none. The policy is then treated as movable-only, and
> movable allocations are restricted to nodes without memory.
>
> This results in allocations failures, a VM_FAULT_OOM leak, and then
> an infinitely retrying fault that hangs the process.
>
> page allocation failure: order:0, mode:0x140dca ... nodemask=2
> Huh VM_FAULT_OOM leaked out to the #PF handler. Retrying PF
>
> Ignore a bind policy whose nodes have no memory. policy_nodemask()
> already ignores a bind policy that does not intersect the cpuset.
> This covers hugetlb's policy_mbind_nodemask() as well.
>
> If the nodes regain memory, the policy applies again.
>
> CPUSETS=n with HOTREMOVE=y is unlikely a common configuration, so this
> isn't marked for stable.
Also no Fixes?
>
> Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
> ---
> mm/mempolicy.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
LGTM.
Reviewed-by: Zi Yan <ziy@nvidia.com>
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory
2026-11-13 19:47 ` Zi Yan
@ 2026-11-13 20:14 ` Gregory Price (Meta)
2026-11-13 20:16 ` Zi Yan
0 siblings, 1 reply; 7+ messages in thread
From: Gregory Price (Meta) @ 2026-11-13 20:14 UTC (permalink / raw)
To: Zi Yan
Cc: Gregory Price (Meta),
linux-mm, linux-kernel, kernel-team, akpm, david, joshua.hahnjy,
rakie.kim, ying.huang
On 2026-11-13 14:47 -0500, Zi Yan wrote:
> On 13 Nov 2026, at 14:26, Gregory Price (Meta) wrote:
>
> > apply_policy_zone() assumes that policy->nodes intersects N_MEMORY, so
> > it reads a bind policy with no N_HIGH_MEMORY node as movable-only.
> >
> > On systems with CONFIG_CPUSETS=n, nothing rebinds policies when memory
> > is removed, so offlining all memory on the nodes a bind policy names
> > leaves it with none. The policy is then treated as movable-only, and
> > movable allocations are restricted to nodes without memory.
> >
> > This results in allocations failures, a VM_FAULT_OOM leak, and then
> > an infinitely retrying fault that hangs the process.
> >
> > page allocation failure: order:0, mode:0x140dca ... nodemask=2
> > Huh VM_FAULT_OOM leaked out to the #PF handler. Retrying PF
> >
> > Ignore a bind policy whose nodes have no memory. policy_nodemask()
> > already ignores a bind policy that does not intersect the cpuset.
> > This covers hugetlb's policy_mbind_nodemask() as well.
> >
> > If the nodes regain memory, the policy applies again.
> >
> > CPUSETS=n with HOTREMOVE=y is unlikely a common configuration, so this
> > isn't marked for stable.
>
> Also no Fixes?
>
It wasn't quite obvious what to tag exactly. Since I don't think it's
worth backporting, wasn't sure I should bother spending time on the
Fixes tag.
--
~Gregory
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory
2026-11-13 20:14 ` Gregory Price (Meta)
@ 2026-11-13 20:16 ` Zi Yan
0 siblings, 0 replies; 7+ messages in thread
From: Zi Yan @ 2026-11-13 20:16 UTC (permalink / raw)
To: Gregory Price (Meta)
Cc: linux-mm, linux-kernel, kernel-team, akpm, david, joshua.hahnjy,
rakie.kim, ying.huang
On 13 Nov 2026, at 15:14, Gregory Price (Meta) wrote:
> On 2026-11-13 14:47 -0500, Zi Yan wrote:
>> On 13 Nov 2026, at 14:26, Gregory Price (Meta) wrote:
>>
>>> apply_policy_zone() assumes that policy->nodes intersects N_MEMORY, so
>>> it reads a bind policy with no N_HIGH_MEMORY node as movable-only.
>>>
>>> On systems with CONFIG_CPUSETS=n, nothing rebinds policies when memory
>>> is removed, so offlining all memory on the nodes a bind policy names
>>> leaves it with none. The policy is then treated as movable-only, and
>>> movable allocations are restricted to nodes without memory.
>>>
>>> This results in allocations failures, a VM_FAULT_OOM leak, and then
>>> an infinitely retrying fault that hangs the process.
>>>
>>> page allocation failure: order:0, mode:0x140dca ... nodemask=2
>>> Huh VM_FAULT_OOM leaked out to the #PF handler. Retrying PF
>>>
>>> Ignore a bind policy whose nodes have no memory. policy_nodemask()
>>> already ignores a bind policy that does not intersect the cpuset.
>>> This covers hugetlb's policy_mbind_nodemask() as well.
>>>
>>> If the nodes regain memory, the policy applies again.
>>>
>>> CPUSETS=n with HOTREMOVE=y is unlikely a common configuration, so this
>>> isn't marked for stable.
>>
>> Also no Fixes?
>>
>
> It wasn't quite obvious what to tag exactly. Since I don't think it's
> worth backporting, wasn't sure I should bother spending time on the
> Fixes tag.
I can imagine that. We probably can blame mbind or hotremove, but the
commit might be too old to be meaningful. It is all good now.
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory
2026-11-13 19:26 [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory Gregory Price (Meta)
2026-11-13 19:47 ` Zi Yan
@ 2026-11-14 0:03 ` Joshua Hahn
2026-11-14 1:14 ` SJ Park
2026-11-14 15:02 ` David Hildenbrand
3 siblings, 0 replies; 7+ messages in thread
From: Joshua Hahn @ 2026-11-14 0:03 UTC (permalink / raw)
To: Gregory Price (Meta)
Cc: linux-mm, linux-kernel, kernel-team, akpm, david, ziy, rakie.kim,
ying.huang
On Fri, Nov 13, 2026 at 02:26:42PM -0500, Gregory Price (Meta) wrote:
> apply_policy_zone() assumes that policy->nodes intersects N_MEMORY, so
> it reads a bind policy with no N_HIGH_MEMORY node as movable-only.
>
> On systems with CONFIG_CPUSETS=n, nothing rebinds policies when memory
> is removed, so offlining all memory on the nodes a bind policy names
> leaves it with none. The policy is then treated as movable-only, and
> movable allocations are restricted to nodes without memory.
>
> This results in allocations failures, a VM_FAULT_OOM leak, and then
> an infinitely retrying fault that hangs the process.
>
> page allocation failure: order:0, mode:0x140dca ... nodemask=2
> Huh VM_FAULT_OOM leaked out to the #PF handler. Retrying PF
>
> Ignore a bind policy whose nodes have no memory. policy_nodemask()
> already ignores a bind policy that does not intersect the cpuset.
> This covers hugetlb's policy_mbind_nodemask() as well.
>
> If the nodes regain memory, the policy applies again.
>
> CPUSETS=n with HOTREMOVE=y is unlikely a common configuration, so this
> isn't marked for stable.
>
> Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Hello Gregory,
Cool find! Thanks for fixing this.
Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>
> ---
> mm/mempolicy.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index ca7e744727b1..5dc2d7ef1544 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -2096,6 +2096,10 @@ bool apply_policy_zone(struct mempolicy *policy, enum zone_type zone)
>
> BUG_ON(dynamic_policy_zone == ZONE_MOVABLE);
>
> + /* Memory hot-remove can leave policy->nodes without memory. */
> + if (!nodes_intersects(policy->nodes, node_states[N_MEMORY]))
> + return false;
> +
> /*
> * if policy->nodes has movable memory only,
> * we apply policy when gfp_zone(gfp) = ZONE_MOVABLE only.
> --
> 2.56.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory
2026-11-13 19:26 [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory Gregory Price (Meta)
2026-11-13 19:47 ` Zi Yan
2026-11-14 0:03 ` Joshua Hahn
@ 2026-11-14 1:14 ` SJ Park
2026-11-14 15:02 ` David Hildenbrand
3 siblings, 0 replies; 7+ messages in thread
From: SJ Park @ 2026-11-14 1:14 UTC (permalink / raw)
To: Gregory Price (Meta)
Cc: SJ Park, linux-mm, linux-kernel, kernel-team, akpm, david, ziy,
joshua.hahnjy, rakie.kim, ying.huang
On Fri, 13 Nov 2026 14:26:42 -0500 "Gregory Price (Meta)" <gourry@gourry.net> wrote:
> apply_policy_zone() assumes that policy->nodes intersects N_MEMORY, so
> it reads a bind policy with no N_HIGH_MEMORY node as movable-only.
>
> On systems with CONFIG_CPUSETS=n, nothing rebinds policies when memory
> is removed, so offlining all memory on the nodes a bind policy names
> leaves it with none. The policy is then treated as movable-only, and
> movable allocations are restricted to nodes without memory.
>
> This results in allocations failures, a VM_FAULT_OOM leak, and then
> an infinitely retrying fault that hangs the process.
>
> page allocation failure: order:0, mode:0x140dca ... nodemask=2
> Huh VM_FAULT_OOM leaked out to the #PF handler. Retrying PF
>
> Ignore a bind policy whose nodes have no memory. policy_nodemask()
> already ignores a bind policy that does not intersect the cpuset.
> This covers hugetlb's policy_mbind_nodemask() as well.
>
> If the nodes regain memory, the policy applies again.
>
> CPUSETS=n with HOTREMOVE=y is unlikely a common configuration, so this
> isn't marked for stable.
Makes sense and looks good to me.
>
> Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: SJ Park <sj@kernel.org>
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory
2026-11-13 19:26 [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory Gregory Price (Meta)
` (2 preceding siblings ...)
2026-11-14 1:14 ` SJ Park
@ 2026-11-14 15:02 ` David Hildenbrand
3 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2026-11-14 15:02 UTC (permalink / raw)
To: linux-mm, Gregory Price (Meta)
Cc: linux-kernel, kernel-team, akpm, david, ziy, joshua.hahnjy,
rakie.kim, ying.huang
On Fri, 13 Nov 2026 14:26:42 -0500, Gregory Price (Meta) wrote:
> apply_policy_zone() assumes that policy->nodes intersects N_MEMORY, so
> it reads a bind policy with no N_HIGH_MEMORY node as movable-only.
>
> On systems with CONFIG_CPUSETS=n, nothing rebinds policies when memory
> is removed, so offlining all memory on the nodes a bind policy names
> leaves it with none. The policy is then treated as movable-only, and
> movable allocations are restricted to nodes without memory.
>
> [...]
Applied, thanks!
tree: mm/core.git
branch: mempolicy-7.5.misc
Applied patches will appear soon in mm-next, followed by linux-next.
Please report any outstanding bugs that were missed during review, so we
can either drop the patch series or decide how to fix it up.
It is encouraged to provide Acked-bys, Reviewed-bys, and Tested-bys even
though the patches have already been applied. If possible, patch trailers
will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. Further, this is not a guarantee that the
patches will go upstream. If in doubt, please check the listed branch.
[1/1] mm/mempolicy: ignore a bind policy whose nodes have no memory
https://git.kernel.org/mm/core/c/528dc8e1
--
Cheers,
David
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-14 15:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 19:26 [PATCH] mm/mempolicy: ignore a bind policy whose nodes have no memory Gregory Price (Meta)
2026-11-13 19:47 ` Zi Yan
2026-11-13 20:14 ` Gregory Price (Meta)
2026-11-13 20:16 ` Zi Yan
2026-11-14 0:03 ` Joshua Hahn
2026-11-14 1:14 ` SJ Park
2026-11-14 15:02 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®