public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: dangshiwei <1138222970gg@gmail.com>
To: dev@dpdk.org
Cc: stanislaw.kardach@gmail.com, sunyuechi@iscas.ac.cn,
	stephen@networkplumber.org, david.marchand@redhat.com,
	dangshiwei <1138222970gg@gmail.com>
Subject: [PATCH] eal/riscv: implement prefetch using __builtin_prefetch
Date: Tue, 10 Mar 2026 21:35:24 +0800	[thread overview]
Message-ID: <20260310133524.28087-1-1138222970gg@gmail.com> (raw)

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


             reply	other threads:[~2026-03-10 13:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 13:35 dangshiwei [this message]
2026-03-28 11:48 ` [PATCH] eal/riscv: implement prefetch using __builtin_prefetch sunyuechi
2026-03-28 16:38   ` shiwei dang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260310133524.28087-1-1138222970gg@gmail.com \
    --to=1138222970gg@gmail.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=stanislaw.kardach@gmail.com \
    --cc=stephen@networkplumber.org \
    --cc=sunyuechi@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox