diff mbox series

RISC-V: Use GCC __builtin_prefetch() to implement prefetch()

Message ID 20230726074732.32981-1-wang_yang6662023@163.com (mailing list archive)
State Handled Elsewhere
Headers show
Series RISC-V: Use GCC __builtin_prefetch() to implement prefetch() | expand

Checks

Context Check Description
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be for-next at HEAD 471aba2e4760
conchuod/fixes_present success Fixes tag not required for -next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 4 and now 4
conchuod/verify_signedoff fail author Signed-off-by missing
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 2810 this patch: 2810
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 15878 this patch: 15878
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 3 this patch: 3
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch fail ERROR: #define of 'ARCH_HAS_PREFETCH' is wrong - use Kconfig variables or standard guards instead ERROR: #define of 'ARCH_HAS_PREFETCHW' is wrong - use Kconfig variables or standard guards instead
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success No Fixes tag
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

wang_yang July 26, 2023, 7:47 a.m. UTC
GCC's __builtin_prefetch() was introduced a long time ago, all supported GCC
 versions have it.So this patch is to use it for implementing the prefetch.

 RISC-V Cache Management Operation instructions has been supported by GCC last
 year.you can refer to
 https://github.com/gcc-mirror/gcc/commit/3df3ca9014f94fe4af07444fea19b4ab29ba8e73
 It is worth noting that CPU based on RISC-V should support Zicbop extension.

 This has been already done on other architectures (see the commit:
 https://github.com/torvalds/linux/commit/0453fb3c528c5eb3483441a466b24a4cb409eec5).

Signed-off-by: Wang Yang <yangwang@nj.iscas.ac.cn>
---
 arch/riscv/include/asm/processor.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Conor Dooley July 26, 2023, 9:27 a.m. UTC | #1
Hey,

On Wed, Jul 26, 2023 at 03:47:32PM +0800, wang_yang wrote:
>  GCC's __builtin_prefetch() was introduced a long time ago, all supported GCC
>  versions have it.So this patch is to use it for implementing the prefetch.
> 
>  RISC-V Cache Management Operation instructions has been supported by GCC last
>  year.you can refer to
>  https://github.com/gcc-mirror/gcc/commit/3df3ca9014f94fe4af07444fea19b4ab29ba8e73

This should be in a Link: tag.

>  It is worth noting that CPU based on RISC-V should support Zicbop extension.

How do you intend determining whether the CPU supports Zicbop?

>  This has been already done on other architectures (see the commit:
>  https://github.com/torvalds/linux/commit/0453fb3c528c5eb3483441a466b24a4cb409eec5).

That's not how to describe commits, please see how that is done
elsewhere in the git history.

> 
> Signed-off-by: Wang Yang <yangwang@nj.iscas.ac.cn>

WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#6: 
 GCC's __builtin_prefetch() was introduced a long time ago, all supported GCC

ERROR: Missing Signed-off-by: line by nominal patch author 'wang_yang <wang_yang6662023@163.com>'

> ---
>  arch/riscv/include/asm/processor.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h
> index c950a8d9edef..f16d4c85ca5b 100644
> --- a/arch/riscv/include/asm/processor.h
> +++ b/arch/riscv/include/asm/processor.h
> @@ -70,6 +70,17 @@ extern void start_thread(struct pt_regs *regs,
>  
>  extern unsigned long __get_wchan(struct task_struct *p);
>  
> +#define ARCH_HAS_PREFETCH
> +static inline void prefetch(const void *ptr)
> +{
> +	__builtin_prefetch(ptr, 0, 3);

As far as I can tell, this does not do anything and will be removed by
the compiler. Please take a look at how other extensions are implemented.

Also, why 3? (Your answer should be in the commit message)

Thanks,
Conor.

> +}
> +
> +#define ARCH_HAS_PREFETCHW
> +static inline void prefetchw(const void *ptr)
> +{
> +	__builtin_prefetch(ptr, 1, 3);
> +}
>  
>  static inline void wait_for_interrupt(void)
>  {
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h
index c950a8d9edef..f16d4c85ca5b 100644
--- a/arch/riscv/include/asm/processor.h
+++ b/arch/riscv/include/asm/processor.h
@@ -70,6 +70,17 @@  extern void start_thread(struct pt_regs *regs,
 
 extern unsigned long __get_wchan(struct task_struct *p);
 
+#define ARCH_HAS_PREFETCH
+static inline void prefetch(const void *ptr)
+{
+	__builtin_prefetch(ptr, 0, 3);
+}
+
+#define ARCH_HAS_PREFETCHW
+static inline void prefetchw(const void *ptr)
+{
+	__builtin_prefetch(ptr, 1, 3);
+}
 
 static inline void wait_for_interrupt(void)
 {