From: sashiko-bot@kernel.org
To: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>,
"Harry Yoo" <harry@kernel.org>
Cc: "Hao Li" <hao.li@linux.dev>, "Christoph Lameter" <cl@gentwo.org>,
"David Rientjes" <rientjes@google.com>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"David Hildenbrand (Arm)" <david@kernel.org>,
linux-mm@kvack.org, "Chris Mason" <mason@kernel.org>
Subject: Re: [PATCH 4/4] mm/slab: clear stale layout values in calculate_sizes()
Date: Fri, 27 Nov 2026 21:16:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-238287@kernel.org> (raw)
In-Reply-To: <20261127-slab-ai-fixes-v1-4-cf13b6be6692@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mm/slab: late SLAB_NO_MERGE in do_kmem_cache_create() skips
obj_ext in object
--
commit e36d70bf4b2fe1e8cc089823e91c1a5b0b9817ea
Author: Chris Mason <mason@kernel.org>
mm/slab: clear stale layout values in calculate_sizes()
This commit resets SLAB_OBJ_EXT_IN_OBJ and s->red_left_pad in
do_kmem_cache_create() before recalculating cache sizes when debug metadata
flags are dropped due to an increased minimum slab order.
> diff --git a/mm/slub.c b/mm/slub.c
> index 9bb031f9a41fd..003023b6f8dc6 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -8860,8 +8860,16 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name,
> * order increased.
> */
> if (get_order(s->size) > get_order(s->object_size)) {
> +
> s->flags &= ~DEBUG_METADATA_FLAGS;
> + /*
> + * Reset fields that the previous run may have set and
> + * now might be different.
> + */
> + s->flags &= ~SLAB_OBJ_EXT_IN_OBJ;
> s->offset = 0;
> + s->red_left_pad = 0;
> +
> if (!calculate_sizes(args, s))
> goto out;
> /* Created as unmergeable, so it has to stay so */
[Severity: Low]
Should SLAB_NO_MERGE be set on s->flags before the second calculate_sizes()
call rather than after it?
calculate_sizes() only sets SLAB_OBJ_EXT_IN_OBJ when the cache is
unmergeable:
mm/slub.c:calculate_sizes() {
...
if (slab_args_unmergeable(args, s->flags) &&
(aligned_size - size >= cache_obj_ext_size(s)))
s->flags |= SLAB_OBJ_EXT_IN_OBJ;
...
}
For a cache that was only unmergeable because of DEBUG_METADATA_FLAGS,
clearing DEBUG_METADATA_FLAGS and SLAB_OBJ_EXT_IN_OBJ before setting
SLAB_NO_MERGE makes slab_args_unmergeable(args, s->flags) return false
during the second calculate_sizes() call. Even when the non-debug object
layout still has enough alignment padding, SLAB_OBJ_EXT_IN_OBJ is not
re-enabled and slab allocations fall back to separate slabobj_ext arrays.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-slab-ai-fixes-v1-0-cf13b6be6692@kernel.org?part=4
prev parent reply other threads:[~2026-11-27 21:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 20:12 [PATCH 0/4] slab AI fixes Vlastimil Babka (SUSE)
2026-11-27 20:12 ` [PATCH 1/4] mm/slab: drop __GFP_NOFAIL when refilling sheaves Vlastimil Babka (SUSE)
2026-11-27 20:12 ` [PATCH 2/4] mm/slab: handle __GFP_NOFAIL better with prefilled sheaves Vlastimil Babka (SUSE)
2026-11-27 21:15 ` sashiko-bot
2026-11-27 20:12 ` [PATCH 3/4] mm/slab: keep caches that drop debug flags unmergeable Vlastimil Babka (SUSE)
2026-11-27 21:15 ` sashiko-bot
2026-11-27 20:12 ` [PATCH 4/4] mm/slab: clear stale layout values in calculate_sizes() Vlastimil Babka (SUSE)
2026-11-27 21:16 ` sashiko-bot [this message]
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=sashiko-outbox-238287@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cl@gentwo.org \
--cc=david@kernel.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=linux-mm@kvack.org \
--cc=mason@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vbabka@kernel.org \
/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