]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
macvlan: avoid spinlock contention in macvlan_broadcast_enqueue()
authorEric Dumazet <edumazet@google.com>
Wed, 1 Apr 2026 10:38:09 +0000 (10:38 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 3 Apr 2026 00:56:35 +0000 (17:56 -0700)
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 <edumazet@google.com>
Link: https://patch.msgid.link/20260401103809.3038139-3-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/macvlan.c

index bbb5c32541f996fdf97caa19d2c6d99e5c994a3d..54c514acacc5e24fcdb88904f41fd1d29b1e34d0 100644 (file)
@@ -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;