eal/riscv: implement prefetch using __builtin_prefetch
PATCH 1/1 eal/riscv: implement prefetch using __builtin_prefetch
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: [email protected]) addressing reviewer feedback from Kardach and Hemminger.
--- lib/eal/riscv/include/rte_prefetch.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
lib/eal/riscv/include/rte_prefetch.h +6 -4
@@ -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); }
Signature · 1 line
2.43.0
Hi,
In the previous prefetch discussion:
"Let's hope you get such hardware by the next release. We will need reviews too."
https://inbox.dpdk.org/dev/CAJFAV8zatWiYQoe4kETcM61=OS1k=QaPRsNjYSYDspKC+voiQw@mail.gmail.com/
Could you share your test environment and results?
And DPDK requires a real name in the Signed-off-by line.
Hi ,
Thanks for the review. I'll address both points (real name in Signed-off-by and test results) together in v2 once I have access to physical RISC-V hardware.
Best regards, Dang Shiwei
Quoted 15 lines · sunyuechi
Hi,
In the previous prefetch discussion:
"Let's hope you get such hardware by the next release. We will need reviews too."
https://inbox.dpdk.org/dev/CAJFAV8zatWiYQoe4kETcM61=OS1k=QaPRsNjYSYDspKC+voiQw@mail.gmail.com/
Could you share your test environment and results?
And DPDK requires a real name in the Signed-off-by line.
Quoted 7 lines · shiwei dang
Hi ,
Thanks for the review. I'll address both points (real name in Signed-off-by and test results) together in v2 once I have access to physical RISC-V hardware.
Best regards, Dang Shiwei
Hi,
Gentle ping — any update on v2?
Quoted 11 lines · On Tue, 10 Mar 2026 21:35:24 +0800 dangshiwei <[email protected]> wrote:
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()andrte_prefetch2()fall back torte_prefetch0(). The volatile qualifier is stripped viauintptr_tcast to satisfy __builtin_prefetch()'s const void * parameter without triggering -Wdiscarded-qualifiers.
Quoted 6 lines
This replaces the abandoned v1 series by Daniel Gregory (Message-ID: [email protected]) addressing reviewer feedback from Kardach and Hemminger.
Signed-off-by dangshiwei <[email protected]>---
There is another patch for x86 that does same thing.
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
Would be good to have single common file for all arch.