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=1796309211; b=fMYbjED5yYBUVkx93hxzfYOsPxUSiSytow7TVvXL5l5f4BdBxZadUOUlF38PZ806K81G Dl1MVPg/q+Hw0qzG30AbafgIDHy4kTVWcy7p8maQEVPBgChccvsJvZzlmUofrI2QeevRp OmW1du1T96zYCC9WP2SBmwlrXTCRhCtP7x1tEC1oHeXdyiNc5ndxgDiHdyKaS9RfQE4dU Zuph0tpKJ0Np7jwvVdSco0bDNYCWfkwCQeCsFm2oir30O28TuLl1AwKGyPGg016MatF+W sTI4sMoTOnaBbC759HuIs43RjsHKK5v+u0atF/ZiMWf9PMXcFCwspSm0n6FWDeXaabA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309211; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=6EWUztHmhiTkBrcqDZ+f7uLODjWFek2K7WQ2yJoUw3g=; b=kGcWwMnm2LUZsC6pTYqV5wKvs9FH5p9mzFfxzQd+Fj7S9T9uSQzd2+kCvqR7dlS0lsKs fdru9kL9tElwakGDKyW0Rt3yuDFvKfYanbfv2q4MQQmH4qQwchIHQndz8h716s9+63/cu GglIrNeAapbj4cYTXWIukkrGCWkOizjDbIJinXuSuZYEf/os37qqyaIkp8LzQ+00ouUzs oTX7e2jHg8Riz3bOZDuzO8CihHFujAcYelBQAicMhiJQ0Ab0W6uMoohve7aKoz3EHxsLK JmTd6N24AxJ0etvQMS3O0KBXGMAzENWLaISLrGAlHwWgqwWK4iIdFXGFzh0dp/ow5TQ== 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=WOhQYE4L; 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 33181606A322; Thu, 3 Dec 2026 14:46:51 +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=WOhQYE4L Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71DF91F00893; Thu, 3 Dec 2026 14:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796309211; bh=6EWUztHmhiTkBrcqDZ+f7uLODjWFek2K7WQ2yJoUw3g=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=WOhQYE4LJb9lUtyEBRCfqx0KWO6EzZAJjRo/Gi3iGSwhJw1nhm1o4o8paON4PnW3P W03Y+lU0I9V9t67q2CSV6vbVq1vevn8dz5cGNuOcMu0Rjs6sQ/t7OiSugWn2lXt+pZ ngPav8CAazZEBYUOVPJTGfN4DqIqSm8SAx2bwDe1y7Z/9LgBO7JM7r5saIDpS9tw7Z Kp0u109Gl7QKpq59uT6TAUFsRUw01XAp22bXc0cVf966eVKx6KblCDzIfTDtYWlK7d 4uUt6iHBmoH98pFDsy/2+cYCOk2RovRITmZHnuZNgxFcxMcY9VuglHyWuKFlnc5Ixm eGE8A/l8vS3FA== Date: Thu, 3 Dec 2026 14:46:49 +0000 From: Harry Yoo To: Hao Li Cc: Vlastimil Babka , Andrew Morton , Suren Baghdasaryan , Johannes Weiner , Michal Hocko , Shakeel Butt , Roman Gushchin , Christoph Lameter , David Rientjes , Muchun Song , Hao Ge , Pedro Falcato , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, "Liam R. Howlett" , Alice Ryhl , Andrew Ballance , Matthew Wilcox , linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , "David S. Miller" , Jakub Kicinski , Sebastian Andrzej Siewior , Jiayuan Chen , netdev@vger.kernel.org, Kees Cook , David Hildenbrand , Lorenzo Stoakes , Catalin Marinas , Will Deacon , Mark Rutland , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Robin Murphy , "Joerg Roedel (AMD)" , Amir Goldstein , Casey Schaufler , Paul Moore , James Morris , "Serge E. Hallyn" , linux-security-module@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , Eric Dumazet Subject: Re: [PATCH slab/for-next v2 14/14] mm/slab: do not set SLAB_MAY_ACCOUNT for all caches Message-ID: References: <20261125-memalloc-prof-dont-waste-slabobj-ext-metadata-v2-0-7c680f02a734@kernel.org> <20261125-memalloc-prof-dont-waste-slabobj-ext-metadata-v2-14-7c680f02a734@kernel.org> X-Mailing-List: linux-fsdevel@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=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Dec 03, 2026 at 02:36:57PM +0000, Hao Li wrote: > On Thu, Dec 03, 2026 at 02:27:25PM +0000, Harry Yoo wrote: > > On Thu, Dec 03, 2026 at 02:17:21PM +0000, Hao Li wrote: > > > On Wed, Nov 25, 2026 at 09:37:15PM +0000, Harry Yoo (Meta) wrote: > > > > Now that all caches whose objects may be allocated with __GFP_ACCOUNT > > > > specify SLAB_MAY_ACCOUNT (or SLAB_ACCOUNT, which implies it), stop > > > > assuming any cache may be used with __GFP_ACCOUNT. This avoids wasting > > > > the objcg slot in slabobj_ext for caches that are never charged to a > > > > memcg. > > > > > > > > Signed-off-by: Harry Yoo (Meta) > > > > --- > > > > diff --git a/mm/slab_common.c b/mm/slab_common.c > > > > index 193b5a03bc47..464695504248 100644 > > > > --- a/mm/slab_common.c > > > > +++ b/mm/slab_common.c > > > > @@ -367,12 +367,10 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, > > > > goto out_unlock; > > > > } > > > > > > > > - /* > > > > - * For now we assume any cache can be used with __GFP_ACCOUNT and thus > > > > - * may need to store objcg pointers for objects > > > > - */ > > > > - if (!mem_cgroup_kmem_disabled()) > > > > + if (flags & SLAB_ACCOUNT) > > > > flags |= SLAB_MAY_ACCOUNT; > > > > + if (mem_cgroup_kmem_disabled()) > > > > + flags &= ~SLAB_MAY_ACCOUNT; > > > > > > Btw, say maple_node/sk_buff/... could be merged with cacheX before. After this > > > patch, cacheX loses SLAB_MAY_ACCOUNT while we still set SLAB_MAY_ACCOUNT for > > > maple_node explicitly, so they can't be merged anymore. Not sure if it matters, > > > though. > > > > Hmm you mean SLAB_ACCOUNT and SLAB_MAY_ACCOUNT should be cleared at > > run-time during merging decision with cgroup.memory=nokmem? > > Ah, not really. I mean, assuming kmem is enabled, before this patchset > all caches have SLAB_MAY_ACCOUNT. After applying it, some have the flag and > some don't, so `if ((flags & SLAB_MERGE_SAME) != (s->flags & SLAB_MERGE_SAME))` > in find_mergeable() might not hold anymore. Ah, I see. This is intentional and benign I think :-) We don't want to merge cache X and Y when only one of them has SLAB_MAY_ACCOUNT as that'll bloat metadata size. -- Cheers, Harry / Hyeonggon