From 6471658dc66c670580a7616e75f51b52917e7883 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 16 Sep 2025 16:09:51 +0000 Subject: [PATCH] udp: use skb_attempt_defer_free() Move skb freeing from udp recvmsg() path to the cpu which allocated/received it, as TCP did in linux-5.17. This increases max thoughput by 20% to 30%, depending on number of BH producers. Signed-off-by: Eric Dumazet Acked-by: Willem de Bruijn Reviewed-by: David Ahern Reviewed-by: Kuniyuki Iwashima Link: https://patch.msgid.link/20250916160951.541279-11-edumazet@google.com Reviewed-by: Jakub Kicinski Signed-off-by: Paolo Abeni --- net/ipv4/udp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 7d1444821ee5..0c40426628eb 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1825,6 +1825,13 @@ void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len) if (unlikely(READ_ONCE(udp_sk(sk)->peeking_with_offset))) sk_peek_offset_bwd(sk, len); + if (!skb_shared(skb)) { + if (unlikely(udp_skb_has_head_state(skb))) + skb_release_head_state(skb); + skb_attempt_defer_free(skb); + return; + } + if (!skb_unref(skb)) return; -- 2.51.0