From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796148979; b=ypyb79Y4Z9zDtKC5rfiH3OVHoF6Ux61w1n3kQBHBTmMtb3mj1DVQBw1DUzIhbhKwXeMf 2SKk8gRk1szI7eyVeZWbDj3uLG7omOF+xIzVk9scqZiwOEyPk4R1VHwdnTr1wDCqze7uN FcCsYeem0yF5Dr8RxkGNKfTWNm1pxQtRwjHONaolbpSsJoKHDIsh2UMhpx1/nWjGVT/Xd Eo+Xl05HN4LeofPxeH5eRM9ws9ha/D+/o7di3ilagnS9Q8ch44QGOqmSVtTSdW7NkvwYd eNBPUAG83RFYoc1K9IJVRg5VK130n+S0dmIvignjc06O8NDk7L+bSaSZP0+M39umEQQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796148979; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer; bh=ztI8h7Ln7OIq2TpRttgWPm/MG37bdeT865BVk72rMxE=; b=NH0LqQ2RzyzFy1w2iGZs99VitmneyyCAKx+/UL9yzlaZijugPP8LurcxFpAWu8itzARA qqMuXQF6FrEu62Rg7YsBO82QFiA9m1iUdCzV0UsDvY7uqqaJsqV6buXMC1FHJ0FoAmcrs /xZna9prQHhNmHyO8kKihvTiN2weDuyFbJLKyfeqz1dW1kHahmE6amfcpJhPWeHn9P+zF oHS5rY5cvMn2MkdrtFbOX79jz4vl3a5Ybh/2vSUv3CNZXpeJnMrnQg8mseXu9NEl2aE6C pYf2lKrGVU32lh99Fixv8Yem+DfGBIjMsEqEw1KBqF5Wyiv0eQ2ZH62rinJ/tyWELEw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jVhFFshH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A70DA606A31A; Tue, 1 Dec 2026 18:16:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jVhFFshH Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F8841F0089F; Tue, 1 Dec 2026 18:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796148979; bh=ztI8h7Ln7OIq2TpRttgWPm/MG37bdeT865BVk72rMxE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=jVhFFshHiZw6IEr4rLme2e/ffKqRbeHDqAYig3oMzvZnsteuJgHdgbabLzZXawtex RMtp63tJ5JPJrWRvSMHCQ5rKZ/sY2+CeizBqMr7wQuZydbJGKaRT3awFnLZ4w5i4RU nFp4mL1qxTW0ltwCC8bKLx1mQwuwjTNcYxD2PVK4s7x4JY1EycCAuAS+APIiWsIKZ9 mGtkRdsBBb54fyz4J/j0KLryvra1VzAg+Tv+fFpi9YD0d6YDQO4B63RvuSiq8+FhqN PnojxhgbMKtB4yll37fiYHa+BpzJqbzFzleuQ9PoVfTeXQtCkRDpIW914uQwviTnM7 L0ZnC30id+0ig== From: "Vlastimil Babka (SUSE)" Date: Tue, 01 Dec 2026 19:16:04 +0100 Subject: [PATCH v2 3/4] mm/slab: keep caches that drop debug flags unmergeable X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261201-slab-ai-fixes-v2-3-7419dfbd3bac@kernel.org> References: <20261201-slab-ai-fixes-v2-0-7419dfbd3bac@kernel.org> In-Reply-To: <20261201-slab-ai-fixes-v2-0-7419dfbd3bac@kernel.org> To: Harry Yoo Cc: Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , "David Hildenbrand (Arm)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Vlastimil Babka (SUSE)" , Chris Mason , stable@vger.kernel.org X-Mailer: b4 0.16.0 From: Chris Mason 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, address sashiko feedback] Fixes: e17f1dfba37b ("mm, slub: extend slub_debug syntax for multiple blocks") Cc: stable@vger.kernel.org Signed-off-by: Chris Mason Signed-off-by: David Hildenbrand (Arm) Co-developed-by: Vlastimil Babka (SUSE) Signed-off-by: Vlastimil Babka (SUSE) Reviewed-by: Harry Yoo (Meta) --- mm/slub.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 0927ffbb1b5e..4e29720ee62d 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -8873,6 +8873,8 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name, if (get_order(s->size) > get_order(s->object_size)) { s->flags &= ~DEBUG_METADATA_FLAGS; s->offset = 0; + /* Created as unmergeable, so it has to stay so */ + s->flags |= SLAB_NO_MERGE; if (!calculate_sizes(args, s)) goto out; } @@ -9836,10 +9838,6 @@ static int sysfs_slab_add(struct kmem_cache *s) struct kset *kset = cache_kset(s); int unmergeable = slab_unmergeable(s); - if (!unmergeable && disable_higher_order_debug && - (slub_debug & DEBUG_METADATA_FLAGS)) - unmergeable = 1; - if (unmergeable) { /* * Slabcache can never be merged so we can use the name proper. -- 2.56.1