riscv, bpf: Optimize stack usage of trampoline
Subsystems (3)
Puranjay Mohan
reviewerPATCH 1/1 riscv, bpf: Optimize stack usage of trampoline
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.
--- arch/riscv/net/bpf_jit_comp64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/net/bpf_jit_comp64.c +1 -1
@@ -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 );
Signature · 1 line
2.40.1
Quoted 17 lines · Puranjay Mohan
When
BPF_TRAMP_F_CALL_ORIGis 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_ORIGis set.Signed-off-by Puranjay Mohan <[email protected]>--- arch/riscv/net/bpf_jit_comp64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/net/bpf_jit_comp64.c +0
-0
arch/riscv/net/bpf_jit_comp64.c static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, · line 898
Quoted 8 lines
arch/riscv/net/bpf_jit_comp64.c +1
-1@@ -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!
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Quoted 8 lines · On Mon, 8 Jul 2024 11:47:58 +0000 you wrote:
When
BPF_TRAMP_F_CALL_ORIGis 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_ORIGis 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
This patch was applied to riscv/linux.git (for-next) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to riscv/linux.git (for-next) by Daniel Borkmann <[email protected]>:
Quoted 8 lines · On Mon, 8 Jul 2024 11:47:58 +0000 you wrote:
When
BPF_TRAMP_F_CALL_ORIGis 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_ORIGis 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html