public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
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 v5 1/4] net: bonding: use workqueue to make sure peer notify updated in lacp mode
Date: Thu, 22 Jan 2026 04:33:09 +0000	[thread overview]
Message-ID: <aXGohVBmvaYIYt2w@fedora> (raw)
In-Reply-To: <f95accb5db0b10ce3ed2f834fc70f716c9abbb9c.1768709239.git.tonghao@bamaicloud.com>

On Sun, Jan 18, 2026 at 12:21:11PM +0800, Tonghao Zhang wrote:
> The rtnl lock might be locked, preventing ad_cond_set_peer_notif() from
> acquiring the lock and updating send_peer_notif. This patch addresses
> the issue by using a workqueue. Since updating send_peer_notif does
> not require high real-time performance, such delayed updates are entirely
> acceptable.
> 
> In fact, checking this value and using it in multiple places, all operations
> are protected at the same time by rtnl lock, such as
> - read send_peer_notif
> - send_peer_notif--
> - bond_should_notify_peers
> 
> By the way, rtnl lock is still required, when accessing bond.params.* for
> updating send_peer_notif. In lacp mode, resetting send_peer_notif in
> workqueue is safe, simple and effective way.
> 
> Additionally, this patch introduces bond_peer_notify_may_events(), which
> is used to check whether an event should be sent. This function will be
> used in both patch 1 and 2.
> 
> 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>
> Suggested-by: Hangbin Liu <liuhangbin@gmail.com>
> Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
> ---
> v5:
> - introduce the common bond_peer_notify_may_events used in patch 1 and 2.
> v4:
> - keep the netdevice notifier order.
> v2/3:
> - no change
> v1:
> - This patch is actually version v3, https://patchwork.kernel.org/project/netdevbpf/patch/20251118090305.35558-1-tonghao@bamaicloud.com/
> - add a comment why we use the trylock.
> - add this patch to series
> ---
>  drivers/net/bonding/bond_3ad.c  |  7 +---
>  drivers/net/bonding/bond_main.c | 66 ++++++++++++++++++++++++++-------
>  include/net/bonding.h           |  2 +
>  3 files changed, 56 insertions(+), 19 deletions(-)

[...]

> 
> +/* Peer notify events post. Holds only RTNL */
> +static void bond_peer_notify_may_events(struct bonding *bond, bool force)
> +{
> +	bool notified = false;
> +
> +	if (bond_should_notify_peers(bond)) {
> +		notified = true;
> +		call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev);
> +	}
> +
> +	if (notified || force)
> +		bond->send_peer_notif--;
> +}

If there is a new version, maybe change the logic to

static void bond_peer_notify_may_events(struct bonding *bond, bool force)
{
        bool do_notify = bond_should_notify_peers(bond);

        if (do_notify)
                call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev);

        if (do_notify || force)
                bond->send_peer_notif--;
}


Others looks good to me.

Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>

  reply	other threads:[~2026-01-22  4:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-18  4:21 [PATCH net-next v5 0/4] A series of minor optimizations of the bonding module Tonghao Zhang
2026-01-18  4:21 ` [PATCH net-next v5 1/4] net: bonding: use workqueue to make sure peer notify updated in lacp mode Tonghao Zhang
2026-01-22  4:33   ` Hangbin Liu [this message]
2026-01-18  4:21 ` [PATCH net-next v5 2/4] net: bonding: move bond_should_notify_peers, e.g. into rtnl lock block Tonghao Zhang
2026-01-18  4:21 ` [PATCH net-next v5 3/4] net: bonding: skip the 2nd trylock when first one fail Tonghao Zhang
2026-01-18  4:21 ` [PATCH net-next v5 4/4] net: bonding: add the READ_ONCE/WRITE_ONCE for outside lock accessing Tonghao Zhang
2026-01-22 10:30 ` [PATCH net-next v5 0/4] A series of minor optimizations of the bonding module patchwork-bot+netdevbpf

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=aXGohVBmvaYIYt2w@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