* [PATCH v1 net-next] bonding: Optimise is_netpoll_tx_blocked().
@ 2026-02-23 23:07 Kuniyuki Iwashima
2026-02-25 1:42 ` Eric Dumazet
2026-02-25 4:09 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Kuniyuki Iwashima @ 2026-02-23 23:07 UTC (permalink / raw)
To: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
bond_start_xmit() spends some cycles in is_netpoll_tx_blocked():
if (unlikely(is_netpoll_tx_blocked(dev)))
return NETDEV_TX_BUSY;
because of the "pushf;pop reg" sequence (aka irqs_disabled()).
Let's swap the conditions in is_netpoll_tx_blocked() and
convert netpoll_block_tx to a static key.
Before:
1.23 │ mov %gs:0x28,%rax
1.24 │ mov %rax,0x18(%rsp)
29.45 │ pushfq
0.50 │ pop %rax
0.47 │ test $0x200,%eax
│ ↓ je 1b4
0.49 │ 32: lea 0x980(%rsi),%rbx
After:
0.72 │ mov %gs:0x28,%rax
0.81 │ mov %rax,0x18(%rsp)
0.82 │ nop
2.77 │ 2a: lea 0x980(%rsi),%rbx
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
drivers/net/bonding/bond_main.c | 4 ++--
include/net/bonding.h | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 55a960da42b5..2f2dddcf9d30 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -206,7 +206,7 @@ MODULE_PARM_DESC(lp_interval, "The number of seconds between instances where "
/*----------------------------- Global variables ----------------------------*/
#ifdef CONFIG_NET_POLL_CONTROLLER
-atomic_t netpoll_block_tx = ATOMIC_INIT(0);
+DEFINE_STATIC_KEY_FALSE(netpoll_block_tx);
#endif
unsigned int bond_net_id __read_mostly;
@@ -6589,7 +6589,7 @@ static void __exit bonding_exit(void)
#ifdef CONFIG_NET_POLL_CONTROLLER
/* Make sure we don't have an imbalance on our netpoll blocking */
- WARN_ON(atomic_read(&netpoll_block_tx));
+ WARN_ON(static_branch_unlikely(&netpoll_block_tx));
#endif
}
diff --git a/include/net/bonding.h b/include/net/bonding.h
index 4ad5521e7731..7f8fda2fdfcb 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -91,22 +91,22 @@
NETIF_F_GSO_ESP)
#ifdef CONFIG_NET_POLL_CONTROLLER
-extern atomic_t netpoll_block_tx;
+DECLARE_STATIC_KEY_FALSE(netpoll_block_tx);
static inline void block_netpoll_tx(void)
{
- atomic_inc(&netpoll_block_tx);
+ static_branch_inc(&netpoll_block_tx);
}
static inline void unblock_netpoll_tx(void)
{
- atomic_dec(&netpoll_block_tx);
+ static_branch_dec(&netpoll_block_tx);
}
static inline int is_netpoll_tx_blocked(struct net_device *dev)
{
- if (unlikely(netpoll_tx_running(dev)))
- return atomic_read(&netpoll_block_tx);
+ if (static_branch_unlikely(&netpoll_block_tx))
+ return netpoll_tx_running(dev);
return 0;
}
#else
--
2.53.0.414.gf7e9f6c205-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1 net-next] bonding: Optimise is_netpoll_tx_blocked().
2026-02-23 23:07 [PATCH v1 net-next] bonding: Optimise is_netpoll_tx_blocked() Kuniyuki Iwashima
@ 2026-02-25 1:42 ` Eric Dumazet
2026-02-25 4:09 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2026-02-25 1:42 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: Jay Vosburgh, Andrew Lunn, David S. Miller, Jakub Kicinski,
Paolo Abeni, Simon Horman, Kuniyuki Iwashima, netdev
On Tue, Feb 24, 2026 at 12:07 AM Kuniyuki Iwashima <kuniyu@google.com> wrote:
>
> bond_start_xmit() spends some cycles in is_netpoll_tx_blocked():
>
> if (unlikely(is_netpoll_tx_blocked(dev)))
> return NETDEV_TX_BUSY;
>
> because of the "pushf;pop reg" sequence (aka irqs_disabled()).
>
> Let's swap the conditions in is_netpoll_tx_blocked() and
> convert netpoll_block_tx to a static key.
>
> Suggested-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1 net-next] bonding: Optimise is_netpoll_tx_blocked().
2026-02-23 23:07 [PATCH v1 net-next] bonding: Optimise is_netpoll_tx_blocked() Kuniyuki Iwashima
2026-02-25 1:42 ` Eric Dumazet
@ 2026-02-25 4:09 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-25 4:09 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: jv, andrew+netdev, davem, edumazet, kuba, pabeni, horms, kuni1840,
netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 23 Feb 2026 23:07:18 +0000 you wrote:
> bond_start_xmit() spends some cycles in is_netpoll_tx_blocked():
>
> if (unlikely(is_netpoll_tx_blocked(dev)))
> return NETDEV_TX_BUSY;
>
> because of the "pushf;pop reg" sequence (aka irqs_disabled()).
>
> [...]
Here is the summary with links:
- [v1,net-next] bonding: Optimise is_netpoll_tx_blocked().
https://git.kernel.org/netdev/net-next/c/fc1f97929ada
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] 3+ messages in thread
end of thread, other threads:[~2026-02-25 4:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 23:07 [PATCH v1 net-next] bonding: Optimise is_netpoll_tx_blocked() Kuniyuki Iwashima
2026-02-25 1:42 ` Eric Dumazet
2026-02-25 4:09 ` 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