From e2d13c430a5c648852369e4ce6808053eb076e5b Mon Sep 17 00:00:00 2001 From: Joe Stringer Date: Fri, 13 Dec 2013 03:33:48 +0000 Subject: [PATCH] ofproto-dpif: Only run bundles when lacp or bonds are enabled 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 average CPU usage of the main thread 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 Signed-off-by: Ethan Jackson Acked-by: Ethan Jackson --- ofproto/ofproto-dpif.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 616aa3c10..89b255d8f 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -483,6 +483,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. */ @@ -1248,6 +1249,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); @@ -1471,7 +1473,6 @@ static int run(struct ofproto *ofproto_) { struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_); - struct ofbundle *bundle; uint64_t new_seq; int error; @@ -1515,8 +1516,12 @@ run(struct ofproto *ofproto_) ofproto->change_seq = new_seq; } - HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) { - bundle_run(bundle); + if (ofproto->lacp_enabled || ofproto->has_bonded_bundles) { + struct ofbundle *bundle; + + HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) { + bundle_run(bundle); + } } stp_run(ofproto); @@ -1556,7 +1561,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; @@ -1568,8 +1572,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); @@ -2471,6 +2479,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(); -- 2.43.0