On Fri, Mar 14, 2025 at 4:11 PM Vladislav Odintsov <vlodintsov@k2.cloud> wrote: > > With this commit the rebalance of hash entries between bonding members > becomes less frequent. If we know all bond members' speed, we do not > move hash entries between them if load difference is less than 1.5% of > minimum link speed of bond members. > > Reported-at: > https://mail.openvswitch.org/pipermail/ovs-dev/2025-March/422028.html > Suggested-by: Ilya Maximets <i.maxim...@ovn.org> > Signed-off-by: Vladislav Odintsov <vlodintsov@k2.cloud> > --- > ofproto/bond.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/ofproto/bond.c b/ofproto/bond.c > index 17bf10be5..70219db89 100644 > --- a/ofproto/bond.c > +++ b/ofproto/bond.c > @@ -1336,6 +1336,7 @@ bond_rebalance(struct bond *bond) > struct ovs_list bals; > bool rebalanced = false; > bool use_recirc; > + uint32_t min_member_mbps = UINT32_MAX; > > ovs_rwlock_wrlock(&rwlock); > if (!bond_is_balanced(bond) || time_msec() < bond->next_rebalance) { > @@ -1378,7 +1379,11 @@ bond_rebalance(struct bond *bond) > ovs_list_init(&bals); > HMAP_FOR_EACH (member, hmap_node, &bond->members) { > if (member->enabled) { > + uint32_t mbps; > + > insert_bal(&bals, member); > + netdev_get_speed(member->netdev, &mbps, NULL);
This function may return an error. And also it may not return an error but still set mbps to zero. We should probably discard the value in those cases. > + min_member_mbps = MIN(mbps, min_member_mbps); > } > } Should probably also have some sane default if all the calls to netdev_get_speed failed and min_member_mbps is still UINT32_MAX. > log_bals(bond, &bals); > @@ -1392,10 +1397,12 @@ bond_rebalance(struct bond *bond) > uint64_t overload; > > overload = from->tx_bytes - to->tx_bytes; > - if (overload < to->tx_bytes >> 5 || overload < 100000) { > + if (overload < to->tx_bytes >> 5 || > + overload / 1000000 < MAX(1, min_member_mbps / 8 >> 6)) { > /* The extra load on 'from' (and all less-loaded members), > compared > * to that of 'to' (the least-loaded member), is less than ~3%, > or > - * it is less than ~1Mbps. No point in rebalancing. */ > + * it is less than MAX of 1MB and ~1.5% of minimum bond member Should this comment be "1MB or ~1.5%" ? Cheers, M > + * link speed, if present. No point in rebalancing. */ > break; > } > > -- > 2.48.1 > > _______________________________________________ > dev mailing list > d...@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev > _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev