]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ipvlan: avoid spinlock contention in ipvlan_multicast_enqueue()
authorEric Dumazet <edumazet@google.com>
Thu, 9 Apr 2026 08:52:38 +0000 (08:52 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sun, 12 Apr 2026 16:05:54 +0000 (09:05 -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, as we did
in macvlan with commit 0d5dc1d7aad1 ("macvlan: avoid spinlock
contention in macvlan_broadcast_enqueue()")

Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260409085238.1122947-3-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ipvlan/ipvlan_core.c

index 214fd299a5aa6e40579aa2dbcb178b5474b561a4..1be8620ad3971d281fb36fd0770efd67b566ae60 100644 (file)
@@ -763,10 +763,16 @@ static rx_handler_result_t ipvlan_handle_mode_l2(struct sk_buff **pskb,
        if (!ipvlan_external_frame(skb, port))
                return RX_HANDLER_PASS;
 
-       nskb = skb_clone(skb, GFP_ATOMIC);
+       if (skb_queue_len_lockless(&port->backlog) >= IPVLAN_QBACKLOG_LIMIT)
+               nskb = NULL;
+       else
+               nskb = skb_clone(skb, GFP_ATOMIC);
+
        if (nskb) {
                ipvlan_skb_crossing_ns(nskb, NULL);
                ipvlan_multicast_enqueue(port, nskb, false);
+       } else {
+               dev_core_stats_rx_dropped_inc(skb->dev);
        }
 
        return RX_HANDLER_PASS;