From 0d5dc1d7aad144b6c561e72e96f3107d812c6026 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 1 Apr 2026 10:38:09 +0000 Subject: [PATCH] macvlan: avoid spinlock contention in macvlan_broadcast_enqueue() Under high stress, we spend a lot of time cloning skbs, then acquiring a spinlock, then freeing the clone because the queue is full. Add a shortcut to avoid these costs under pressure. Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20260401103809.3038139-3-edumazet@google.com Signed-off-by: Jakub Kicinski --- drivers/net/macvlan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index bbb5c32541f9..54c514acacc5 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -360,6 +360,9 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port, struct sk_buff *nskb; int err = -ENOMEM; + if (skb_queue_len_lockless(&port->bc_queue) >= bc_queue_len_used) + goto err; + nskb = skb_clone(skb, GFP_ATOMIC); if (!nskb) goto err; -- 2.47.3