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>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Conor Dooley" <conor@kernel.org>,
"Damien Le Moal" <dlemoal@kernel.org>,
linux-mm@kvack.org
Subject: Re: [PATCH RFC v2 2/8] mm, slab: introduce slab_debug=N
Date: Sat, 24 Oct 2026 19:22:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-183847@kernel.org> (raw)
In-Reply-To: <20261024-slub_tiny_rework-v2-2-bf1419ab5ffd@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mm, slab: missing SLAB_DEBUG_NOOP in SLAB_MERGE_SAME merges mismatched caches
--
commit 2d842bc4bf4f28b2b4c86a9001856691abe3624c
Author: Vlastimil Babka (SUSE) <vbabka@kernel.org>
mm, slab: introduce slab_debug=N
This commit introduces the slab_debug=N boot option and the corresponding
SLAB_DEBUG_NOOP slab flag to force slab debugging slowpaths and disable
percpu sheaf caching without enabling actual debug checks. It also excludes
SLAB_DEBUG_NOOP from SLAB_NEVER_MERGE and avoids disabling printk pointer
hashing when only SLAB_DEBUG_NOOP is enabled.
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 01c64ef661e7f..02dfe4351e8b7 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -47,9 +47,9 @@ struct kmem_cache *kmem_cache;
> * Any flag that adds per-object metadata should be included,
> * since slab merging can update s->inuse that affects the metadata layout.
> */
> -#define SLAB_NEVER_MERGE (SLAB_DEBUG_FLAGS | SLAB_TYPESAFE_BY_RCU | \
> - SLAB_NOLEAKTRACE | SLAB_FAILSLAB | SLAB_NO_MERGE | \
> - SLAB_OBJ_EXT_IN_OBJ)
> +#define SLAB_NEVER_MERGE ((SLAB_DEBUG_FLAGS & ~SLAB_DEBUG_NOOP) | \
> + SLAB_TYPESAFE_BY_RCU | SLAB_NOLEAKTRACE | SLAB_FAILSLAB | \
> + SLAB_NO_MERGE | SLAB_OBJ_EXT_IN_OBJ)
>
> #define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | \
> SLAB_CACHE_DMA32 | SLAB_ACCOUNT | SLAB_MAY_ACCOUNT)
[Severity: Medium]
Should SLAB_DEBUG_NOOP also be added to SLAB_MERGE_SAME?
Excluding SLAB_DEBUG_NOOP from SLAB_NEVER_MERGE allows caches with
SLAB_DEBUG_NOOP to participate in slab merging, which is checked in
find_mergeable():
mm/slab_common.c:find_mergeable() {
flags = kmem_cache_flags(flags, name);
if (slab_args_unmergeable(args, flags))
return NULL;
...
list_for_each_entry_reverse(s, &slab_caches, list) {
if (slab_unmergeable(s))
continue;
if (size > s->size)
continue;
if ((flags & SLAB_MERGE_SAME) != (s->flags & SLAB_MERGE_SAME))
continue;
}
When SLAB_DEBUG_NOOP is enabled for a subset of caches (for example via
per-cache boot parameters such as slab_debug=N,<cache_name> or
slab_debug=N;-,<cache_name>, or by passing SLAB_DEBUG_NOOP to
kmem_cache_create()), find_mergeable() does not require both caches to agree
on SLAB_DEBUG_NOOP.
As a result, a cache matched by slab_debug=N,<cache_name> can merge into an
existing compatible cache created without SLAB_DEBUG_NOOP (such as a
kmalloc-* cache), keeping percpu sheaves enabled and silently ignoring the
requested option. Conversely, if an earlier mergeable cache is created with
SLAB_DEBUG_NOOP, subsequent compatible caches without SLAB_DEBUG_NOOP will
merge into it and be forced onto the debug slowpaths with zero sheaf
capacity.
If SLAB_DEBUG_NOOP is added to SLAB_MERGE_SAME, does create_unique_id() in
mm/slub.c also need to encode SLAB_DEBUG_NOOP so that aliasable caches
differing only in SLAB_DEBUG_NOOP do not generate colliding sysfs IDs in
sysfs_slab_add()?
mm/slub.c:create_unique_id() {
/*
* First flags affecting slabcache operations. We will only
* get here for aliasable slabs so we do not need to support
* too many flags. The flags here must cover all flags that
* are matched during merging to guarantee that the id is
* unique.
*/
if (s->flags & SLAB_CACHE_DMA)
*p++ = 'd';
if (s->flags & SLAB_CACHE_DMA32)
*p++ = 'D';
if (s->flags & SLAB_RECLAIM_ACCOUNT)
*p++ = 'a';
if (s->flags & SLAB_CONSISTENCY_CHECKS)
*p++ = 'F';
if (s->flags & SLAB_ACCOUNT)
*p++ = 'A';
}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261024-slub_tiny_rework-v2-0-bf1419ab5ffd@kernel.org?part=2
next prev parent reply other threads:[~2026-10-24 19:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 19:07 [PATCH RFC v2 0/8] replace CONFIG_SLUB_TINY with a slab_tiny boot parameter Vlastimil Babka (SUSE)
2026-10-24 19:07 ` [PATCH RFC v2 1/8] mm, slab: refactor slab_min/max_order handling Vlastimil Babka (SUSE)
2026-10-24 19:07 ` [PATCH RFC v2 2/8] mm, slab: introduce slab_debug=N Vlastimil Babka (SUSE)
2026-10-24 19:22 ` sashiko-bot [this message]
2026-10-24 19:07 ` [PATCH RFC v2 3/8] mm, slab: rework KMALLOC_RECLAIM handling of SLUB_TINY Vlastimil Babka (SUSE)
2026-10-28 11:43 ` Hao Li
2026-10-24 19:07 ` [PATCH RFC v2 4/8] mm, slab: make SLUB_TINY handling dynamic for sizing decisions Vlastimil Babka (SUSE)
2026-10-24 19:07 ` [PATCH RFC v2 5/8] mm, slab: convert CONFIG_SLUB_TINY checks to kmem_cache_debug() Vlastimil Babka (SUSE)
2026-10-24 19:07 ` [PATCH RFC v2 6/8] mm, slab: remove remaining compile-time checks for CONFIG_SLUB_TINY Vlastimil Babka (SUSE)
2026-10-24 19:07 ` [PATCH RFC v2 7/8] mm, slab: add slab_tiny boot param Vlastimil Babka (SUSE)
2026-10-24 19:07 ` [PATCH RFC v2 8/8] mm, slab: deprecate CONFIG_SLUB_TINY and reduce its Kconfig effects Vlastimil Babka (SUSE)
2026-10-24 19:22 ` sashiko-bot
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-183847@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cl@gentwo.org \
--cc=conor@kernel.org \
--cc=dlemoal@kernel.org \
--cc=geert@linux-m68k.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.