Subject: Re: [PATCH net-next v5 1/4] net: bonding: use workqueue to make sure peer notify updated in lacp mode

From: Hangbin Liu <[email-masked]>
Date: Thu, 22 Jan 2026 04:33:09 +0000

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 <[email-masked]>
> Cc: "David S. Miller" <[email-masked]>
> Cc: Eric Dumazet <[email-masked]>
> Cc: Jakub Kicinski <[email-masked]>
> Cc: Paolo Abeni <[email-masked]>
> Cc: Simon Horman <[email-masked]>
> Cc: Jonathan Corbet <[email-masked]>
> Cc: Andrew Lunn <[email-masked]>
> Cc: Nikolay Aleksandrov <[email-masked]>
> Cc: Hangbin Liu <[email-masked]>
> Cc: Jason Xing <[email-masked]>
> Suggested-by: Hangbin Liu <[email-masked]>
> Signed-off-by: Tonghao Zhang <[email-masked]>
> ---
> 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/[email-masked]/
> - 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 <[email-masked]>