Re: [PATCH v3] mm/slub: prevent pfmemalloc objects from entering the barn

From: hu.shengming

Date: Tue Jul 21 2026 - 05:12:23 EST


Vlastimil wrote:
> On 7/21/26 09:34, Vlastimil Babka (SUSE) wrote:
> > On 7/21/26 02:45, hu.shengming@xxxxxxxxxx wrote:
> >> From: Shengming Hu <hu.shengming@xxxxxxxxxx>
> >>
> >> kmem_cache_return_sheaf() may refill a partially consumed sheaf before
> >> placing it in the barn. Without an explicit restriction, this refill may
> >> draw objects from pfmemalloc slabs and consume emergency reserves.
> >>
> >> Add __GFP_NOMEMALLOC so that returned sheaves are refilled only from
> >> non-pfmemalloc slabs. Also add __GFP_NOWARN, as suggested by Hao Li,
> >> because this refill is a best-effort attempt and failure is acceptable..
> >> If the refill fails, flush and free the sheaf instead.
> >>
> >> Fixes: 3c1ea5c5019f ("slab: sheaf prefilling for guaranteed allocations")
> >
> > Wonder if 1ce20c28eafd ("slab: handle pfmemalloc slabs properly with
> > sheaves") is a better match. Until that commit we just didn't care, and it
> > seems like this is a case that commit missed?

Agreed, 1ce20c28eafd is a better match. Thanks for catching this.

> Added to slab/for-next with changed Fixes: per above, but can adjust it
> further if it was wrong. Thanks!
>

Thanks!

--
With Best Regards,
Shengming