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=1796052691; b=YVHNe5m9P17zB9YCnuST+HyVs7Uzbyej1TTpyKszHlvBc19GtBx59GcKk8s4MoXDWQY6 dE51ryTVcnfmi6Ub9c1AEMpMuUNzjA6A3pBGn9ckPthZTjawiqXexKkyTdXy3ux8WOWkn rylcbaOM1YSxydO2eRPQhV2GmdqGy2w3YGpRaBJ71awdlI5k8+yqRrutVuYWYYRzSXHMy sbH0iSCrlsQLqDjCixOb400yA/WZa8BQ9lX+Fh2EPnKJDZTJasupn1v5chh7Fxz3OH91T dF41UN3yrNcgm10QAqLRBnd2Hrz8dHXj0i9yl2+ErzxI8QJ/EtkBGj1JOVw2l+B4TVw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796052691; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=wz9lOtFC8dKwhFObUGqQrGXXzKXNF7cq9KS3o2rO6MI=; b=Ljt3cAkbwm+XxEC3jKso71aChOvjTpol+TeoUP2IK7F8leQ+KMzB+OzBh6ddUqIlWaZD 0/hyIKbYZU25/rbEwxk8uMb88ZeDemDuPuD4uCbjYwB3OS2yLwFK/R21WjEC7vZXgEV6S zYX1gpJ89vzmwyJDQ3fEh17KKutbiLeh9Vzdi49Rbqdhvzl4xQIqnxfI5JwxoXxn4qL0L j12COD6BvFRj876B6YG8jpoZIYsWf+RJ7177rrvJoki6jLT8Z03T46JQNd2XEHfypZ1QF Ui2DsUIZn3mgCcHnRAotTK1iweNjE4vk+Nmo6TofOR5CP3U8fuku3aaN4Lh26DeqL/w== 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=C3O28DJm; 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 64641606A325 for ; Mon, 30 Nov 2026 15:31:31 +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=C3O28DJm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 337EB1F0089A; Mon, 30 Nov 2026 15:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796052690; bh=wz9lOtFC8dKwhFObUGqQrGXXzKXNF7cq9KS3o2rO6MI=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=C3O28DJmHBZbtE/pWbL85N6IhP6FV+U0ep11R1kDYf/5isr7yT78gFF5LA1mGkUGB SAPCg7aYtw/NjCMn5H9QiA7g3xf8+l8+AaGQESh3Rv7DL5uvGEWh6TKwG/nEktW4O3 PZaJ9ioMSNLQ8VtxDjJ35/zBAWHo/JaxsApWCn6HU0QA8gSOGGSIM/5tyugKIdGUfM CeVia7rZpU/UjqV4iklEk/mWPAYWrDCLccceCLkD3e2Un5QG8hjbeSseOEvJOXzg4C B1bldm2EsFFMSS9QdZyXOW/FpGaZGfTH1AnJxD77WqAV7xZgY8dyR2hgpxY1gkcaDg cA40xuwLF3W8Q== Date: Mon, 30 Nov 2026 15:31:28 +0000 From: Harry Yoo To: sashiko-reviews@lists.linux.dev Cc: "Vlastimil Babka (SUSE)" , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , "David Hildenbrand (Arm)" , linux-mm@kvack.org, Chris Mason Subject: Re: [PATCH 4/4] mm/slab: clear stale layout values in calculate_sizes() Message-ID: References: <20261127-slab-ai-fixes-v1-0-cf13b6be6692@kernel.org> <20261127-slab-ai-fixes-v1-4-cf13b6be6692@kernel.org> X-Mailing-List: sashiko-reviews@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Nov 27, 2026 at 09:16:00PM +0000, sashiko-bot@kernel.org wrote: > 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 > > 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. True but I don't really care TBH :) It's fine either way (to me). -- Cheers, Harry / Hyeonggon