All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] eal/riscv: implement prefetch using __builtin_prefetch
@ 2026-03-10 13:35 dangshiwei
  2026-03-28 11:48 ` sunyuechi
  2026-09-15 13:22 ` Stephen Hemminger
  0 siblings, 2 replies; 5+ messages in thread
From: dangshiwei @ 2026-03-10 13:35 UTC (permalink / raw)
  To: dev; +Cc: stanislaw.kardach, sunyuechi, stephen, david.marchand, dangshiwei

RISC-V currently has no-op implementations of the rte_prefetch*
functions. Use __builtin_prefetch() to allow the compiler to emit
Zicbop prefetch instructions when the target supports them (GCC
13.1+, Clang 17.0.1+ with -march=rv*_zicbop).

The Zicbop extension has no cache-level hints, so rte_prefetch1()
and rte_prefetch2() fall back to rte_prefetch0(). The volatile
qualifier is stripped via uintptr_t cast to satisfy
__builtin_prefetch()'s const void * parameter without triggering
-Wdiscarded-qualifiers.

This replaces the abandoned v1 series by Daniel Gregory
(Message-ID: 20240530171948.19763-1-daniel.gregory@bytedance.com)
addressing reviewer feedback from Kardach and Hemminger.

Signed-off-by: dangshiwei <1138222970gg@gmail.com>
---
 lib/eal/riscv/include/rte_prefetch.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/eal/riscv/include/rte_prefetch.h b/lib/eal/riscv/include/rte_prefetch.h
index 42146491ea..37b4787387 100644
--- a/lib/eal/riscv/include/rte_prefetch.h
+++ b/lib/eal/riscv/include/rte_prefetch.h
@@ -18,22 +18,24 @@ extern "C" {
 
 static inline void rte_prefetch0(const volatile void *p)
 {
-	RTE_SET_USED(p);
+	__builtin_prefetch((const void *)(uintptr_t)p);
 }
 
 static inline void rte_prefetch1(const volatile void *p)
 {
-	RTE_SET_USED(p);
+	/* Zicbop has no cache-level hints, fallback to rte_prefetch0 */
+	rte_prefetch0(p);
 }
 
 static inline void rte_prefetch2(const volatile void *p)
 {
-	RTE_SET_USED(p);
+	/* Zicbop has no cache-level hints, fallback to rte_prefetch0 */
+	rte_prefetch0(p);
 }
 
 static inline void rte_prefetch_non_temporal(const volatile void *p)
 {
-	/* non-temporal version not available, fallback to rte_prefetch0 */
+	/* Zicbop has no non-temporal hint, fallback to rte_prefetch0 */
 	rte_prefetch0(p);
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-15 13:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10 13:35 [PATCH] eal/riscv: implement prefetch using __builtin_prefetch dangshiwei
2026-03-28 11:48 ` sunyuechi
2026-03-28 16:38   ` shiwei dang
2026-05-26  3:30     ` sunyuechi
2026-09-15 13:22 ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.