* + mm-mempolicy-use-one-node-set-for-interleave-weights.patch added to mm-hotfixes-unstable branch
@ 2026-10-30 16:19 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-30 16:19 UTC (permalink / raw)
To: mm-commits, ziy, ying.huang, stable, rakie.kim, joshua.hahnjy,
harry, gourry, david, akpm
The patch titled
Subject: mm/mempolicy: use one node set for interleave weights
has been added to the -mm mm-hotfixes-unstable branch. Its filename is
mm-mempolicy-use-one-node-set-for-interleave-weights.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-mempolicy-use-one-node-set-for-interleave-weights.patch
This patch will later appear in the mm-hotfixes-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Andrew Morton <akpm@linux-foundation.org>
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.
Link: https://lore.kernel.org/20261030161046.1497894-1-gourry@gourry.net
Fixes: e341f9c3c841 ("mm/mempolicy: Weighted Interleave Auto-tuning")
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Cc: David Hildenbrand <david@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Ying Huang <ying.huang@linux.alibaba.com>
Cc: Harry Yoo <harry@kernel.org>
Cc: <stable@vger.kernel.org>
---
mm/mempolicy.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
--- a/mm/mempolicy.c~mm-mempolicy-use-one-node-set-for-interleave-weights
+++ a/mm/mempolicy.c
@@ -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 akpm@linux-foundation.org are
openrisc-export-mulsi3.patch
mm-mempolicy-use-one-node-set-for-interleave-weights.patch
maintainers-add-ipc-maintainers.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
drivers-media-v4l2-core-v4l2-vp9c-reduce-inlining.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-30 16:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 16:19 + mm-mempolicy-use-one-node-set-for-interleave-weights.patch added to mm-hotfixes-unstable branch Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox