* [PATCH bpf-next] riscv, bpf: Optimize stack usage of trampoline
@ 2024-07-08 11:47 Puranjay Mohan
2024-07-08 12:02 ` Pu Lehui
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Puranjay Mohan @ 2024-07-08 11:47 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Björn Töpel, Pu Lehui, Puranjay Mohan, Paul Walmsley,
Palmer Dabbelt, Albert Ou, bpf, linux-riscv, linux-kernel
When BPF_TRAMP_F_CALL_ORIG is not set, stack space for passing arguments
on stack doesn't need to be reserved because the original function is
not called.
Only reserve space for stacked arguments when BPF_TRAMP_F_CALL_ORIG is
set.
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
---
arch/riscv/net/bpf_jit_comp64.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
index 685c7389ae7e..0795efdd3519 100644
--- a/arch/riscv/net/bpf_jit_comp64.c
+++ b/arch/riscv/net/bpf_jit_comp64.c
@@ -892,7 +892,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
stack_size += 8;
sreg_off = stack_size;
- if (nr_arg_slots - RV_MAX_REG_ARGS > 0)
+ if ((flags & BPF_TRAMP_F_CALL_ORIG) && (nr_arg_slots - RV_MAX_REG_ARGS > 0))
stack_size += (nr_arg_slots - RV_MAX_REG_ARGS) * 8;
stack_size = round_up(stack_size, STACK_ALIGN);
--
2.40.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 bpf-next] riscv, bpf: Optimize stack usage of trampoline
2024-07-08 11:47 [PATCH bpf-next] riscv, bpf: Optimize stack usage of trampoline Puranjay Mohan
@ 2024-07-08 12:02 ` Pu Lehui
2024-07-08 13:50 ` patchwork-bot+netdevbpf
2024-07-23 12:58 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 4+ messages in thread
From: Pu Lehui @ 2024-07-08 12:02 UTC (permalink / raw)
To: Puranjay Mohan
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Björn Töpel, Puranjay Mohan, Paul Walmsley,
Palmer Dabbelt, Albert Ou, bpf, linux-riscv, linux-kernel
On 2024/7/8 19:47, Puranjay Mohan wrote:
> When BPF_TRAMP_F_CALL_ORIG is not set, stack space for passing arguments
> on stack doesn't need to be reserved because the original function is
> not called.
>
> Only reserve space for stacked arguments when BPF_TRAMP_F_CALL_ORIG is
> set.
>
> Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
> ---
> arch/riscv/net/bpf_jit_comp64.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
> index 685c7389ae7e..0795efdd3519 100644
> --- a/arch/riscv/net/bpf_jit_comp64.c
> +++ b/arch/riscv/net/bpf_jit_comp64.c
> @@ -892,7 +892,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
> stack_size += 8;
> sreg_off = stack_size;
>
> - if (nr_arg_slots - RV_MAX_REG_ARGS > 0)
> + if ((flags & BPF_TRAMP_F_CALL_ORIG) && (nr_arg_slots - RV_MAX_REG_ARGS > 0))
> stack_size += (nr_arg_slots - RV_MAX_REG_ARGS) * 8;
>
> stack_size = round_up(stack_size, STACK_ALIGN);
Thanks!
Acked-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 bpf-next] riscv, bpf: Optimize stack usage of trampoline
2024-07-08 11:47 [PATCH bpf-next] riscv, bpf: Optimize stack usage of trampoline Puranjay Mohan
2024-07-08 12:02 ` Pu Lehui
@ 2024-07-08 13:50 ` patchwork-bot+netdevbpf
2024-07-23 12:58 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-07-08 13:50 UTC (permalink / raw)
To: Puranjay Mohan
Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, bjorn, pulehui,
puranjay12, paul.walmsley, palmer, aou, bpf, linux-riscv,
linux-kernel
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:
On Mon, 8 Jul 2024 11:47:58 +0000 you wrote:
> When BPF_TRAMP_F_CALL_ORIG is not set, stack space for passing arguments
> on stack doesn't need to be reserved because the original function is
> not called.
>
> Only reserve space for stacked arguments when BPF_TRAMP_F_CALL_ORIG is
> set.
>
> [...]
Here is the summary with links:
- [bpf-next] riscv, bpf: Optimize stack usage of trampoline
https://git.kernel.org/bpf/bpf-next/c/a5912c37faf7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
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 bpf-next] riscv, bpf: Optimize stack usage of trampoline
2024-07-08 11:47 [PATCH bpf-next] riscv, bpf: Optimize stack usage of trampoline Puranjay Mohan
2024-07-08 12:02 ` Pu Lehui
2024-07-08 13:50 ` patchwork-bot+netdevbpf
@ 2024-07-23 12:58 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-07-23 12:58 UTC (permalink / raw)
To: Puranjay Mohan
Cc: linux-riscv, ast, daniel, andrii, martin.lau, eddyz87, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, bjorn,
pulehui, puranjay12, paul.walmsley, palmer, aou, bpf,
linux-kernel
Hello:
This patch was applied to riscv/linux.git (for-next)
by Daniel Borkmann <daniel@iogearbox.net>:
On Mon, 8 Jul 2024 11:47:58 +0000 you wrote:
> When BPF_TRAMP_F_CALL_ORIG is not set, stack space for passing arguments
> on stack doesn't need to be reserved because the original function is
> not called.
>
> Only reserve space for stacked arguments when BPF_TRAMP_F_CALL_ORIG is
> set.
>
> [...]
Here is the summary with links:
- [bpf-next] riscv, bpf: Optimize stack usage of trampoline
https://git.kernel.org/riscv/c/a5912c37faf7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
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-07-23 12:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-08 11:47 [PATCH bpf-next] riscv, bpf: Optimize stack usage of trampoline Puranjay Mohan
2024-07-08 12:02 ` Pu Lehui
2024-07-08 13:50 ` patchwork-bot+netdevbpf
2024-07-23 12:58 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox