[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251126023829.44946-6-tonghao@bamaicloud.com>
Date: Wed, 26 Nov 2025 10:38:29 +0800
From: Tonghao Zhang <tonghao@...aicloud.com>
To: netdev@...r.kernel.org
Cc: Tonghao Zhang <tonghao@...aicloud.com>,
Jay Vosburgh <jv@...sburgh.net>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>,
Jonathan Corbet <corbet@....net>,
Andrew Lunn <andrew+netdev@...n.ch>,
Nikolay Aleksandrov <razor@...ckwall.org>,
Hangbin Liu <liuhangbin@...il.com>,
Jason Xing <kerneljasonxing@...il.com>
Subject: [PATCH net-next v2 5/5] net: bonding: combine rtnl lock block for arp monitor in activebackup mode
Place all the arp monitor in a common critical section, to avoid requesting
rtnl lock frequently. Note that mii monitor also use the common critical
section. It should be noted that the bond_ab_arp_probe() sending probe arp
may be lost in this cycle, when committing link changed state. It is acceptable.
Cc: Jay Vosburgh <jv@...sburgh.net>
Cc: "David S. Miller" <davem@...emloft.net>
Cc: Eric Dumazet <edumazet@...gle.com>
Cc: Jakub Kicinski <kuba@...nel.org>
Cc: Paolo Abeni <pabeni@...hat.com>
Cc: Simon Horman <horms@...nel.org>
Cc: Jonathan Corbet <corbet@....net>
Cc: Andrew Lunn <andrew+netdev@...n.ch>
Cc: Nikolay Aleksandrov <razor@...ckwall.org>
Cc: Hangbin Liu <liuhangbin@...il.com>
Cc: Jason Xing <kerneljasonxing@...il.com>
Signed-off-by: Tonghao Zhang <tonghao@...aicloud.com>
---
drivers/net/bonding/bond_main.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 14396e39b1f0..2cfaac3edde0 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3757,7 +3757,7 @@ static bool bond_ab_arp_probe(struct bonding *bond)
static void bond_activebackup_arp_mon(struct bonding *bond)
{
- bool should_notify_rtnl;
+ bool should_notify_rtnl, commit;
int delta_in_ticks;
delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval);
@@ -3767,36 +3767,28 @@ static void bond_activebackup_arp_mon(struct bonding *bond)
rcu_read_lock();
- if (bond_ab_arp_inspect(bond)) {
- rcu_read_unlock();
-
- /* Race avoidance with bond_close flush of workqueue */
- if (!rtnl_trylock()) {
- delta_in_ticks = 1;
- goto re_arm;
- }
-
- bond_ab_arp_commit(bond);
-
- rtnl_unlock();
- rcu_read_lock();
- }
-
+ commit = !!bond_ab_arp_inspect(bond);
should_notify_rtnl = bond_ab_arp_probe(bond);
+
rcu_read_unlock();
- if (READ_ONCE(bond->send_peer_notif) || should_notify_rtnl) {
+ if (commit || READ_ONCE(bond->send_peer_notif) || should_notify_rtnl) {
+ /* Race avoidance with bond_close flush of workqueue */
if (!rtnl_trylock()) {
delta_in_ticks = 1;
goto re_arm;
}
+ if (commit)
+ bond_ab_arp_commit(bond);
+
if (bond->send_peer_notif) {
if (bond_should_notify_peers(bond))
call_netdevice_notifiers(NETDEV_NOTIFY_PEERS,
bond->dev);
bond->send_peer_notif--;
}
+
if (should_notify_rtnl) {
bond_slave_state_notify(bond);
bond_slave_link_notify(bond);
--
2.34.1
Powered by blists - more mailing lists