]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
slab: handle pfmemalloc slabs properly with sheaves
authorVlastimil Babka <vbabka@suse.cz>
Wed, 5 Nov 2025 09:05:31 +0000 (10:05 +0100)
committerVlastimil Babka <vbabka@suse.cz>
Fri, 7 Nov 2025 08:59:15 +0000 (09:59 +0100)
commit1ce20c28eafdc101164a4bfedd2ea818eb137de7
treec1f73705365278490d2d5c6bc078acf7bce1357f
parentea6b5e5778b1dc58b1909e4badd3e180ddae7418
slab: handle pfmemalloc slabs properly with sheaves

When a pfmemalloc allocation actually dips into reserves, the slab is
marked accordingly and non-pfmemalloc allocations should not be allowed
to allocate from it. The sheaves percpu caching currently doesn't follow
this rule, so implement it before we expand sheaves usage to all caches.

Make sure objects from pfmemalloc slabs don't end up in percpu sheaves.
When freeing, skip sheaves when freeing an object from pfmemalloc slab.
When refilling sheaves, use __GFP_NOMEMALLOC to override any pfmemalloc
context - the allocation will fallback to regular slab allocations when
sheaves are depleted and can't be refilled because of the override.

For kfree_rcu(), detect pfmemalloc slabs after processing the rcu_sheaf
after the grace period in __rcu_free_sheaf_prepare() and simply flush
it if any object is from pfmemalloc slabs.

For prefilled sheaves, try to refill them first with __GFP_NOMEMALLOC
and if it fails, retry without __GFP_NOMEMALLOC but then mark the sheaf
pfmemalloc, which makes it flushed back to slabs when returned.

Link: https://patch.msgid.link/20251105-sheaves-cleanups-v1-3-b8218e1ac7ef@suse.cz
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
mm/slub.c