dpif-netdev: optmizing emc_processing()
authorAndy Zhou <azhou@ovn.org>
Sat, 30 Jan 2016 01:48:50 +0000 (17:48 -0800)
committerAndy Zhou <azhou@ovn.org>
Tue, 2 Feb 2016 20:01:14 +0000 (12:01 -0800)
Commit d262ac2c60ce1da7b477737f70e8efd38b32502d introduced a slight
performance drop for the fast path, where every packets hits the
emc cache.  This patch removes that performance drop by only reloading
the key pointer on emc cache miss.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
lib/dpif-netdev.c

index 094ffbf..faf5d45 100644 (file)
@@ -3297,6 +3297,7 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, struct dp_packet **packets,
                struct packet_batch batches[], size_t *n_batches)
 {
     struct emc_cache *flow_cache = &pmd->flow_cache;
+    struct netdev_flow_key *key = &keys[0];
     size_t i, n_missed = 0, n_dropped = 0;
 
     for (i = 0; i < cnt; i++) {
@@ -3314,7 +3315,6 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, struct dp_packet **packets,
             OVS_PREFETCH(dp_packet_data(packets[i+1]));
         }
 
-        struct netdev_flow_key *key = &keys[n_missed];
         miniflow_extract(packet, &key->mf);
         key->len = 0; /* Not computed yet. */
         key->hash = dpif_netdev_packet_get_rss_hash(packet, &key->mf);
@@ -3326,7 +3326,8 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, struct dp_packet **packets,
         } else {
             /* Exact match cache missed. Group missed packets together at
              * the beginning of the 'packets' array.  */
-            packets[n_missed++] = packet;
+            packets[n_missed] = packet;
+            key = &keys[n_missed++];
         }
     }