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 RESEND net-next v4 3/4] net: bonding: skip the 2nd trylock when first one fail
Date: Mon, 12 Jan 2026 08:49:17 +0000 [thread overview]
Message-ID: <aWS1jST2907AGCLi@fedora> (raw)
In-Reply-To: <e90a599a58a3738d69a2b879f31871afa223d7ab.1768184929.git.tonghao@bamaicloud.com>
On Mon, Jan 12, 2026 at 10:40:50AM +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>
> ---
> v2-4:
> - no change
> 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 8be7f52e847c..b835f63d2871 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
>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
next prev parent reply other threads:[~2026-01-12 8:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 2:40 [PATCH RESEND net-next v4 0/4] A series of minor optimizations of the bonding module Tonghao Zhang
2026-01-12 2:40 ` [PATCH RESEND net-next v4 1/4] net: bonding: use workqueue to make sure peer notify updated in lacp mode Tonghao Zhang
2026-01-12 8:28 ` Hangbin Liu
2026-01-15 10:46 ` Paolo Abeni
2026-01-16 2:45 ` Tonghao Zhang
2026-01-12 2:40 ` [PATCH RESEND net-next v4 2/4] net: bonding: move bond_should_notify_peers, e.g. into rtnl lock block Tonghao Zhang
2026-01-12 2:40 ` [PATCH RESEND net-next v4 3/4] net: bonding: skip the 2nd trylock when first one fail Tonghao Zhang
2026-01-12 8:49 ` Hangbin Liu [this message]
2026-01-12 2:40 ` [PATCH RESEND net-next v4 4/4] net: bonding: add the READ_ONCE/WRITE_ONCE for outside lock accessing Tonghao Zhang
2026-01-12 8:52 ` Hangbin Liu
-- strict thread matches above, loose matches on Subject: below --
2025-12-29 9:50 [PATCH net-next v4 0/4] A series of minor optimizations of the bonding module Tonghao Zhang
2026-01-03 9:49 ` [PATCH RESEND net-next v4 3/4] net: bonding: skip the 2nd trylock when first one fail Tonghao Zhang
2026-01-03 9:49 ` Tonghao Zhang
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=aWS1jST2907AGCLi@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.