Skip to contentSkip to conversation

mm-mempolicy-use-one-node-set-for-interleave-weights.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Nov 10 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/mempolicy: use one node set for interleave weights
has been removed from the -mm tree. Its filename was
mm-mempolicy-use-one-node-set-for-interleave-weights.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: mm/mempolicy: use one node set for interleave weights
Date: Fri, 30 Oct 2026 12:10:46 -0400

Switching weighted interleave back to automatic mode while memory is being onlined can cause a kernel divide error on x86, and a panic if panic_on_oops is set.

reduce_interleave_weights() scans N_MEMORY three times, but hotplug can cause N_MEMORY to change at runtime - and torn reads on that nodemask can cause a total sum of zero bandwidth. A node that was hot-unplugged and then hotplugged back can then cause this loop to generate a div/0.

Record the nodes visited while summing their bandwidth, then use that same set when scaling and reducing the weights. This gives us a consistent state even if N_MEMORY changes.

Fixes e341f9c3c841 ("mm/mempolicy: Weighted Interleave Auto-tuning")
Cc David Hildenbrand <[email protected]>
Cc Zi Yan <[email protected]>
Cc Rakie Kim <[email protected]>
Cc Ying Huang <[email protected]>
Cc Harry Yoo <[email protected]>

---

 mm/mempolicy.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
mm/mempolicy.c renamed from mm/mempolicy.c~mm-mempolicy-use-one-node-set-for-interleave-weights +10 -3
@@ -207,15 +207,22 @@ static u8 get_il_weight(int node)
  */
 static void reduce_interleave_weights(unsigned int *bw, u8 *new_iw)
 {
+	nodemask_t nodes = NODE_MASK_NONE;
 	u64 sum_bw = 0;
 	unsigned int cast_sum_bw, scaling_factor = 1, iw_gcd = 0;
 	int nid;
 
-	for_each_node_state(nid, N_MEMORY)
+	/*
+	 * N_MEMORY can change while wi_state_lock is held. Remember the
+	 * nodes contributing to sum_bw so all passes use the same set.
+	 */
+	for_each_node_state(nid, N_MEMORY) {
+		node_set(nid, nodes);
 		sum_bw += bw[nid];
+	}
 
 	/* Scale bandwidths to whole numbers in the range [1, weightiness] */
-	for_each_node_state(nid, N_MEMORY) {
+	for_each_node_mask(nid, nodes) {
 		/*
 		 * Try not to perform 64-bit division.
 		 * If sum_bw < scaling_factor, then sum_bw < U32_MAX.
@@ -234,7 +241,7 @@ static void reduce_interleave_weights(un
 	}
 
 	/* 1:2 is strictly better than 16:32. Reduce by the weights' GCD. */
-	for_each_node_state(nid, N_MEMORY)
+	for_each_node_mask(nid, nodes)
 		new_iw[nid] /= iw_gcd;
 }
 

_

Patches currently in -mm which might be from [email protected] are

shmem-consume-the-reserved-xattr-space-despite-remount.patch selftests-mm-check-madv_cold-and-madv_pageout-on-partly-advised-thps-fix.patch alloc_tag-introduce-ioctls-to-toggle-allocation-tracepoints-fix-fix.patch alloc_tag-introduce-ioctls-to-toggle-allocation-tracepoints-fix.patch mm-migrate_device-allocate-deferred-split-sublists-for-new-huge-folios.patch profile-account-for-partial-proc-profile-reads.patch profile-simplify-proc-profile-read-layout.patch ipc-msg-clamp-negative-msg_info-usage-counts.patch squashfs-fix-leaked-page-locks-when-page-actor-allocation-fails-fix.patch drivers-media-v4l2-core-v4l2-vp9c-reduce-inlining.patch