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> --- v1 -> v2: - Addressed Ilya's, Eelco's, Mike's review comments. - Docs updated. - NEWS entry added. --- Documentation/topics/bonding.rst | 3 ++- NEWS | 4 ++++ ofproto/bond.c | 25 +++++++++++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Documentation/topics/bonding.rst b/Documentation/topics/bonding.rst index b8ef0dab5..003f01fb0 100644 --- a/Documentation/topics/bonding.rst +++ b/Documentation/topics/bonding.rst @@ -136,7 +136,8 @@ vswitchd will only shift a hash from H to L if it will decrease the ratio of the load between H and L by at least 0.1. Currently, "significantly more loaded" means that H must carry at least 1 Mbps -more traffic, and that traffic must be at least 3% greater than L's. +or ~1.5% of slowest member network device speed more traffic, and that traffic +must be at least 3% greater than L's. Bond Balance Modes ------------------ diff --git a/NEWS b/NEWS index 72a902dda..9afb28205 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,10 @@ Post-v3.5.0 * Bond rebalancing log messages of INFO log level is highly reduced: they are printed once in rebalance run. Previous detailed log messaged moved to DBG log level. + * Additionally to previous behavior bond rebalancing now performed if the + most loaded bond member transfers ~3% of minimum member link speed more + traffic in average by last rebalance_interval, than the least loaded + bond member. v3.5.0 - 17 Feb 2025 diff --git a/ofproto/bond.c b/ofproto/bond.c index adba1501d..91e40b347 100644 --- a/ofproto/bond.c +++ b/ofproto/bond.c @@ -1331,7 +1331,10 @@ compare_bond_entries(const void *a_, const void *b_) void bond_rebalance(struct bond *bond) { + int rebalance_interval_sec = bond->rebalance_interval / 1000; struct bond_entry *e, *hashes[BOND_BUCKETS]; + uint32_t min_member_mbps = UINT32_MAX; + uint64_t overload_threshold, overload; struct bond_member *member; struct ovs_list bals; bool rebalanced = false; @@ -1378,9 +1381,18 @@ 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); + /* Speed can be 0 in case inability to get it from device. In that + * case min_member_mbps will be also 0, but replaced with a + * fallback minimum rebalance value of ~1Mbps below. */ + min_member_mbps = MIN(mbps, min_member_mbps); } } + overload_threshold = MAX(1, min_member_mbps >> 6); log_bals(bond, &bals); /* Shift load from the most-loaded members to the least-loaded members. */ @@ -1389,13 +1401,14 @@ bond_rebalance(struct bond *bond) = bond_member_from_bal_node(ovs_list_front(&bals)); struct bond_member *to = bond_member_from_bal_node(ovs_list_back(&bals)); - uint64_t overload; - overload = from->tx_bytes - to->tx_bytes; - if (overload < to->tx_bytes >> 5 || overload < 100000) { - /* 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. */ + overload = (from->tx_bytes - to->tx_bytes) / rebalance_interval_sec; + if (overload < (to->tx_bytes / rebalance_interval_sec) >> 5 || + overload * 8 / 1000000 < overload_threshold) { + /* The extra average load per second 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 MAX of 1Mbps and ~1.5% of MIN + * bond member 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