public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] macvlan: broadcast delivery changes
@ 2026-04-01 10:38 Eric Dumazet
  2026-04-01 10:38 ` [PATCH net-next 1/2] macvlan: annotate data-races around port->bc_queue_len_used Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-04-01 10:38 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, Andrew Lunn, netdev, eric.dumazet, Eric Dumazet

First patch adds data-race annotations.

Second patch changes macvlan_broadcast_enqueue() to return
early if the queue is full.

Eric Dumazet (2):
  macvlan: annotate data-races around port->bc_queue_len_used
  macvlan: avoid spinlock contention in macvlan_broadcast_enqueue()

 drivers/net/macvlan.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

-- 
2.53.0.1118.gaef5881109-goog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 1/2] macvlan: annotate data-races around port->bc_queue_len_used
  2026-04-01 10:38 [PATCH net-next 0/2] macvlan: broadcast delivery changes Eric Dumazet
@ 2026-04-01 10:38 ` Eric Dumazet
  2026-04-01 10:38 ` [PATCH net-next 2/2] macvlan: avoid spinlock contention in macvlan_broadcast_enqueue() Eric Dumazet
  2026-04-03  1:10 ` [PATCH net-next 0/2] macvlan: broadcast delivery changes patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-04-01 10:38 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, Andrew Lunn, netdev, eric.dumazet, Eric Dumazet

port->bc_queue_len_used is read and written locklessly,
add READ_ONCE()/WRITE_ONCE() annotations.

While WRITE_ONCE() in macvlan_fill_info() is not yet needed,
it is a prereq for future RTNL avoidance.

Fixes: d4bff72c8401 ("macvlan: Support for high multicast packet rate")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 drivers/net/macvlan.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index ea22909cb09de43fbf26b16144430b4d6687de3e..bbb5c32541f996fdf97caa19d2c6d99e5c994a3d 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -356,6 +356,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
 				      const struct macvlan_dev *src,
 				      struct sk_buff *skb)
 {
+	u32 bc_queue_len_used = READ_ONCE(port->bc_queue_len_used);
 	struct sk_buff *nskb;
 	int err = -ENOMEM;
 
@@ -366,7 +367,7 @@ static void macvlan_broadcast_enqueue(struct macvlan_port *port,
 	MACVLAN_SKB_CB(nskb)->src = src;
 
 	spin_lock(&port->bc_queue.lock);
-	if (skb_queue_len(&port->bc_queue) < port->bc_queue_len_used) {
+	if (skb_queue_len(&port->bc_queue) < bc_queue_len_used) {
 		if (src)
 			dev_hold(src->dev);
 		__skb_queue_tail(&port->bc_queue, nskb);
@@ -1731,7 +1732,8 @@ static int macvlan_fill_info(struct sk_buff *skb,
 	}
 	if (nla_put_u32(skb, IFLA_MACVLAN_BC_QUEUE_LEN, vlan->bc_queue_len_req))
 		goto nla_put_failure;
-	if (nla_put_u32(skb, IFLA_MACVLAN_BC_QUEUE_LEN_USED, port->bc_queue_len_used))
+	if (nla_put_u32(skb, IFLA_MACVLAN_BC_QUEUE_LEN_USED,
+			READ_ONCE(port->bc_queue_len_used)))
 		goto nla_put_failure;
 	if (port->bc_cutoff != 1 &&
 	    nla_put_s32(skb, IFLA_MACVLAN_BC_CUTOFF, port->bc_cutoff))
@@ -1791,7 +1793,7 @@ static void update_port_bc_queue_len(struct macvlan_port *port)
 		if (vlan->bc_queue_len_req > max_bc_queue_len_req)
 			max_bc_queue_len_req = vlan->bc_queue_len_req;
 	}
-	port->bc_queue_len_used = max_bc_queue_len_req;
+	WRITE_ONCE(port->bc_queue_len_used, max_bc_queue_len_req);
 }
 
 static int macvlan_device_event(struct notifier_block *unused,
-- 
2.53.0.1118.gaef5881109-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/2] macvlan: avoid spinlock contention in macvlan_broadcast_enqueue()
  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
  2026-04-03  1:10 ` [PATCH net-next 0/2] macvlan: broadcast delivery changes patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-04-01 10:38 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, Andrew Lunn, netdev, eric.dumazet, Eric Dumazet

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 0/2] macvlan: broadcast delivery changes
  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 ` [PATCH net-next 2/2] macvlan: avoid spinlock contention in macvlan_broadcast_enqueue() Eric Dumazet
@ 2026-04-03  1:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-04-03  1:10 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, horms, andrew+netdev, netdev, eric.dumazet

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  1 Apr 2026 10:38:07 +0000 you wrote:
> First patch adds data-race annotations.
> 
> Second patch changes macvlan_broadcast_enqueue() to return
> early if the queue is full.
> 
> Eric Dumazet (2):
>   macvlan: annotate data-races around port->bc_queue_len_used
>   macvlan: avoid spinlock contention in macvlan_broadcast_enqueue()
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] macvlan: annotate data-races around port->bc_queue_len_used
    https://git.kernel.org/netdev/net-next/c/1ef5789d9906
  - [net-next,2/2] macvlan: avoid spinlock contention in macvlan_broadcast_enqueue()
    https://git.kernel.org/netdev/net-next/c/0d5dc1d7aad1

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-03  1:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH net-next 2/2] macvlan: avoid spinlock contention in macvlan_broadcast_enqueue() Eric Dumazet
2026-04-03  1:10 ` [PATCH net-next 0/2] macvlan: broadcast delivery changes patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox