[PATCH V3 3/5] raid6: riscv: Prevent compiler with vector support to build already vectorized code

Chunyan Zhang posted 5 patches 6 months, 3 weeks ago
[PATCH V3 3/5] raid6: riscv: Prevent compiler with vector support to build already vectorized code
Posted by Chunyan Zhang 6 months, 3 weeks ago
To avoid the inline assembly code to break what the compiler could have
vectorized, this code must be built without compiler support for vector.

Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
---
 lib/raid6/rvv.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/raid6/rvv.c b/lib/raid6/rvv.c
index 89da5fc247aa..015f3ee4da25 100644
--- a/lib/raid6/rvv.c
+++ b/lib/raid6/rvv.c
@@ -20,6 +20,10 @@ static int rvv_has_vector(void)
 	return has_vector();
 }
 
+#ifdef __riscv_vector
+#error "This code must be built without compiler support for vector"
+#endif
+
 static void raid6_rvv1_gen_syndrome_real(int disks, unsigned long bytes, void **ptrs)
 {
 	u8 **dptr = (u8 **)ptrs;
-- 
2.34.1
Re: [PATCH V3 3/5] raid6: riscv: Prevent compiler with vector support to build already vectorized code
Posted by Paul Walmsley 2 months, 2 weeks ago
Hi,

On Fri, 18 Jul 2025, Chunyan Zhang wrote:

> To avoid the inline assembly code to break what the compiler could have
> vectorized, this code must be built without compiler support for vector.
> 
> Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>

This one has been queued with a somewhat modified commit message to 
reflect what I thought the intention is.  But I might be wrong.  Can you 
check it, please?

thanks,


- Paul

From: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
Date: Mon, 17 Nov 2025 21:19:24 -0700

raid6: riscv: Prevent compiler from breaking inline vector assembly code

To prevent the compiler from breaking the inline vector assembly code,
this code must be built without compiler support for vector.

Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
Link: https://patch.msgid.link/20250718072711.3865118-4-zhangchunyan@iscas.ac.cn
[pjw@kernel.org: cleaned up commit message]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
---
 lib/raid6/rvv.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/raid6/rvv.c b/lib/raid6/rvv.c
index 89da5fc247aa..015f3ee4da25 100644
--- a/lib/raid6/rvv.c
+++ b/lib/raid6/rvv.c
@@ -20,6 +20,10 @@ static int rvv_has_vector(void)
 	return has_vector();
 }
 
+#ifdef __riscv_vector
+#error "This code must be built without compiler support for vector"
+#endif
+
 static void raid6_rvv1_gen_syndrome_real(int disks, unsigned long bytes, void **ptrs)
 {
 	u8 **dptr = (u8 **)ptrs;
-- 
2.48.1
Re: [PATCH V3 3/5] raid6: riscv: Prevent compiler with vector support to build already vectorized code
Posted by Chunyan Zhang 2 months, 2 weeks ago
Hi Paul,

On Tue, 25 Nov 2025 at 17:26, Paul Walmsley <pjw@kernel.org> wrote:
>
> Hi,
>
> On Fri, 18 Jul 2025, Chunyan Zhang wrote:
>
> > To avoid the inline assembly code to break what the compiler could have
> > vectorized, this code must be built without compiler support for vector.
> >
> > Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
>
> This one has been queued with a somewhat modified commit message to
> reflect what I thought the intention is.  But I might be wrong.  Can you
> check it, please?
>
> thanks,
>
>
> - Paul
>
> From: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
> Date: Mon, 17 Nov 2025 21:19:24 -0700
>
> raid6: riscv: Prevent compiler from breaking inline vector assembly code
>
> To prevent the compiler from breaking the inline vector assembly code,
> this code must be built without compiler support for vector.

This is more clear and easier to understand.

Thanks for the review and rephrasing the commit message.

Chunyan

>
> Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
> Link: https://patch.msgid.link/20250718072711.3865118-4-zhangchunyan@iscas.ac.cn
> [pjw@kernel.org: cleaned up commit message]
> Signed-off-by: Paul Walmsley <pjw@kernel.org>
> ---
>  lib/raid6/rvv.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/lib/raid6/rvv.c b/lib/raid6/rvv.c
> index 89da5fc247aa..015f3ee4da25 100644
> --- a/lib/raid6/rvv.c
> +++ b/lib/raid6/rvv.c
> @@ -20,6 +20,10 @@ static int rvv_has_vector(void)
>         return has_vector();
>  }
>
> +#ifdef __riscv_vector
> +#error "This code must be built without compiler support for vector"
> +#endif
> +
>  static void raid6_rvv1_gen_syndrome_real(int disks, unsigned long bytes, void **ptrs)
>  {
>         u8 **dptr = (u8 **)ptrs;
> --
> 2.48.1
>