From: Harry Yoo <harry@kernel.org>
To: hu.shengming@zte.com.cn, vbabka@kernel.org, akpm@linux-foundation.org
Cc: hao.li@linux.dev, cl@gentwo.org, rientjes@google.com,
roman.gushchin@linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, zhang.run@zte.com.cn,
cai.qu@zte.com.cn
Subject: Re: [PATCH] mm/slub: free returned pfmemalloc sheaves via free_empty_sheaf()
Date: Fri, 22 May 2026 10:21:58 +0900 [thread overview]
Message-ID: <13fd910b-e897-4a9d-847a-545267209bf8@kernel.org> (raw)
In-Reply-To: <20260521195015105Y4zvKHj0TfPZEujixy9Vo@zte.com.cn>
Hi Shengming,
On 5/21/26 8:50 PM, hu.shengming@zte.com.cn wrote:
> From: Shengming Hu <hu.shengming@zte.com.cn>
>
> Regular sized sheaves are allocated through alloc_empty_sheaf(), which
> sets __GFP_NO_OBJ_EXT. free_empty_sheaf() is the matching free helper
> for such sheaves. It marks kmalloc sheaves with an empty codetag before
> kfree(), avoiding the alloc_tag_sub() warning for intentionally missing
> object extensions.
>
> kmem_cache_return_sheaf() currently handles returned pfmemalloc sheaves
> in the same branch as oversize sheaves and uses kfree(). That is right
> for oversize sheaves, which are allocated directly with kzalloc_flex(),
> but it misses the matching free path for regular sized pfmemalloc sheaves
> that came from alloc_empty_sheaf().
I think it'd be better (in terms of readability) to teach
alloc_empty_sheaf() how to allocate and initialize an oversized empty
sheaf, and always free empty sheaves with free_empty_sheaf().
> Split the two cases. Keep plain kfree() for capacity-mismatched oversize
> sheaves, and use free_empty_sheaf() after flushing returned pfmemalloc
> regular sheaves.
>
> Fixes: <1ce20c2> ("slab: handle pfmemalloc slabs properly with sheaves")
When referring to a commit, the commit id should contain at least 12
characters to avoid collisions (per the process document).
...but probably Fixes: is not needed at all, because currently no user
uses kmalloc caches to allocate prefilled sheaves.
> Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
> ---
> mm/slub.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 04692a6f9128..a6b720fa79ad 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -5094,13 +5094,18 @@ void kmem_cache_return_sheaf(struct kmem_cache *s, gfp_t gfp,
> struct slub_percpu_sheaves *pcs;
> struct node_barn *barn;
>
> - if (unlikely((sheaf->capacity != s->sheaf_capacity)
> - || sheaf->pfmemalloc)) {
> + if (unlikely(sheaf->capacity != s->sheaf_capacity)) {
> sheaf_flush_unused(s, sheaf);
> kfree(sheaf);
> return;
> }
>
> + if (unlikely(sheaf->pfmemalloc)) {
> + sheaf_flush_unused(s, sheaf);
> + free_empty_sheaf(s, sheaf);
> + return;
> + }
> +
> local_lock(&s->cpu_sheaves->lock);
> pcs = this_cpu_ptr(s->cpu_sheaves);
> barn = get_barn(s);
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2026-05-22 1:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 11:50 hu.shengming
2026-05-22 1:21 ` Harry Yoo [this message]
2026-05-22 2:15 ` hu.shengming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13fd910b-e897-4a9d-847a-545267209bf8@kernel.org \
--to=harry@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cai.qu@zte.com.cn \
--cc=cl@gentwo.org \
--cc=hao.li@linux.dev \
--cc=hu.shengming@zte.com.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@kernel.org \
--cc=zhang.run@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®