[ovs-dev] [PATCH ovn v4 4/9] ovn-northd: Add commands to set/get parallelisation thresholds

anton.ivanov at cambridgegreys.com anton.ivanov at cambridgegreys.com
Fri Sep 25 09:58:02 UTC 2020


From: Anton Ivanov <anton.ivanov at cambridgegreys.com>

Add commands to control and display single-threaded to multi-
threaded cutoff.

Signed-off-by: Anton Ivanov <anton.ivanov at cambridgegreys.com>
---
 northd/ovn-northd.c | 47 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 3 deletions(-)

diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index 225f4ca8e..c768431d0 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -59,6 +59,8 @@ static unixctl_cb_func ovn_northd_resume;
 static unixctl_cb_func ovn_northd_is_paused;
 static unixctl_cb_func ovn_northd_status;
 static unixctl_cb_func cluster_state_reset_cmd;
+static unixctl_cb_func get_param_cutoff;
+static unixctl_cb_func set_param_cutoff;
 
 struct northd_context {
     struct ovsdb_idl *ovnnb_idl;
@@ -11460,8 +11462,8 @@ static void init_lflows_thread_pool(void)
  * Setting to 1 forces "all parallel" lflow build.
  */
 
-#define OD_CUTOFF 1
-#define OP_CUTOFF 1
+static ssize_t lflow_od_cuttoff = 1;
+static ssize_t lflow_op_cutoff = 1;
 
 static void
 build_lswitch_and_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
@@ -11472,7 +11474,8 @@ build_lswitch_and_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
 {
     char *svc_check_match = xasprintf("eth.dst == %s", svc_monitor_mac);
 
-    if (hmap_count(datapaths) > OD_CUTOFF || hmap_count(ports) > OP_CUTOFF) {
+    if (hmap_count(datapaths) > lflow_od_cuttoff ||
+            hmap_count(ports) > lflow_op_cutoff) {
 
         struct hmap *lflow_segs;
         struct lswitch_flow_build_info *lsiv;
@@ -13157,6 +13160,14 @@ main(int argc, char *argv[])
     unixctl_command_register("is-paused", "", 0, 0, ovn_northd_is_paused,
                              &state);
     unixctl_command_register("status", "", 0, 0, ovn_northd_status, &state);
+    unixctl_command_register("set-datapath-cutoff", "", 0, 0,
+                             set_param_cutoff, &lflow_od_cuttoff);
+    unixctl_command_register("set-port-cutoff", "", 0, 0,
+                             set_param_cutoff, &lflow_op_cutoff);
+    unixctl_command_register("get-datapath-cutoff", "", 0, 0,
+                             get_param_cutoff, &lflow_od_cuttoff);
+    unixctl_command_register("get-port-cutoff", "", 0, 0,
+                             get_param_cutoff, &lflow_op_cutoff);
 
     bool reset_ovnsb_idl_min_index = false;
     unixctl_command_register("sb-cluster-state-reset", "", 0, 0,
@@ -13582,3 +13593,33 @@ cluster_state_reset_cmd(struct unixctl_conn *conn, int argc OVS_UNUSED,
     poll_immediate_wake();
     unixctl_command_reply(conn, NULL);
 }
+
+static void set_param_cutoff
+(struct unixctl_conn *conn, int argc OVS_UNUSED,
+                          const char *argv[],
+                          void *param_)
+{
+    long new_cutoff;
+    ssize_t *param = param_;
+
+    if (str_to_long(argv[1], 10, &new_cutoff)) {
+        if (new_cutoff > 0) {
+            *param = new_cutoff;
+            return;
+        }
+    }
+    unixctl_command_reply_error(conn, "unsigned integer required");
+}
+
+static void get_param_cutoff
+(struct unixctl_conn *conn, int argc OVS_UNUSED,
+                          const char *argv[] OVS_UNUSED,
+                          void *param_)
+{
+    struct ds ds = DS_EMPTY_INITIALIZER;
+    ssize_t *param = param_;
+
+    ds_put_format(&ds, "%ld\n", *param);
+    unixctl_command_reply(conn, ds_cstr(&ds));
+    ds_destroy(&ds);
+}
-- 
2.20.1



More information about the dev mailing list