Re: [PATCH] mm/mempolicy: use one node set for interleave weights

From: Joshua Hahn

Date: Fri Oct 30 2026 - 12:37:40 EST


On Fri, Oct 30, 2026 at 12:12 PM Gregory Price (Meta) <gourry@xxxxxxxxxx> wrote:
>
> From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
>
> From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
>
> 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.

Makes a lot of sense to me. Thanks for the fix!
Reviewed-by: Joshua Hahn <joshua.hahnjy@xxxxxxxxx>

> Fixes: e341f9c3c841 ("mm/mempolicy: Weighted Interleave Auto-tuning")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>