From: Hangbin Liu <liuhangbin@gmail.com>
To: Tonghao Zhang <tonghao@bamaicloud.com>
Cc: netdev@vger.kernel.org, Jay Vosburgh <jv@jvosburgh.net>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Nikolay Aleksandrov <razor@blackwall.org>,
Jason Xing <kerneljasonxing@gmail.com>
Subject: Re: [PATCH net-next v3 3/4] net: bonding: skip the 2nd trylock when first one fail
Date: Mon, 1 Dec 2025 07:35:25 +0000 [thread overview]
Message-ID: <aS1FPdC98q6wxviG@fedora> (raw)
In-Reply-To: <20251130074846.36787-4-tonghao@bamaicloud.com>
On Sun, Nov 30, 2025 at 03:48:45PM +0800, Tonghao Zhang wrote:
> 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>
> ---
> v1:
> - splitted from: https://patchwork.kernel.org/project/netdevbpf/patch/20251118090431.35654-1-tonghao@bamaicloud.com/
> - this patch only skip the 2nd rtnl lock.
> - add this patch to series
> ---
> drivers/net/bonding/bond_main.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 1b16c4cd90e0..025ca0a45615 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -3756,7 +3756,7 @@ static bool bond_ab_arp_probe(struct bonding *bond)
>
> 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);
> @@ -3784,13 +3784,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) {
> if (bond_should_notify_peers(bond))
> @@ -3805,6 +3803,10 @@ static void bond_activebackup_arp_mon(struct bonding *bond)
>
> 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)
> --
> 2.34.1
>
Maybe this patch should be merged together with patch 02, since the issue
was introduced there. Before patch 02, both should_notify_peers and
should_notify_rtnl would be false when the first rtnl_trylock() failed,
so the second trylock() would never be called.
Thanks
Hangbin
next prev parent reply other threads:[~2025-12-01 7:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-30 7:48 [PATCH net-next v3 0/4] A series of minor optimizations of the bonding module Tonghao Zhang
2025-11-30 7:48 ` [PATCH net-next v3 1/4] net: bonding: use workqueue to make sure peer notify updated in lacp mode Tonghao Zhang
2025-12-01 6:57 ` Hangbin Liu
2025-12-01 9:45 ` Tonghao Zhang
2025-12-01 10:05 ` Hangbin Liu
2025-12-01 11:01 ` Tonghao Zhang
2025-12-01 13:56 ` Hangbin Liu
2025-12-22 13:53 ` Tonghao Zhang
2025-11-30 7:48 ` [PATCH net-next v3 2/4] net: bonding: move bond_should_notify_peers, e.g. into rtnl lock block Tonghao Zhang
2025-12-01 7:23 ` Hangbin Liu
2025-12-02 1:54 ` Jason Xing
2025-12-22 14:24 ` Tonghao Zhang
2025-11-30 7:48 ` [PATCH net-next v3 3/4] net: bonding: skip the 2nd trylock when first one fail Tonghao Zhang
2025-12-01 7:35 ` Hangbin Liu [this message]
2025-12-22 14:15 ` Tonghao Zhang
2025-12-24 6:00 ` Hangbin Liu
2025-11-30 7:48 ` [PATCH net-next v3 4/4] net: bonding: add the READ_ONCE/WRITE_ONCE for outside lock accessing Tonghao Zhang
2025-12-01 7:43 ` Hangbin Liu
2025-12-01 7:24 ` [PATCH net-next v3 0/4] A series of minor optimizations of the bonding module Hangbin Liu
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=aS1FPdC98q6wxviG@fedora \
--to=liuhangbin@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jv@jvosburgh.net \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=tonghao@bamaicloud.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.