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 4/4] net: bonding: add the READ_ONCE/WRITE_ONCE for outside lock accessing
Date: Mon, 12 Jan 2026 08:52:43 +0000 [thread overview]
Message-ID: <aWS2W27L3MbZMK1T@fedora> (raw)
In-Reply-To: <5bf134412fd558dc80fbf97a149964f536a59cb7.1768184929.git.tonghao@bamaicloud.com>
On Mon, Jan 12, 2026 at 10:40:51AM +0800, Tonghao Zhang wrote:
> Although operations on the variable send_peer_notif are already within
> a lock-protected critical section, there are cases where it is accessed
> outside the lock. Therefore, READ_ONCE() and WRITE_ONCE() should be
> added to it.
>
> 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>
> ---
> v3/4:
> - no change
> v2: fix compilation errors
> ---
> drivers/net/bonding/bond_main.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index b835f63d2871..909c01f55744 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1204,8 +1204,9 @@ void bond_peer_notify_work_rearm(struct bonding *bond, unsigned long delay)
> /* Peer notify update handler. Holds only RTNL */
> static void bond_peer_notify_reset(struct bonding *bond)
> {
> - bond->send_peer_notif = bond->params.num_peer_notif *
> - max(1, bond->params.peer_notif_delay);
> + WRITE_ONCE(bond->send_peer_notif,
> + bond->params.num_peer_notif *
> + max(1, bond->params.peer_notif_delay));
> }
>
> static void bond_peer_notify_handler(struct work_struct *work)
> @@ -2825,7 +2826,7 @@ static void bond_mii_monitor(struct work_struct *work)
>
> rcu_read_unlock();
>
> - if (commit || bond->send_peer_notif) {
> + if (commit || READ_ONCE(bond->send_peer_notif)) {
> /* Race avoidance with bond_close cancel of workqueue */
> if (!rtnl_trylock()) {
> delay = 1;
> @@ -3784,7 +3785,7 @@ static void bond_activebackup_arp_mon(struct bonding *bond)
> should_notify_rtnl = bond_ab_arp_probe(bond);
> rcu_read_unlock();
>
> - if (bond->send_peer_notif || should_notify_rtnl) {
> + if (READ_ONCE(bond->send_peer_notif) || should_notify_rtnl) {
> if (!rtnl_trylock()) {
> delta_in_ticks = 1;
> goto re_arm;
> --
> 2.34.1
>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
next prev parent reply other threads:[~2026-01-12 8:52 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
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 [this message]
-- 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
2025-12-29 9:50 ` [PATCH net-next v4 4/4] net: bonding: add the READ_ONCE/WRITE_ONCE for outside lock accessing Tonghao Zhang
2026-01-03 9:49 ` [PATCH RESEND " 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=aWS2W27L3MbZMK1T@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox