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 <joestrin...@nicira.com> Acked-by: Ethan Jackson <et...@nicira.com> --- v5: Rebase Tweak commit message --- 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 cba3534..4e889e6 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -489,6 +489,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. */ @@ -1255,6 +1256,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); @@ -1478,7 +1480,6 @@ static int run(struct ofproto *ofproto_) { struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_); - struct ofbundle *bundle; uint64_t new_seq; int error; @@ -1522,8 +1523,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); @@ -1563,7 +1568,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; @@ -1575,8 +1579,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); @@ -2478,6 +2486,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