On Tue, 2 Jun 2026 at 22:59, Varun R Mallya <[email protected]> wrote: > > On RISC-V, the current task pointer is stored in the thread pointer > register (tp). Emit a single `mv a5, tp` instead of a full helper > call for BPF_FUNC_get_current_task and BPF_FUNC_get_current_task_btf. > > Register bpf_jit_inlines_helper_call() entries for both helpers so the > verifier treats them as inlined, and add the expected `mv a5, tp` > annotation to the riscv64 selftests. > > The following show changes before and after this patch. > > Before patch: > > auipc t1,0x817a # load upper PC-relative address > jalr -2004(t1) # call bpf_get_current_task helper > mv a5,a0 # move return value to BPF_REG_0 > > After patch: > > mv a5,tp # directly: a5 = current (tp = thread pointer) > > Benchmark (bpf_prog_test_run wrapping bpf_get_current_task in loop, > batch=100, 10s, QEMU RISC-V): > > | runs/sec | helper-calls/sec | ns/call > -------------+-----------+------------------+--------- > Before patch | 173,490 | 17,349,090 | 57 > After patch | 320,497 | 32,049,780 | 31 > -------------+-----------+------------------+--------- > Improvement | +84.7% | +84.7% | -45.6% > > Signed-off-by: Varun R Mallya <[email protected]>
Acked-by: Björn Töpel <[email protected]>

