Re: [PATCH 3/4] mm/slab: keep caches that drop debug flags unmergeable

From: Harry Yoo

Date: Mon Nov 30 2026 - 10:14:58 EST


On Fri, Nov 27, 2026 at 09:12:32PM +0100, Vlastimil Babka (SUSE) wrote:
> From: Chris Mason <mason@xxxxxxxxxx>
>
> When slab_debug boot parameter contains the O flag and a list of caches,
> two caches can get the same id in /sys/kernel/slab, so sysfs warns about
> a duplicate filename and one of them is missing there as a result.
>
> create_unique_id() builds the id of a mergeable cache from its size and
> flags, so caches that are mergeable and result in the same unique id
> must get merged - otherwise a duplicate id would try to be created.
>
> But find_mergeable() doesn't merge a new cache that has (at that point)
> debug flags, and with O do_kmem_cache_create() later drops the flags
> that store metadata if they raise the minimum slab order, and the cache
> can become mergeable again, but too late. An example with the id:
>
> slab_debug=OU,sgpool-128
>
> biovec-max mergeable :0004096
> sgpool-128 has U, so not merged into biovec-max
> later U dropped, so mergeable :0004096
>
> sysfs_slab_add() has a check for such caches since commit 11066386efa6
> ("slub: fix sysfs duplicate filename creation when slub_debug=O") but it
> tests only the global slub_debug, and flags given for a list of caches
> don't end up there.
>
> The fix used here is to mark the cache unmergeable when its debug flags
> are dropped. With that, we can also effectively revert commit
> 11066386efa6 since the global slub_debug is covered by this fix too.
>
> Ideally we would evaluate mergeability with the O flag precisely
> (dropping the U soon enough to merge) but that would be a more involved
> change and probably not worth the effort.
>
> [vbabka: revert 11066386efa6, tweak commit message]
>
> Fixes: e17f1dfba37b ("mm, slub: extend slub_debug syntax for multiple blocks")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: Chris Mason <mason@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> Co-developed-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> ---

Looks good to me,
Reviewed-by: Harry Yoo (Meta) <harry@xxxxxxxxxx>

--
Cheers,
Harry / Hyeonggon