[ovs-dev,3/4] util: Use OPCH_NTR type while prefetching packet metadata.

Message ID 1515778879-60075-3-git-send-email-bhanuprakash.bodireddy@intel.com
State New
Delegated to: Ian Stokes
Headers show
Series
  • [ovs-dev,1/4] compiler: Introduce OVS_PREFETCH variants.
Related show

Commit Message

Bodireddy, Bhanuprakash Jan. 12, 2018, 5:41 p.m.
OVS_PREFETCH by default uses OPCH_HTR(High Temporal Read), meaning
the prefetch is in preparation for a future read and the prefetched
data is made available in all levels of caches.

However the pkt_metadata_prefetch_init() prefetches the metadata so that
the data is readily available when pkt_metadata_init() zeroes out the
same. So a 'write' operation is actually performed instead of anticipated
'read' on the prefetched data.

Doing a 'write' isn't a problem as the metadata isn't shared between the
threads and doesn't need invalidation across other cores and so read
prefetch is enough with *non-temporal* reference so not to pollute the
cache. This change seems to positively affect performance.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com>
---
 lib/packets.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch

diff --git a/lib/packets.h b/lib/packets.h
index 9a71aa3..5f50fe2 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -166,14 +166,14 @@  pkt_metadata_prefetch_init(struct pkt_metadata *md)
 {
     /* Prefetch cacheline0 as members till ct_state and odp_port will
      * be initialized later in pkt_metadata_init(). */
-    OVS_PREFETCH(md->cacheline0);
+    OVS_PREFETCH_CACHE(md->cacheline0, OPCH_NTR);
 
     /* Prefetch cacheline1 as members of this cacheline will be zeroed out
      * in pkt_metadata_init_tnl(). */
-    OVS_PREFETCH(md->cacheline1);
+    OVS_PREFETCH_CACHE(md->cacheline1, OPCH_NTR);
 
     /* Prefetch cachline2 as ip_dst & ipv6_dst fields will be initialized. */
-    OVS_PREFETCH(md->cacheline2);
+    OVS_PREFETCH_CACHE(md->cacheline2, OPCH_NTR);
 }
 
 bool dpid_from_string(const char *s, uint64_t *dpidp);