Skip to content

Commit 021ca6b

Browse files
hygoniVlastimil Babka (SUSE)
authored andcommitted
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: 1ce20c2 ("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>
1 parent 6de23f8 commit 021ca6b

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

mm/slub.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,7 +2822,7 @@ static struct slab_sheaf *alloc_full_sheaf(struct kmem_cache *s, gfp_t gfp)
28222822
if (!sheaf)
28232823
return NULL;
28242824

2825-
if (refill_sheaf(s, sheaf, gfp | __GFP_NOMEMALLOC)) {
2825+
if (refill_sheaf(s, sheaf, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) {
28262826
free_empty_sheaf(s, sheaf);
28272827
return NULL;
28282828
}
@@ -4575,7 +4575,7 @@ __pcs_replace_empty_main(struct kmem_cache *s, struct slub_percpu_sheaves *pcs,
45754575
return NULL;
45764576

45774577
if (empty) {
4578-
if (!refill_sheaf(s, empty, gfp | __GFP_NOMEMALLOC)) {
4578+
if (!refill_sheaf(s, empty, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) {
45794579
full = empty;
45804580
} else {
45814581
/*
@@ -4890,9 +4890,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node_noprof);
48904890
static int __prefill_sheaf_pfmemalloc(struct kmem_cache *s,
48914891
struct slab_sheaf *sheaf, gfp_t gfp)
48924892
{
4893-
int ret = 0;
4893+
gfp_t gfp_nomemalloc;
4894+
int ret;
4895+
4896+
gfp_nomemalloc = gfp | __GFP_NOMEMALLOC;
4897+
if (gfp_pfmemalloc_allowed(gfp))
4898+
gfp_nomemalloc |= __GFP_NOWARN;
48944899

4895-
ret = refill_sheaf(s, sheaf, gfp | __GFP_NOMEMALLOC);
4900+
ret = refill_sheaf(s, sheaf, gfp_nomemalloc);
48964901

48974902
if (likely(!ret || !gfp_pfmemalloc_allowed(gfp)))
48984903
return ret;

0 commit comments

Comments
 (0)