Re: [PATCH net v3 1/2] bonding: convert unbalanced_load to per-cpu state

From: Hangbin Liu

Date: Tue Aug 18 2026 - 21:15:09 EST


On Tue, Aug 18, 2026 at 12:42:10PM +0300, Nikolay Aleksandrov wrote:
> > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> > index 522eab060f9e..9fb44e0031c8 100644
> > --- a/drivers/net/bonding/bond_main.c
> > +++ b/drivers/net/bonding/bond_main.c
> > @@ -5995,6 +5995,7 @@ static void bond_destructor(struct net_device *bond_dev)
> > destroy_workqueue(bond->wq);
> > free_percpu(bond->rr_tx_counter);
> > + free_percpu(bond->alb_info.unbalanced_load);
> > }
> > void bond_setup(struct net_device *bond_dev)
> > @@ -6494,6 +6495,10 @@ static int bond_init(struct net_device *bond_dev)
> > if (!bond->wq)
> > return -ENOMEM;
> > + bond->alb_info.unbalanced_load = alloc_percpu(struct unbalanced_load_stats);
> > + if (!bond->alb_info.unbalanced_load)
> > + goto wq_out;
> > +
>
> The bond doesn't generally depend on this struct and shouldn't fail to init
> if it fails to allocate and the user hasn't chosen alb mode. Also here is too
> early to tell, the netlink mode hasn't been applied yet.
> Maybe the allocation could be moved to bond_alb_initialize and the freeing to
> bond_alb_deinitialize?

Makes sense. Let me move it to tlb_initialize/tlb_deinitialize.

Thanks
Hangbin