[PATCH slab/for-next 05/14] net: skbuff: specify SLAB_MAY_ACCOUNT for skbuff_head_cache

From: Harry Yoo (Meta)

Date: Wed Oct 21 2026 - 07:52:28 EST


AF_UNIX sets sk->sk_allocation to GFP_KERNEL_ACCOUNT, so skbs can be
allocated from skbuff_head_cache with __GFP_ACCOUNT. Specify
SLAB_MAY_ACCOUNT when the object may be charged to a memcg.
__GFP_ACCOUNT without SLAB_MAY_ACCOUNT will not be allowed.

Path: unix_dgram_sendmsg() -> sock_alloc_send_pskb(sk->sk_allocation)
-> alloc_skb_with_frags() -> __alloc_skb()
-> kmem_cache_alloc_node(skbuff_head_cache)

Assisted-by: LLM
Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
Cc: Simon Horman <horms@xxxxxxxxxx>
Cc: Jason Xing <kerneljasonxing@xxxxxxxxx>
Cc: Willem de Bruijn <willemb@xxxxxxxxxx>
Cc: Mina Almasry <almasrymina@xxxxxxxxxx>
Cc: "Björn Töpel" <bjorn@xxxxxxxxxx>
Cc: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Cc: Jiayuan Chen <jiayuan.chen@xxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
Signed-off-by: Harry Yoo (Meta) <harry@xxxxxxxxxx>
---
net/core/skbuff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 966af3beed94..34ebbaf04fc7 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5213,7 +5213,7 @@ void __init skb_init(void)
sizeof(struct sk_buff),
0,
SLAB_HWCACHE_ALIGN|SLAB_PANIC|
- FLAG_SKB_NO_MERGE,
+ SLAB_MAY_ACCOUNT|FLAG_SKB_NO_MERGE,
offsetof(struct sk_buff, cb),
sizeof_field(struct sk_buff, cb),
NULL);

--
2.54.0