diff mbox series

[ovs-dev,v1,4/6] dpif-netdev: skip flow hash calculation in case of smc disabled

Message ID 20200602071005.29925-5-Yanqin.Wei@arm.com
State Changes Requested
Headers show
Series Memory access optimization for flow scalability of userspace datapath. | expand

Commit Message

Yanqin Wei June 2, 2020, 7:10 a.m. UTC
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.Zhang@arm.com>
Reviewed-by: Malvika Gupta <Malvika.Gupta@arm.com>
Reviewed-by: Lance Yang <Lance.Yang@arm.com>
Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
---
 lib/dpif-netdev.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
diff mbox series

Patch

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.