In case of 10k+ flows, emc lookup will usually miss. Flow hash value is always calculated in this case no matter smc is enabled or not. This patch moves it from smc_insert function into fast_path_processing and handle_packet_upcall function to avoid unnecessary hash calculation and memory access(flow->ufid) in smc disabled case.
Reviewed-by: Lijian Zhang <lijian.zh...@arm.com> Reviewed-by: Malvika Gupta <malvika.gu...@arm.com> Reviewed-by: Lance Yang <lance.y...@arm.com> Signed-off-by: Yanqin Wei <yanqin....@arm.com> --- lib/dpif-netdev.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 3994f41e4..d575edefd 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -2957,14 +2957,8 @@ smc_insert(struct dp_netdev_pmd_thread *pmd, struct smc_bucket *bucket = &smc_cache->buckets[key->hash & SMC_MASK]; uint16_t index; uint32_t cmap_index; - bool smc_enable_db; int i; - atomic_read_relaxed(&pmd->dp->smc_enable_db, &smc_enable_db); - if (!smc_enable_db) { - return; - } - cmap_index = cmap_find_index(&pmd->flow_table, hash); index = (cmap_index >= UINT16_MAX) ? UINT16_MAX : (uint16_t)cmap_index; @@ -6794,8 +6788,13 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd, add_actions->size); } ovs_mutex_unlock(&pmd->flow_mutex); - uint32_t hash = dp_netdev_flow_hash(&netdev_flow->ufid); - smc_insert(pmd, key, hash); + + bool smc_enable_db; + atomic_read_relaxed(&pmd->dp->smc_enable_db, &smc_enable_db); + if (smc_enable_db) { + uint32_t hash = dp_netdev_flow_hash(&netdev_flow->ufid); + smc_insert(pmd, key, hash); + } emc_probabilistic_insert(pmd, key, netdev_flow); } if (pmd_perf_metrics_enabled(pmd)) { @@ -6904,9 +6903,13 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, } flow = dp_netdev_flow_cast(rules[i]); - uint32_t hash = dp_netdev_flow_hash(&flow->ufid); - smc_insert(pmd, keys[i], hash); + bool smc_enable_db; + atomic_read_relaxed(&pmd->dp->smc_enable_db, &smc_enable_db); + if (smc_enable_db) { + uint32_t hash = dp_netdev_flow_hash(&flow->ufid); + smc_insert(pmd, keys[i], hash); + } emc_probabilistic_insert(pmd, keys[i], flow); /* Add these packets into the flow map in the same order * as received. -- 2.17.1 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev