From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next 2/2] macvlan: avoid spinlock contention in macvlan_broadcast_enqueue()
Date: Wed, 1 Apr 2026 10:38:09 +0000 [thread overview]
Message-ID: <20260401103809.3038139-3-edumazet@google.com> (raw)
In-Reply-To: <20260401103809.3038139-1-edumazet@google.com>
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>
---
drivers/net/macvlan.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index bbb5c32541f996fdf97caa19d2c6d99e5c994a3d..54c514acacc5e24fcdb88904f41fd1d29b1e34d0 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.53.0.1118.gaef5881109-goog
next prev parent reply other threads:[~2026-04-01 10:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 10:38 [PATCH net-next 0/2] macvlan: broadcast delivery changes Eric Dumazet
2026-04-01 10:38 ` [PATCH net-next 1/2] macvlan: annotate data-races around port->bc_queue_len_used Eric Dumazet
2026-04-01 10:38 ` Eric Dumazet [this message]
2026-04-03 1:10 ` [PATCH net-next 0/2] macvlan: broadcast delivery changes patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260401103809.3038139-3-edumazet@google.com \
--to=edumazet@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox