]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: bonding: skip the 2nd trylock when first one fail
authorTonghao Zhang <tonghao@bamaicloud.com>
Sun, 18 Jan 2026 04:21:13 +0000 (12:21 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 22 Jan 2026 10:20:33 +0000 (11:20 +0100)
After the first trylock fail, retrying immediately is
not advised as there is a high probability of failing
to acquire the lock again. This optimization makes sense.

Cc: Jay Vosburgh <jv@jvosburgh.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>
Cc: Nikolay Aleksandrov <razor@blackwall.org>
Cc: Hangbin Liu <liuhangbin@gmail.com>
Cc: Jason Xing <kerneljasonxing@gmail.com>
Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://patch.msgid.link/9aba44f02163e8fe8dbaba63ff2df921bc2b114e.1768709239.git.tonghao@bamaicloud.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/bonding/bond_main.c

index 16418e1dc10ab900163b0da03f4f3efbed0fea6b..98f391ac761f8b2fad32338ce07e0d4f7737a89a 100644 (file)
@@ -3759,7 +3759,7 @@ check_state:
 
 static void bond_activebackup_arp_mon(struct bonding *bond)
 {
-       bool should_notify_rtnl = false;
+       bool should_notify_rtnl;
        int delta_in_ticks;
 
        delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval);
@@ -3787,13 +3787,11 @@ static void bond_activebackup_arp_mon(struct bonding *bond)
        should_notify_rtnl = bond_ab_arp_probe(bond);
        rcu_read_unlock();
 
-re_arm:
-       if (bond->params.arp_interval)
-               queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks);
-
        if (bond->send_peer_notif || should_notify_rtnl) {
-               if (!rtnl_trylock())
-                       return;
+               if (!rtnl_trylock()) {
+                       delta_in_ticks = 1;
+                       goto re_arm;
+               }
 
                if (bond->send_peer_notif)
                        bond_peer_notify_may_events(bond, true);
@@ -3805,6 +3803,10 @@ re_arm:
 
                rtnl_unlock();
        }
+
+re_arm:
+       if (bond->params.arp_interval)
+               queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks);
 }
 
 static void bond_arp_monitor(struct work_struct *work)