From: Kees Cook <kees@kernel.org>
To: Vlastimil Babka <vbabka@kernel.org>
Cc: Kees Cook <kees@kernel.org>, Harry Yoo <harry@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Andrew Morton <akpm@linux-foundation.org>,
Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Pedro Falcato <pfalcato@suse.de>,
Kuniyuki Iwashima <kuniyu@google.com>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Shakeel Butt <shakeel.butt@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Willem de Bruijn <willemb@google.com>,
Jason Xing <kerneljasonxing@gmail.com>,
cgroups@vger.kernel.org, netdev@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: [PATCH net-next v6 0/8] net: skb: isolate skb data area allocations into a separate bucket
Date: Tue, 6 Oct 2026 02:20:26 -0700 [thread overview]
Message-ID: <20261006092030.got.500-kees@kernel.org> (raw)
Hi!
This gets the buckets able to handle memcg (GFP_KERNEL_ACCOUNT) with
isolation (since it's common due to AF_UNIX), and GFP_DMA with fall back
(since it's rare). It gave me an excuse to build out bucket kunit tests
too, and that (and LLM review) found a couple other issues that needed
fixing too, including msg_msg allocations going uncharged to their memcg
when CONFIG_SLAB_BUCKETS=n (fixed in 2/8).
Harry, on your v4 question[1] about bucket users giving their own
alignment: I tried that in v5, but a set's allocations don't always
come from its own caches. With CONFIG_SLAB_BUCKETS=n, after a failed
kmem_buckets_create(), and for the DMA and reclaimable fallbacks, they
come from the general kmalloc caches, which can only give kmalloc()'s
alignment. So v6 goes back to mirroring the kmalloc cache's alignment,
and drops the ctor and flags arguments for the same reason. And the whole
exploration made me realize I had a completely wrong understanding of
how memcg worked. :P
The bulk of this is mm/slab, but the final patch is netdev, which Paolo
acked in v4, so I'm hoping this whole series can go via slab?
Thanks!
-Kees
v6:
- drop v5's 6/7 ("Let a bucket set handle __GFP_ACCOUNT") and its
kmem_buckets_create_types(): memcg charges each object in whatever
cache serves it, so accounted allocations can stay in a set's single
row of caches, and the fallback now covers only DMA, reclaimable, and
no-obj-ext allocations (Sashiko)
- 2/8: new: account msg_msg with GFP_KERNEL_ACCOUNT again; with
CONFIG_SLAB_BUCKETS=n it went uncharged, since its accounting lived in
SLAB_ACCOUNT on bucket caches that are not created (Sashiko)
- 3/8: new: drop the ctor and flags arguments from kmem_buckets_create();
neither reaches allocations that fall back to the general kmalloc
caches, and no caller needs them any more (Sashiko)
- 4/8: go back to v4's form: no alignment argument, and each bucket cache
takes the alignment of the kmalloc cache it mirrors, since the fallbacks
to kmalloc can give no other (Sashiko, Harry)
- 5/8: say in the teardown comment that cache sharing comes from kmalloc
rounding sizes up to a larger class (Sashiko)
- 6/8: drop the explicit alignment tests; check that each size lands in
the cache of the size kmalloc() rounds it up to, not just a big enough
one; and in the destroy test, assert on the allocation, skip when KFENCE
serves it, and tear the set down through its KUnit cleanup action
(Sashiko)
- 7/8: keep __GFP_ACCOUNT allocations in the set, document what an
allocation that falls back loses, and test the reclaimable fallback
(Sashiko)
- 8/8: create the skb_data set with kmem_buckets_create(), and make the
comment above kmalloc_reserve() name no allocator (Sashiko)
- v5..v6 diff: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/diff/?id=dev/v7.3-rc2/skb-buckets/v6&id2=dev/v7.3-rc2/skb-buckets/v5
v5: https://lore.kernel.org/all/20261002231120.late.500-kees@kernel.org/
v4: https://lore.kernel.org/all/20260921075811.too.775-kees@kernel.org/
v3: https://lore.kernel.org/all/20260702170728.168755-1-pfalcato@suse.de/
[1] https://lore.kernel.org/all/arViR2Miz61-3fV4@thinkstation/
Kees Cook (7):
mm/slab: Mark the kmem_buckets_create() context as a Context: section
ipc, msg: Account msg_msg allocations with GFP_KERNEL_ACCOUNT again
mm/slab: Drop the ctor and flags arguments from kmem_buckets_create()
mm/slab: Give bucket caches the alignment of the caches they mirror
mm/slab: Add kmem_buckets_destroy()
mm/slab: Add tests for the existing kmem_buckets behaviour
mm/slab: Provide kmalloc type fallback for bucket allocations
Pedro Falcato (1):
net: skb: isolate skb data area allocations into a separate bucket
include/linux/slab.h | 6 +-
mm/slab.h | 19 ++-
ipc/msgutil.c | 8 +-
lib/tests/slub_kunit.c | 291 +++++++++++++++++++++++++++++++++++++++++
mm/slab_common.c | 74 ++++++++---
mm/util.c | 2 +-
net/core/skbuff.c | 10 +-
7 files changed, 378 insertions(+), 32 deletions(-)
--
2.55.0
next reply other threads:[~2026-10-06 9:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 9:20 Kees Cook [this message]
2026-10-06 9:20 ` [PATCH net-next v6 1/8] mm/slab: Mark the kmem_buckets_create() context as a Context: section Kees Cook
2026-10-06 9:20 ` [PATCH net-next v6 2/8] ipc, msg: Account msg_msg allocations with GFP_KERNEL_ACCOUNT again Kees Cook
2026-10-06 9:20 ` [PATCH net-next v6 3/8] mm/slab: Drop the ctor and flags arguments from kmem_buckets_create() Kees Cook
2026-10-06 9:20 ` [PATCH net-next v6 4/8] mm/slab: Give bucket caches the alignment of the caches they mirror Kees Cook
2026-10-06 9:20 ` [PATCH net-next v6 5/8] mm/slab: Add kmem_buckets_destroy() Kees Cook
2026-10-06 9:20 ` [PATCH net-next v6 6/8] mm/slab: Add tests for the existing kmem_buckets behaviour Kees Cook
2026-10-06 9:20 ` [PATCH net-next v6 7/8] mm/slab: Provide kmalloc type fallback for bucket allocations Kees Cook
2026-10-06 9:20 ` [PATCH net-next v6 8/8] net: skb: isolate skb data area allocations into a separate bucket Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261006092030.got.500-kees@kernel.org \
--to=kees@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=cl@gentwo.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hannes@cmpxchg.org \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=horms@kernel.org \
--cc=jack@suse.cz \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pfalcato@suse.de \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=vbabka@kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®