When dealing with a large number of ports, bundle_run() and
bundle_wait() add significant unnecessary processing to the main run
loop, even when there are no bonds and lacp is not configured. 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 <joestrin...@nicira.com>
---
 ofproto/ofproto-dpif.c |   31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 1e4315f..c33a008 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -485,6 +485,7 @@ struct ofproto_dpif {
     struct hmap bundles;        /* Contains "struct ofbundle"s. */
     struct mac_learning *ml;
     bool has_bonded_bundles;
+    bool lacp_enabled;
     struct mbridge *mbridge;
 
     /* Facets. */
@@ -1250,6 +1251,7 @@ construct(struct ofproto *ofproto_)
     ofproto->ml = mac_learning_create(MAC_ENTRY_DEFAULT_IDLE_TIME);
     ofproto->mbridge = mbridge_create();
     ofproto->has_bonded_bundles = false;
+    ofproto->lacp_enabled = false;
     ovs_mutex_init(&ofproto->stats_mutex);
     ovs_mutex_init(&ofproto->vsp_mutex);
 
@@ -1472,7 +1474,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)) {
@@ -1505,15 +1506,19 @@ run(struct ofproto *ofproto_)
         dpif_ipfix_run(ofproto->ipfix);
     }
 
-    if (ofproto_->change_seq != netdev_change_seq()) {
-        struct ofport_dpif *ofport;
+    if (ofproto->lacp_enabled || ofproto->has_bonded_bundles) {
+        struct ofbundle *bundle;
+
+        if (ofproto_->change_seq != netdev_change_seq()) {
+            struct ofport_dpif *ofport;
 
-        HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
-            port_run(ofport);
+            HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
+                port_run(ofport);
+            }
+        }
+        HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) {
+            bundle_run(bundle);
         }
-    }
-    HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) {
-        bundle_run(bundle);
     }
 
     stp_run(ofproto);
@@ -1553,7 +1558,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;
@@ -1565,8 +1569,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 (ofproto->lacp_enabled || ofproto->has_bonded_bundles) {
+        struct ofbundle *bundle;
+
+        HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) {
+            bundle_wait(bundle);
+        }
     }
     if (ofproto->netflow) {
         netflow_wait(ofproto->netflow);
@@ -2447,6 +2455,7 @@ bundle_set(struct ofproto *ofproto_, void *aux,
 
     /* LACP. */
     if (s->lacp) {
+        ofproto->lacp_enabled = true;
         if (!bundle->lacp) {
             ofproto->backer->need_revalidate = REV_RECONFIGURE;
             bundle->lacp = lacp_create();
-- 
1.7.9.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to