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 v3] mm/slub: free prefilled empty sheaves consistently
Date: Tue, 26 May 2026 15:02:28 +0900 [thread overview]
Message-ID: <799bdd0f-2771-4fad-8617-fbe4165689d9@kernel.org> (raw)
In-Reply-To: <20260525211000387LYqTHmxYL900XIB8qwV3h@zte.com.cn>
On 5/25/26 10:10 PM, hu.shengming@zte.com.cn wrote:
> From: Shengming Hu <hu.shengming@zte.com.cn>
>
> Empty sheaves allocated by alloc_empty_sheaf() should be released with
> free_empty_sheaf().
>
> Move the empty-sheaf capacity initialization into __alloc_empty_sheaf()
> and use it for oversized prefilled sheaves as well.
>
> This keeps the prefill paths consistent: after flushing an oversized or
> pfmemalloc sheaf, release the now-empty sheaf through free_empty_sheaf()
> instead of kfree().
>
> Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
> ---
> mm/slub.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 04692a6f9128..f4c06bf43f2d 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2782,6 +2782,7 @@ static struct slab_sheaf *__alloc_empty_sheaf(struct kmem_cache *s, gfp_t gfp,
> return NULL;
>
> sheaf->cache = s;
> + sheaf->capacity = capacity;
the capacity field is only used by oversized sheaves (for now).
It should be outside __alloc_empty_sheaf().
> stat(s, SHEAF_ALLOC);
>
> @@ -5015,21 +5016,15 @@ kmem_cache_prefill_sheaf(struct kmem_cache *s, gfp_t gfp, unsigned int size)
>
> if (unlikely(size > s->sheaf_capacity)) {
>
> - sheaf = kzalloc_flex(*sheaf, objects, size, gfp);
> + sheaf = __alloc_empty_sheaf(s, gfp, size);
> if (!sheaf)
> return NULL;
>
> stat(s, SHEAF_PREFILL_OVERSIZE);
So now SHEAF_ALLOC and SHEAF_FREE include oversized sheaves.
I think that's fine, but can we update the commit message and the comment?
the comment:
SHEAF_ALLOC, /* Allocation of an empty sheaf including oversized ones */
SHEAF_FREE, /* Freeing of an empty sheaf including oversized ones */
> - sheaf->cache = s;
> - sheaf->capacity = size;
> - /*
> - * we do not need to care about pfmemalloc here because oversize
> - * sheaves area always flushed and freed when returned
> - */
the comment is still worth having?
> if (!__kmem_cache_alloc_bulk(s, gfp, size,
> &sheaf->objects[0])) {
> - kfree(sheaf);
> + free_empty_sheaf(s, sheaf);
> return NULL;
> }
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2026-05-26 6:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 13:10 hu.shengming
2026-05-26 5:53 ` Hao Li
2026-05-26 7:11 ` hu.shengming
2026-05-26 6:02 ` Harry Yoo [this message]
2026-05-26 13:52 ` hu.shengming
2026-05-28 20:29 ` kernel test robot
2026-05-29 8:09 ` Vlastimil Babka (SUSE)
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=799bdd0f-2771-4fad-8617-fbe4165689d9@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®