* [PATCH bpf-next v1] selftests/bpf: Test jited inline of bpf_get_smp_processor_id() for RISC-V
@ 2026-07-22 7:01 Tiezhu Yang
2026-07-23 3:31 ` Pu Lehui
0 siblings, 1 reply; 2+ messages in thread
From: Tiezhu Yang @ 2026-07-22 7:01 UTC (permalink / raw)
To: Andrii Nakryiko, Eduard Zingerman, Ihor Solodrai,
Björn Töpel, Pu Lehui, Puranjay Mohan
Cc: bpf, linux-kernel
Add the JITed inline instruction of bpf_get_smp_processor_id() for RISC-V
to pass the test case.
On RISC-V, the 'cpu' field of 'struct thread_info' resides at offset 0x20,
BPF_REG_0 maps to the a5 register, and the thread pointer (tp) is used as
the base address. Therefore, the JIT compiler emits "lw a5, 0x20(tp)" to
optimize this helper call.
Tested on a RISC-V virtual machine.
Before:
$ sudo ./test_progs -t verifier_jit_inline
#610/1 verifier_jit_inline/inline_bpf_get_current_task:OK
#610/2 verifier_jit_inline/inline_bpf_get_smp_processor_id:SKIP
#610 verifier_jit_inline:OK (SKIP: 1/2)
Summary: 1/1 PASSED, 1 SKIPPED, 0 FAILED
After:
$ sudo ./test_progs -t verifier_jit_inline
#610/1 verifier_jit_inline/inline_bpf_get_current_task:OK
#610/2 verifier_jit_inline/inline_bpf_get_smp_processor_id:OK
#610 verifier_jit_inline:OK
Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
tools/testing/selftests/bpf/progs/verifier_jit_inline.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/verifier_jit_inline.c b/tools/testing/selftests/bpf/progs/verifier_jit_inline.c
index 02e562f56f9d..c696baa5364b 100644
--- a/tools/testing/selftests/bpf/progs/verifier_jit_inline.c
+++ b/tools/testing/selftests/bpf/progs/verifier_jit_inline.c
@@ -25,6 +25,8 @@ SEC("fentry/bpf_fentry_test2")
__success __retval(0)
__arch_loongarch
__jited(" ld.wu $a5, $tp, 16")
+__arch_riscv64
+__jited(" lw a5, 0x20(tp)")
int inline_bpf_get_smp_processor_id(void)
{
bpf_get_smp_processor_id();
--
2.42.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH bpf-next v1] selftests/bpf: Test jited inline of bpf_get_smp_processor_id() for RISC-V
2026-07-22 7:01 [PATCH bpf-next v1] selftests/bpf: Test jited inline of bpf_get_smp_processor_id() for RISC-V Tiezhu Yang
@ 2026-07-23 3:31 ` Pu Lehui
0 siblings, 0 replies; 2+ messages in thread
From: Pu Lehui @ 2026-07-23 3:31 UTC (permalink / raw)
To: Tiezhu Yang, Andrii Nakryiko, Eduard Zingerman, Ihor Solodrai,
Björn Töpel, Puranjay Mohan
Cc: bpf, linux-kernel
On 2026/7/22 15:01, Tiezhu Yang wrote:
> Add the JITed inline instruction of bpf_get_smp_processor_id() for RISC-V
> to pass the test case.
>
> On RISC-V, the 'cpu' field of 'struct thread_info' resides at offset 0x20,
> BPF_REG_0 maps to the a5 register, and the thread pointer (tp) is used as
> the base address. Therefore, the JIT compiler emits "lw a5, 0x20(tp)" to
> optimize this helper call.
>
> Tested on a RISC-V virtual machine.
>
> Before:
> $ sudo ./test_progs -t verifier_jit_inline
> #610/1 verifier_jit_inline/inline_bpf_get_current_task:OK
> #610/2 verifier_jit_inline/inline_bpf_get_smp_processor_id:SKIP
> #610 verifier_jit_inline:OK (SKIP: 1/2)
> Summary: 1/1 PASSED, 1 SKIPPED, 0 FAILED
>
> After:
> $ sudo ./test_progs -t verifier_jit_inline
> #610/1 verifier_jit_inline/inline_bpf_get_current_task:OK
> #610/2 verifier_jit_inline/inline_bpf_get_smp_processor_id:OK
> #610 verifier_jit_inline:OK
> Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> tools/testing/selftests/bpf/progs/verifier_jit_inline.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/progs/verifier_jit_inline.c b/tools/testing/selftests/bpf/progs/verifier_jit_inline.c
> index 02e562f56f9d..c696baa5364b 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_jit_inline.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_jit_inline.c
> @@ -25,6 +25,8 @@ SEC("fentry/bpf_fentry_test2")
> __success __retval(0)
> __arch_loongarch
> __jited(" ld.wu $a5, $tp, 16")
> +__arch_riscv64
> +__jited(" lw a5, 0x20(tp)")
> int inline_bpf_get_smp_processor_id(void)
> {
> bpf_get_smp_processor_id();
Hi Tiezhu,
There are many places in selftest can be add __arch_riscv64 tag, I think
we can enable them witch one patch.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-23 3:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-22 7:01 [PATCH bpf-next v1] selftests/bpf: Test jited inline of bpf_get_smp_processor_id() for RISC-V Tiezhu Yang
2026-07-23 3:31 ` Pu Lehui
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®