[ovs-dev] [PATCH v3 09/16] ovn-controller: Avoid forced recompute when not needed

Han Zhou zhouhan at gmail.com
Fri Jun 1 17:41:59 UTC 2018


Signed-off-by: Han Zhou <hzhou8 at ebay.com>
---
 ovn/controller/ovn-controller.c | 13 +++++++++----
 ovn/lib/inc-proc-eng.c          | 20 ++++++++++++++++++++
 ovn/lib/inc-proc-eng.h          |  4 ++++
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index e939d03..e4506c2 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -1157,10 +1157,15 @@ main(int argc, char *argv[])
 
         }
         if (old_engine_run_id == engine_run_id) {
-            VLOG_DBG("engine did not run, force recompute next time: "
-                     "br_int %p, chassis %p", br_int, chassis);
-            engine_set_force_recompute(true);
-            poll_immediate_wake();
+            if (engine_need_run(&en_flow_output)) {
+                VLOG_DBG("engine did not run, force recompute next time: "
+                         "br_int %p, chassis %p", br_int, chassis);
+                engine_set_force_recompute(true);
+                poll_immediate_wake();
+            } else {
+                VLOG_DBG("engine did not run, and it was not needed either: "
+                         "br_int %p, chassis %p", br_int, chassis);
+            }
         } else {
             engine_set_force_recompute(false);
         }
diff --git a/ovn/lib/inc-proc-eng.c b/ovn/lib/inc-proc-eng.c
index 8006acd..08f152e 100644
--- a/ovn/lib/inc-proc-eng.c
+++ b/ovn/lib/inc-proc-eng.c
@@ -139,3 +139,23 @@ engine_run(struct engine_node *node, uint64_t run_id)
 
     VLOG_DBG("node: %s, changed: %d", node->name, node->changed);
 }
+
+bool
+engine_need_run(struct engine_node *node)
+{
+    size_t i;
+
+    if (!node->n_inputs) {
+        node->run(node);
+        VLOG_DBG("input node: %s, changed: %d", node->name, node->changed);
+        return node->changed;
+    }
+
+    for (i = 0; i < node->n_inputs; i++) {
+        if (engine_need_run(node->inputs[i].node)) {
+            return true;
+        }
+    }
+
+    return false;
+}
diff --git a/ovn/lib/inc-proc-eng.h b/ovn/lib/inc-proc-eng.h
index 8399321..17006f1 100644
--- a/ovn/lib/inc-proc-eng.h
+++ b/ovn/lib/inc-proc-eng.h
@@ -126,6 +126,10 @@ void engine_run(struct engine_node *, uint64_t run_id);
  * terminates. */
 void engine_cleanup(struct engine_node *);
 
+/* Check if engine needs to run, i.e. any change to be processed. */
+bool
+engine_need_run(struct engine_node *);
+
 /* Get the input node with <name> for <node> */
 struct engine_node * engine_get_input(const char *input_name,
                                       struct engine_node *);
-- 
2.1.0



More information about the dev mailing list