When dealing with a large number of ports, bundle_run() and
bundle_wait() add significant unnecessary processing to the main run
loop, even when not in use. This patch skips such execution if it is
unneeded, reducing CPU usage from about 25% to about 20% in a test
environment of 5000 internal ports and 50 tunnel ports running bfd.

Signed-off-by: Joe Stringer <[email protected]>
---
 ofproto/ofproto-dpif.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 3717365..189b185 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1470,7 +1470,6 @@ static int
 run(struct ofproto *ofproto_)
 {
     struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
-    struct ofbundle *bundle;
     int error;
 
     if (mbridge_need_revalidate(ofproto->mbridge)) {
@@ -1510,8 +1509,12 @@ run(struct ofproto *ofproto_)
             port_run(ofport);
         }
     }
-    HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) {
-        bundle_run(bundle);
+    if (hmap_count(&ofproto->bundles)) {
+        struct ofbundle *bundle;
+
+        HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) {
+            bundle_run(bundle);
+        }
     }
 
     stp_run(ofproto);
@@ -1551,7 +1554,6 @@ static void
 wait(struct ofproto *ofproto_)
 {
     struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
-    struct ofbundle *bundle;
 
     if (ofproto_get_flow_restore_wait()) {
         return;
@@ -1563,8 +1565,12 @@ wait(struct ofproto *ofproto_)
     if (ofproto->ipfix) {
         dpif_ipfix_wait(ofproto->ipfix);
     }
-    HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) {
-        bundle_wait(bundle);
+    if (hmap_count(&ofproto->bundles)) {
+        struct ofbundle *bundle;
+
+        HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) {
+            bundle_wait(bundle);
+        }
     }
     if (ofproto->netflow) {
         netflow_wait(ofproto->netflow);
-- 
1.7.9.5

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to