[ovs-dev] [RFC PATCH ovn 1/4] ovn-northd: Avoid ha_ref_chassis calculation when there is only one chassis in ha_chassis_group.

Han Zhou hzhou at ovn.org
Fri Jul 30 07:21:38 UTC 2021


When there is a big number of ha_chassis_groups (e.g. for distributed
gateway ports), the calculation of ha_ref_chassis can take the major
part of ovn-northd CPU as shown in perf.

However, when there is only one chassis in ha_chassis_group, no BFD
sessions are needed, so ha_ref_chassis calculation is unnecessary.

Signed-off-by: Han Zhou <hzhou at ovn.org>

---
TODO: DDlog changes
---
 northd/ovn-northd.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index 87c4478fa..2bc187d39 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -6488,7 +6488,8 @@ build_lrouter_groups__(struct hmap *ports, struct ovn_datapath *od)
          * ha chassis group name. */
         for (size_t i = 0; i < od->n_l3dgw_ports; i++) {
             struct ovn_port *crp = od->l3dgw_ports[i]->cr_port;
-            if (crp->sb->ha_chassis_group) {
+            if (crp->sb->ha_chassis_group &&
+                crp->sb->ha_chassis_group->n_ha_chassis > 1) {
                 sset_add(&od->lr_group->ha_chassis_groups,
                          crp->sb->ha_chassis_group->name);
             }
@@ -14163,11 +14164,13 @@ handle_port_binding_changes(struct northd_context *ctx, struct hmap *ports,
     if (ctx->ovnsb_txn) {
         const struct sbrec_ha_chassis_group *ha_ch_grp;
         SBREC_HA_CHASSIS_GROUP_FOR_EACH (ha_ch_grp, ctx->ovnsb_idl) {
-            struct ha_ref_chassis_info *ref_ch_info =
-                xzalloc(sizeof *ref_ch_info);
-            ref_ch_info->ha_chassis_group = ha_ch_grp;
-            build_ha_chassis_ref = true;
-            shash_add(ha_ref_chassis_map, ha_ch_grp->name, ref_ch_info);
+            if (ha_ch_grp->n_ha_chassis > 1) {
+                struct ha_ref_chassis_info *ref_ch_info =
+                    xzalloc(sizeof *ref_ch_info);
+                ref_ch_info->ha_chassis_group = ha_ch_grp;
+                build_ha_chassis_ref = true;
+                shash_add(ha_ref_chassis_map, ha_ch_grp->name, ref_ch_info);
+            }
         }
     }
 
-- 
2.30.2



More information about the dev mailing list