Re: [PATCH 1/2] mm/mempolicy: use SRCU for the weighted interleave state

From: David Hildenbrand (Arm)

Date: Wed Sep 16 2026 - 12:43:20 EST


On 8/29/26 03:59, Gregory Price wrote:
> alloc_pages_bulk_weighted_interleave() copies iw_table into a scratch
> array on every call so it can walk the weights outside of RCU. The copy
> exists only because the loop may sleep in the page allocator and so cannot
> hold rcu_read_lock().
>
> Use SRCU to pin the global iw_table object and use it in-place instead.
>
> Retire through both flavors - call_srcu() for the sleeping readers, then
> kfree_rcu() for the reference-less ones - so writers no longer block on
> synchronize_rcu() either.
>
> Tested in a VM with KASAN, PROVE_LOCKING and DEBUG_OBJECTS_RCU_HEAD,
> with a udelay() injected into the read section to widen the race against
> concurrent sysfs weight writers, and placement checked against the
> configured weights.
>
> Every retired state reached its callback. Swapping the deferred free for
> a bare kfree() in the same test reports a use-after-free immediately.
>
> Suggested-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Suggested-by: Matthew Wilcox <willy@xxxxxxxxxxxxx>
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
> ---

LGTM

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David