Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv, bpf: Use STACK_ALIGN macro for size rounding up
@ 2024-05-22  5:45 Xiao Wang
  2024-05-22  6:29 ` Pu Lehui
  2024-05-23  1:42 ` Pu Lehui
  0 siblings, 2 replies; 4+ messages in thread
From: Xiao Wang @ 2024-05-22  5:45 UTC (permalink / raw)
  To: paul.walmsley, palmer, aou, luke.r.nels, xi.wang, bjorn
  Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, linux-riscv,
	linux-kernel, bpf, pulehui, haicheng.li, Xiao Wang

Use the macro STACK_ALIGN that is defined in asm/processor.h for stack size
rounding up, just like bpf_jit_comp32.c does.

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
---
 arch/riscv/net/bpf_jit_comp64.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
index 39149ad002da..bd869d41612f 100644
--- a/arch/riscv/net/bpf_jit_comp64.c
+++ b/arch/riscv/net/bpf_jit_comp64.c
@@ -858,7 +858,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
 	stack_size += 8;
 	sreg_off = stack_size;
 
-	stack_size = round_up(stack_size, 16);
+	stack_size = round_up(stack_size, STACK_ALIGN);
 
 	if (!is_struct_ops) {
 		/* For the trampoline called from function entry,
@@ -1723,7 +1723,7 @@ void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog)
 {
 	int i, stack_adjust = 0, store_offset, bpf_stack_adjust;
 
-	bpf_stack_adjust = round_up(ctx->prog->aux->stack_depth, 16);
+	bpf_stack_adjust = round_up(ctx->prog->aux->stack_depth, STACK_ALIGN);
 	if (bpf_stack_adjust)
 		mark_fp(ctx);
 
@@ -1743,7 +1743,7 @@ void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog)
 	if (seen_reg(RV_REG_S6, ctx))
 		stack_adjust += 8;
 
-	stack_adjust = round_up(stack_adjust, 16);
+	stack_adjust = round_up(stack_adjust, STACK_ALIGN);
 	stack_adjust += bpf_stack_adjust;
 
 	store_offset = stack_adjust - 8;
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] riscv, bpf: Use STACK_ALIGN macro for size rounding up
  2024-05-22  5:45 [PATCH] riscv, bpf: Use STACK_ALIGN macro for size rounding up Xiao Wang
@ 2024-05-22  6:29 ` Pu Lehui
  2024-05-23  1:42 ` Pu Lehui
  1 sibling, 0 replies; 4+ messages in thread
From: Pu Lehui @ 2024-05-22  6:29 UTC (permalink / raw)
  To: Xiao Wang, paul.walmsley, palmer, aou, luke.r.nels, xi.wang,
	bjorn
  Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, linux-riscv,
	linux-kernel, bpf, haicheng.li


On 2024/5/22 13:45, Xiao Wang wrote:
> Use the macro STACK_ALIGN that is defined in asm/processor.h for stack size
> rounding up, just like bpf_jit_comp32.c does.
> 
> Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
> ---
>   arch/riscv/net/bpf_jit_comp64.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
> index 39149ad002da..bd869d41612f 100644
> --- a/arch/riscv/net/bpf_jit_comp64.c
> +++ b/arch/riscv/net/bpf_jit_comp64.c
> @@ -858,7 +858,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
>   	stack_size += 8;
>   	sreg_off = stack_size;
>   
> -	stack_size = round_up(stack_size, 16);
> +	stack_size = round_up(stack_size, STACK_ALIGN);
>   
>   	if (!is_struct_ops) {
>   		/* For the trampoline called from function entry,
> @@ -1723,7 +1723,7 @@ void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog)
>   {
>   	int i, stack_adjust = 0, store_offset, bpf_stack_adjust;
>   
> -	bpf_stack_adjust = round_up(ctx->prog->aux->stack_depth, 16);
> +	bpf_stack_adjust = round_up(ctx->prog->aux->stack_depth, STACK_ALIGN);
>   	if (bpf_stack_adjust)
>   		mark_fp(ctx);
>   
> @@ -1743,7 +1743,7 @@ void bpf_jit_build_prologue(struct rv_jit_context *ctx, bool is_subprog)
>   	if (seen_reg(RV_REG_S6, ctx))
>   		stack_adjust += 8;
>   
> -	stack_adjust = round_up(stack_adjust, 16);
> +	stack_adjust = round_up(stack_adjust, STACK_ALIGN);
>   	stack_adjust += bpf_stack_adjust;
>   
>   	store_offset = stack_adjust - 8;

Reviewed-by: Pu Lehui <pulehui@huawei.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] riscv, bpf: Use STACK_ALIGN macro for size rounding up
  2024-05-22  5:45 [PATCH] riscv, bpf: Use STACK_ALIGN macro for size rounding up Xiao Wang
  2024-05-22  6:29 ` Pu Lehui
@ 2024-05-23  1:42 ` Pu Lehui
  2024-05-23  3:11   ` Wang, Xiao W
  1 sibling, 1 reply; 4+ messages in thread
From: Pu Lehui @ 2024-05-23  1:42 UTC (permalink / raw)
  To: Xiao Wang
  Cc: paul.walmsley, palmer, aou, luke.r.nels, xi.wang, bjorn, ast,
	daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, linux-riscv,
	linux-kernel, bpf, haicheng.li


On 2024/5/22 13:45, Xiao Wang wrote:
> Use the macro STACK_ALIGN that is defined in asm/processor.h for stack size
> rounding up, just like bpf_jit_comp32.c does.
> 
> Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
> ---
>   arch/riscv/net/bpf_jit_comp64.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)

It met a patching conflict. I think you should target for the bpf-next tree.
https://github.com/kernel-patches/bpf/pull/7080

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* RE: [PATCH] riscv, bpf: Use STACK_ALIGN macro for size rounding up
  2024-05-23  1:42 ` Pu Lehui
@ 2024-05-23  3:11   ` Wang, Xiao W
  0 siblings, 0 replies; 4+ messages in thread
From: Wang, Xiao W @ 2024-05-23  3:11 UTC (permalink / raw)
  To: Pu Lehui
  Cc: paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, luke.r.nels@gmail.com, xi.wang@gmail.com,
	bjorn@kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com,
	song@kernel.org, yonghong.song@linux.dev,
	john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com,
	haoluo@google.com, jolsa@kernel.org,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	bpf@vger.kernel.org, Li, Haicheng



> -----Original Message-----
> From: Pu Lehui <pulehui@huawei.com>
> Sent: Thursday, May 23, 2024 9:43 AM
> To: Wang, Xiao W <xiao.w.wang@intel.com>
> Cc: paul.walmsley@sifive.com; palmer@dabbelt.com;
> aou@eecs.berkeley.edu; luke.r.nels@gmail.com; xi.wang@gmail.com;
> bjorn@kernel.org; ast@kernel.org; daniel@iogearbox.net; andrii@kernel.org;
> martin.lau@linux.dev; eddyz87@gmail.com; song@kernel.org;
> yonghong.song@linux.dev; john.fastabend@gmail.com; kpsingh@kernel.org;
> sdf@google.com; haoluo@google.com; jolsa@kernel.org; linux-
> riscv@lists.infradead.org; linux-kernel@vger.kernel.org; bpf@vger.kernel.org;
> Li, Haicheng <haicheng.li@intel.com>
> Subject: Re: [PATCH] riscv, bpf: Use STACK_ALIGN macro for size rounding up
> 
> 
> On 2024/5/22 13:45, Xiao Wang wrote:
> > Use the macro STACK_ALIGN that is defined in asm/processor.h for stack size
> > rounding up, just like bpf_jit_comp32.c does.
> >
> > Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
> > ---
> >   arch/riscv/net/bpf_jit_comp64.c | 6 +++---
> >   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> It met a patching conflict. I think you should target for the bpf-next tree.
> https://github.com/kernel-patches/bpf/pull/7080

OK, I would make v2 based on bpf-next.

BRs,
Xiao
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2024-05-23  3:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-22  5:45 [PATCH] riscv, bpf: Use STACK_ALIGN macro for size rounding up Xiao Wang
2024-05-22  6:29 ` Pu Lehui
2024-05-23  1:42 ` Pu Lehui
2024-05-23  3:11   ` Wang, Xiao W

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox