diff mbox series

[ovs-dev,v4,1/2] dpif-netdev: add EMC entries counter

Message ID 1559555477-36363-2-git-send-email-Yanqin.Wei@arm.com
State Deferred
Headers show
Series dfc_process optimization by prefetching EMC entry | expand

Commit Message

Yanqin Wei June 3, 2019, 9:51 a.m. UTC
Implement entries counter for EMC. It could be used for improvement for
EMC lookup.

Signed-off-by: Yanqin Wei <yanqin.wei@arm.com>
Reviewed-by: Gavin Hu <Gavin.Hu@arm.com>
---
 lib/dpif-netdev.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

Comments

0-day Robot June 3, 2019, 9:59 a.m. UTC | #1
Bleep bloop.  Greetings Yanqin Wei, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Author Yanqin Wei <Yanqin.Wei@arm.com> needs to sign off.
WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Yanqin Wei <yanqin.wei@arm.com>
Lines checked: 116, Warnings: 1, Errors: 1


Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

Thanks,
0-day Robot
diff mbox series

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 5a6f2ab..c74cc02 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -197,6 +197,7 @@  struct emc_entry {
 struct emc_cache {
     struct emc_entry entries[EM_FLOW_HASH_ENTRIES];
     int sweep_idx;                /* For emc_cache_slow_sweep(). */
+    uint32_t counter;
 };
 
 struct smc_bucket {
@@ -826,7 +827,7 @@  static int dpif_netdev_xps_get_tx_qid(const struct dp_netdev_pmd_thread *pmd,
                                       struct tx_port *tx);
 
 static inline bool emc_entry_alive(struct emc_entry *ce);
-static void emc_clear_entry(struct emc_entry *ce);
+static void emc_clear_entry(struct emc_cache *cache, struct emc_entry *ce);
 static void smc_clear_entry(struct smc_bucket *b, int idx);
 
 static void dp_netdev_request_reconfigure(struct dp_netdev *dp);
@@ -840,6 +841,7 @@  emc_cache_init(struct emc_cache *flow_cache)
 {
     int i;
 
+    flow_cache->counter = 0;
     flow_cache->sweep_idx = 0;
     for (i = 0; i < ARRAY_SIZE(flow_cache->entries); i++) {
         flow_cache->entries[i].flow = NULL;
@@ -872,8 +874,9 @@  emc_cache_uninit(struct emc_cache *flow_cache)
 {
     int i;
 
+    flow_cache->counter = 0;
     for (i = 0; i < ARRAY_SIZE(flow_cache->entries); i++) {
-        emc_clear_entry(&flow_cache->entries[i]);
+        emc_clear_entry(flow_cache, &flow_cache->entries[i]);
     }
 }
 
@@ -904,7 +907,7 @@  emc_cache_slow_sweep(struct emc_cache *flow_cache)
     struct emc_entry *entry = &flow_cache->entries[flow_cache->sweep_idx];
 
     if (!emc_entry_alive(entry)) {
-        emc_clear_entry(entry);
+        emc_clear_entry(flow_cache,entry);
     }
     flow_cache->sweep_idx = (flow_cache->sweep_idx + 1) & EM_FLOW_HASH_MASK;
 }
@@ -2771,25 +2774,28 @@  emc_entry_alive(struct emc_entry *ce)
 }
 
 static void
-emc_clear_entry(struct emc_entry *ce)
+emc_clear_entry(struct emc_cache *cache, struct emc_entry *ce)
 {
     if (ce->flow) {
         dp_netdev_flow_unref(ce->flow);
         ce->flow = NULL;
+        cache->counter--;
     }
 }
 
 static inline void
-emc_change_entry(struct emc_entry *ce, struct dp_netdev_flow *flow,
-                 const struct netdev_flow_key *key)
+emc_change_entry(struct emc_cache *cache, struct emc_entry *ce,
+                struct dp_netdev_flow *flow, const struct netdev_flow_key *key)
 {
     if (ce->flow != flow) {
         if (ce->flow) {
             dp_netdev_flow_unref(ce->flow);
+            cache->counter--;
         }
 
         if (dp_netdev_flow_ref(flow)) {
             ce->flow = flow;
+            cache->counter++;
         } else {
             ce->flow = NULL;
         }
@@ -2809,7 +2815,7 @@  emc_insert(struct emc_cache *cache, const struct netdev_flow_key *key,
     EMC_FOR_EACH_POS_WITH_HASH(cache, current_entry, key->hash) {
         if (netdev_flow_key_equal(&current_entry->key, key)) {
             /* We found the entry with the 'mf' miniflow */
-            emc_change_entry(current_entry, flow, NULL);
+            emc_change_entry(cache,current_entry, flow, NULL);
             return;
         }
 
@@ -2825,7 +2831,7 @@  emc_insert(struct emc_cache *cache, const struct netdev_flow_key *key,
     /* We didn't find the miniflow in the cache.
      * The 'to_be_replaced' entry is where the new flow will be stored */
 
-    emc_change_entry(to_be_replaced, flow, key);
+    emc_change_entry(cache,to_be_replaced, flow, key);
 }
 
 static inline void