Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/slab: pass __GFP_NOWARN to refill_sheaf() if fallback is available

When refill_sheaf() is called, failing to refill the sheaf doesn't
necessarily mean the allocation will fail because a fallback path
might be available and serve the allocation request.

Suppress spurious warnings by passing __GFP_NOWARN along with
__GFP_NOMEMALLOC whenever a fallback path is available.

When the caller is alloc_full_sheaf() or __pcs_replace_empty_main(),
the kernel always falls back to the slowpath (__slab_alloc_node()).
For __prefill_sheaf_pfmemalloc(), the fallback path is available
only when gfp_pfmemalloc_allowed() returns true.

Reported-and-tested-by: Chris Bainbridge <chris.bainbridge@gmail.com>
Closes: https://lore.kernel.org/linux-mm/aZt2-oS9lkmwT7Ch@debian.local
Fixes: 1ce20c28eafd ("slab: handle pfmemalloc slabs properly with sheaves")
Link: https://lore.kernel.org/linux-mm/aZwSreGj9-HHdD-j@hyeyoo
Signed-off-by: Harry Yoo <harry.yoo@oracle.com>
Link: https://patch.msgid.link/20260223133322.16705-1-harry.yoo@oracle.com
Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>

authored by

Harry Yoo and committed by
Vlastimil Babka (SUSE)
021ca6b6 6de23f81

+9 -4
+9 -4
mm/slub.c
··· 2822 2822 if (!sheaf) 2823 2823 return NULL; 2824 2824 2825 - if (refill_sheaf(s, sheaf, gfp | __GFP_NOMEMALLOC)) { 2825 + if (refill_sheaf(s, sheaf, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) { 2826 2826 free_empty_sheaf(s, sheaf); 2827 2827 return NULL; 2828 2828 } ··· 4575 4575 return NULL; 4576 4576 4577 4577 if (empty) { 4578 - if (!refill_sheaf(s, empty, gfp | __GFP_NOMEMALLOC)) { 4578 + if (!refill_sheaf(s, empty, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) { 4579 4579 full = empty; 4580 4580 } else { 4581 4581 /* ··· 4890 4890 static int __prefill_sheaf_pfmemalloc(struct kmem_cache *s, 4891 4891 struct slab_sheaf *sheaf, gfp_t gfp) 4892 4892 { 4893 - int ret = 0; 4893 + gfp_t gfp_nomemalloc; 4894 + int ret; 4894 4895 4895 - ret = refill_sheaf(s, sheaf, gfp | __GFP_NOMEMALLOC); 4896 + gfp_nomemalloc = gfp | __GFP_NOMEMALLOC; 4897 + if (gfp_pfmemalloc_allowed(gfp)) 4898 + gfp_nomemalloc |= __GFP_NOWARN; 4899 + 4900 + ret = refill_sheaf(s, sheaf, gfp_nomemalloc); 4896 4901 4897 4902 if (likely(!ret || !gfp_pfmemalloc_allowed(gfp))) 4898 4903 return ret;