Article View: linux.kernel.netdev
Article #26433Re: [PATCH slab/for-next v2 14/14] mm/slab: do not set SLAB_MAY_ACCOUNT for all caches
From: Harry Yoo
Date: Thu, 03 Dec 2026 14:46
Date: Thu, 03 Dec 2026 14:46
53 lines
11823 bytes
11823 bytes
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) <harry@kernel.org> > > > > --- > > > > 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
Technical Details
Message-ID:
<axF_9PFvl-Ypa9dD@thinkstation>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376673-linux-kernel-netdev=dewy.ruReferences:
<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> <axF1jxUBKq0Y00tw@fedora> <axF7O_lIG4zf9L-9@thinkstation> <axF9JUMywglaob8D@fedora>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376673-linux-kernel-netdev=dewy.ru From: harry@kernel.org (Harry Yoo) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH slab/for-next v2 14/14] mm/slab: do not set SLAB_MAY_ACCOUNT for all caches Date: Thu, 3 Dec 2026 14:46:49 +0000 Organization: Usenet Network Message-ID: <axF_9PFvl-Ypa9dD@thinkstation> 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> <axF1jxUBKq0Y00tw@fedora> <axF7O_lIG4zf9L-9@thinkstation> <axF9JUMywglaob8D@fedora> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="2517497"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:FpexhjXfOg1VPwp6tb2OnpMDino= sha256:fldWWc8taNX5BXLQdUuwOwDFZG4SjpB3GPbhWCF847U= sha1:8ff6PY9dnHAIwFh9mZ88VkzIclQ= sha256:OHkcmtOZRWX+sk52EXVuzhXp9eWSxSqhjARslgu6o50= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 42C2F11798B; Thu, 3 Dec 2026 17:47:08 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.74 X-Spam-Status: No, score=-3.74 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8Xh7EAvm5726; Thu, 3 Dec 2026 17:47:05 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376673-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 5AD3511796D; Thu, 3 Dec 2026 17:46:56 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id D07D02505A; Thu, 3 Dec 2026 14:46:54 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796309212; b=VKggj+vDXXIFWhKhKGc4BoEbMsJaSQU7sVKf2tXt8u5YWhcyjW9Ay5b84goTE00ULjt7 FdDOK1PlnKb9u0iFa7brsAtFs4rpIhZ8CYYeElsAJShjXAOVdqdRgI8LATzvt9NLvwn9B 4G8BSdSqnGFKltN25vazQC9qbF2O1lag6MgJGk6Uvi9LykGYcJBCdhalElapLI6EMq1gc RJjYAtOX5JZWZx+7gRc1uOtIlE/b2Y1OMmUvHb88p1szIaj6oUnnNPJgTR6LZYabArbTe x30ALGniPXyHYceBq1kB8XckONX88CRJRfOOpeLg2RgvkHWAiv11A+qRZTh4iVlplOQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309212; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=6EWUztHmhiTkBrcqDZ+f7uLODjWFek2K7WQ2yJoUw3g=; b=SUJaC4jgy3bhTdmHic9Vb3fwuo/YpznvufjpCCOARLiJQ4rZiGKygwpqZhBzZgIfhcXi VyvaPZJbBVKH+Kc5EZbOx8OD91tqzHMK6/o2I2PXDoxpxJEBn/z4Ol0yHbmk7pHLrGPjo l97M0clKjpB5UBYYc5wRwLQ6vz+bd9rKdAwWVCFme2mdLu2nKDq30ZzqMRGbZ92/VNRo9 ZF7rrF/guF+BE1XNBWjhScE87lUKpTolpHMILnJOUUhP9sLhLEAoE8h4e9IPOZ+bxkITz uuMCsQ0dBALAdTuuCK2JidEvEx9X5jmrRtg9AkIsql/dHGYXR4TDCevL/oQ7626V8Kw== X-ARC-Authentication-Results: i=2; 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=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A27D606A338; Thu, 3 Dec 2026 14:46:52 +0000 (UTC) X-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 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-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== X-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== X-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 X-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) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71DF91F00893; Thu, 3 Dec 2026 14:46:50 +0000 (UTC) X-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== X-Cc: Vlastimil Babka <vbabka@kernel.org>, Andrew Morton <akpm@linux-foundation.org>, Suren Baghdasaryan <surenb@google.com>, Johannes Weiner <hannes@cmpxchg.org>, Michal Hocko <mhocko@kernel.org>, Shakeel Butt <shakeel.butt@linux.dev>, Roman Gushchin <roman.gushchin@linux.dev>, Christoph Lameter <cl@gentwo.org>, David Rientjes <rientjes@google.com>, Muchun Song <muchun.song@linux.dev>, Hao Ge <hao.ge@linux.dev>, Pedro Falcato <pfalcato@suse.de>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, "Liam R. Howlett" <liam@infradead.org>, Alice Ryhl <aliceryhl@google.com>, Andrew Ballance <andrewjballance@gmail.com>, Matthew Wilcox <willy@infradead.org>, linux-fsdevel@vger.kernel.org, Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>, "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Jiayuan Chen <jiayuan.chen@linux.dev>, netdev@vger.kernel.org, Kees Cook <kees@kernel.org>, David Hildenbrand <david@kernel.org>, Lorenzo Stoakes <ljs@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Madhavan Srinivasan <maddy@linux.ibm.com>, Michael Ellerman <mpe@ellerman.id.au>, Nicholas Piggin <npiggin@gmail.com>, Robin Murphy <robin.murphy@arm.com>, "Joerg Roedel (AMD)" <joro@8bytes.org>, Amir Goldstein <amir73il@gmail.com>, Casey Schaufler <casey@schaufler-ca.com>, Paul Moore <paul@paul-moore.com>, James Morris <jmorris@namei.org>, "Serge E. Hallyn" <serge@hallyn.com>, linux-security-module@vger.kernel.org, Richard Weinberger <richard@nod.at>, Anton Ivanov <anton.ivanov@cambridgegreys.com>, Johannes Berg <johannes@sipsolutions.net>, Eric Dumazet <edumazet@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <axF9JUMywglaob8D@fedora>