Skip to contentSkip to conversation

mm/mempolicy: ignore a bind policy whose nodes have no memory

PATCH Applied Gregory Price (Meta) 5 participants 7 messages Nov 13 – Nov 14

Subsystems (2)
lore
Share & tools
lore

Gregory Price (Meta)

author maintainer
#0 lore raw

PATCH 1/1 mm/mempolicy: ignore a bind policy whose nodes have no memory

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.

---
 mm/mempolicy.c | 4 ++++
 1 file changed, 4 insertions(+)
mm/mempolicy.c +4 -0
index ca7e744727b1..5dc2d7ef1544 100644
@@ -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.
Signature · 1 line
2.56.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Gregory Price (Meta)

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

Quoted 8 lines

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?

Quoted 6 lines
---
 mm/mempolicy.c | 4 ++++
 1 file changed, 4 insertions(+)

LGTM.

Best Regards,
Yan, Zi

author maintainer
#2 lore raw
Quoted 20 lines · Zi Yan
Quoted 18 lines · Gregory Price (Meta)

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.

Quoted 7 lines
Quoted 4 lines

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.

Signature · 1 line
~Gregory
reviewer
#3 lore raw
Quoted 26 lines · Gregory Price (Meta)
Quoted 25 lines · Zi Yan
Quoted 22 lines · Gregory Price (Meta)

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.

Quoted 6 lines
Quoted 2 lines

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

reviewer Reviewed-by on v1 1/1
#4 lore raw
In reply to Gregory Price (Meta)
Quoted 18 lines · Gregory Price (Meta)

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.

Quoted 6 lines

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.

Hello Gregory,

Cool find! Thanks for fixing this.

Quoted 22 lines
---
 mm/mempolicy.c | 4 ++++
 1 file changed, 4 insertions(+)
mm/mempolicy.c +4 -0
index ca7e744727b1..5dc2d7ef1544 100644
@@ -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.
Signature · 1 line
2.56.0
Reviewed-by on v1 1/1
#5 lore raw
In reply to Gregory Price (Meta)
Quoted 14 lines · On Fri, 13 Nov 2026 14:26:42 -0500 "Gregory Price (Meta)" <[email protected]>…

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

Quoted 8 lines

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.

Quoted 2 lines

Thanks,
SJ

[...]

maintainer Applied
#6 lore raw
In reply to Gregory Price (Meta)
Quoted 9 lines · Gregory Price (Meta)

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
Signature · 3 lines
Cheers,

David