mm/slab: pass __GFP_NOWARN to refill_sheaf() if fallback is available
Subsystems (2)
PATCH 1/1 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.
--- mm/slub.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
mm/slub.c +9 -4
@@ -2823,7 +2823,7 @@ static struct slab_sheaf *alloc_full_sheaf(struct kmem_cache *s, gfp_t gfp)if (!sheaf)return NULL ; -if (refill_sheaf (s, sheaf, gfp | __GFP_NOMEMALLOC)) { +if (refill_sheaf (s, sheaf, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) {free_empty_sheaf (s, sheaf);return NULL ; }
@@ -4576,7 +4576,7 @@ __pcs_replace_empty_main(struct kmem_cache *s, struct slub_percpu_sheaves *pcs,return NULL ;if (empty) { -if (!refill_sheaf (s, empty, gfp | __GFP_NOMEMALLOC)) { +if (!refill_sheaf (s, empty, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) { full = empty; }else {/*
@@ -4891,9 +4891,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node_noprof);static int __prefill_sheaf_pfmemalloc (struct kmem_cache *s,struct slab_sheaf *sheaf,gfp_t gfp) { -int ret =0 ; +gfp_t gfp_nomemalloc; +int ret; + + gfp_nomemalloc = gfp | __GFP_NOMEMALLOC; +if (gfp_pfmemalloc_allowed (gfp)) + gfp_nomemalloc |= __GFP_NOWARN; - ret =refill_sheaf (s, sheaf, gfp | __GFP_NOMEMALLOC); + ret =refill_sheaf (s, sheaf, gfp_nomemalloc);if (likely (!ret || !gfp_pfmemalloc_allowed (gfp)))return ret;
Signature · 1 line
2.43.0
Vlastimil Babka (SUSE)
maintainerQuoted 12 lines · Harry Yoo
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_NOWARNalong with__GFP_NOMEMALLOCwhenever 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 whengfp_pfmemalloc_allowed()returns true.
Quoted 5 lines
Reported-by Chris Bainbridge <[email protected]>Fixes 1ce20c28eafd ("slab: handle pfmemalloc slabs properly with sheaves")Signed-off-by Harry Yoo <[email protected]>
Thanks, added to slab/for-next-fixes.
Hopefully Chris can confirm it works (without adding the __NOWARN to btrfs code)
Quoted 43 lines
--- mm/slub.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)mm/slub.c +9
-4@@ -2823,7 +2823,7 @@ static struct slab_sheaf *alloc_full_sheaf(struct kmem_cache *s, gfp_t gfp)if (!sheaf)return NULL ; -if (refill_sheaf (s, sheaf, gfp | __GFP_NOMEMALLOC)) { +if (refill_sheaf (s, sheaf, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) {free_empty_sheaf (s, sheaf);return NULL ; }@@ -4576,7 +4576,7 @@ __pcs_replace_empty_main(struct kmem_cache *s, struct slub_percpu_sheaves *pcs,return NULL ;if (empty) { -if (!refill_sheaf (s, empty, gfp | __GFP_NOMEMALLOC)) { +if (!refill_sheaf (s, empty, gfp | __GFP_NOMEMALLOC | __GFP_NOWARN)) { full = empty; }else {/* @@ -4891,9 +4891,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node_noprof);static int __prefill_sheaf_pfmemalloc (struct kmem_cache *s,struct slab_sheaf *sheaf,gfp_t gfp) { -int ret =0 ; +gfp_t gfp_nomemalloc; +int ret; + + gfp_nomemalloc = gfp | __GFP_NOMEMALLOC; +if (gfp_pfmemalloc_allowed (gfp)) + gfp_nomemalloc |= __GFP_NOWARN; - ret =refill_sheaf (s, sheaf, gfp | __GFP_NOMEMALLOC); + ret =refill_sheaf (s, sheaf, gfp_nomemalloc);if (likely (!ret || !gfp_pfmemalloc_allowed (gfp)))return ret;
Quoted 13 lines · Vlastimil Babka (SUSE)
Quoted 12 lines · Harry Yoo
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_NOWARNalong with__GFP_NOMEMALLOCwhenever 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 whengfp_pfmemalloc_allowed()returns true.
Quoted 8 lines
Quoted 5 lines
Reported-by Chris Bainbridge <[email protected]>Fixes 1ce20c28eafd ("slab: handle pfmemalloc slabs properly with sheaves")Signed-off-by Harry Yoo <[email protected]>Thanks, added to slab/for-next-fixes.
Hopefully Chris can confirm it works (without adding the__NOWARNto btrfs code)
Yes, it works for my test case.
Vlastimil Babka (SUSE)
maintainerQuoted 20 lines · Chris Bainbridge
Quoted 19 lines · Vlastimil Babka (SUSE)
Quoted 17 lines · Harry Yoo
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_NOWARNalong with__GFP_NOMEMALLOCwhenever 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 whengfp_pfmemalloc_allowed()returns true.Reported-by Chris Bainbridge <[email protected]>Fixes 1ce20c28eafd ("slab: handle pfmemalloc slabs properly with sheaves")Signed-off-by Harry Yoo <[email protected]>
Quoted 4 lines
Quoted 2 lines
Thanks, added to slab/for-next-fixes.
Hopefully Chris can confirm it works (without adding the__NOWARNto btrfs code)Yes, it works for my test case.
Great, can we add your Tested-by: then?
Thanks!
Quoted 21 lines · Vlastimil Babka (SUSE)
Quoted 20 lines · Chris Bainbridge
Quoted 19 lines · Vlastimil Babka (SUSE)
Quoted 17 lines · Harry Yoo
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_NOWARNalong with__GFP_NOMEMALLOCwhenever 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 whengfp_pfmemalloc_allowed()returns true.Reported-by Chris Bainbridge <[email protected]>Fixes 1ce20c28eafd ("slab: handle pfmemalloc slabs properly with sheaves")Signed-off-by Harry Yoo <[email protected]>
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Thanks, added to slab/for-next-fixes.
Hopefully Chris can confirm it works (without adding the__NOWARNto btrfs code)Yes, it works for my test case.
Great, can we add your Tested-by: then?
Thanks!
Sure.