[ovs-dev] [PATCH 2/4] util: Extend ovs_prefetch_range to include prefetch type.

Bhanuprakash Bodireddy bhanuprakash.bodireddy at intel.com
Fri Jan 12 17:41:17 UTC 2018


With ovs_prefetch_range(), large amounts of data can be prefetched in to
caches. Prefetch type gives better control over data caching strategy;
Meaning where the data should be prefetched(L1/L2/L3) and if the data
reference is temporal or non-temporal.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy at intel.com>
---
 lib/pvector.h | 6 ++++--
 lib/util.h    | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/pvector.h b/lib/pvector.h
index b175b21..d5655f0 100644
--- a/lib/pvector.h
+++ b/lib/pvector.h
@@ -177,7 +177,8 @@ pvector_cursor_init(const struct pvector *pvec,
 
     impl = ovsrcu_get(struct pvector_impl *, &pvec->impl);
 
-    ovs_prefetch_range(impl->vector, impl->size * sizeof impl->vector[0]);
+    ovs_prefetch_range(impl->vector, impl->size * sizeof impl->vector[0],
+                       OPCH_HTR);
 
     cursor.size = impl->size;
     cursor.vector = impl->vector;
@@ -208,7 +209,8 @@ static inline void pvector_cursor_lookahead(const struct pvector_cursor *cursor,
                                             int n, size_t size)
 {
     if (cursor->entry_idx + n < cursor->size) {
-        ovs_prefetch_range(cursor->vector[cursor->entry_idx + n].ptr, size);
+        ovs_prefetch_range(cursor->vector[cursor->entry_idx + n].ptr, size,
+                           OPCH_HTR);
     }
 }
 
diff --git a/lib/util.h b/lib/util.h
index b6639b8..0a8ae23 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -73,13 +73,13 @@ BUILD_ASSERT_DECL(IS_POW2(CACHE_LINE_SIZE));
 typedef uint8_t OVS_CACHE_LINE_MARKER[1];
 
 static inline void
-ovs_prefetch_range(const void *start, size_t size)
+ovs_prefetch_range(const void *start, size_t size, enum ovs_prefetch_type type)
 {
     const char *addr = (const char *)start;
     size_t ofs;
 
     for (ofs = 0; ofs < size; ofs += CACHE_LINE_SIZE) {
-        OVS_PREFETCH(addr + ofs);
+        OVS_PREFETCH_CACHE(addr + ofs, type);
     }
 }
 
-- 
2.4.11



More information about the dev mailing list