[PATCH bpf-next 0/4] riscv, bpf: Miscellaneous JIT optimizations

From: Pu Lehui

Date: Tue Dec 01 2026 - 08:29:46 EST


From: Pu Lehui <pulehui@xxxxxxxxxx>

This series brings four improvements to the RISC-V BPF JIT:

- Patch 1 fixes forward jump offset calculation across JIT passes so
large programs (e.g. no_limits/dump) converge in 2 passes instead of
hitting NR_JIT_ITERATIONS.
- Patch 2 reuses the tailcall epilogue across multiple bpf_tail_call()
sites on RV64 to shrink JIT image size.
- Patch 3 introduces a per-image PLT on RV64 to eliminate stop_machine()
in bpf_arch_text_poke(), reducing trampoline attach/detach latency.
- Patch 4 removes the now-redundant RV64 arch_bpf_trampoline_skip() and
4-byte-aligns the skip nop in invoke_bpf_prog().

This series has been tested with riscv-bpf-daily and passed:
https://github.com/pulehui/riscv-bpf-daily/pull/26

Pu Lehui (4):
riscv, bpf: Fix forward jump offset calculation during JIT passes
riscv, bpf: Reuse tailcall epilogue across tailcall sites
riscv, bpf: Eliminate stop_machine in bpf_arch_text_poke with
per-image PLT
riscv, bpf: Remove arch_bpf_trampoline_skip

arch/riscv/net/bpf_jit.h | 19 ++--
arch/riscv/net/bpf_jit_comp32.c | 5 +-
arch/riscv/net/bpf_jit_comp64.c | 192 +++++++++++++++++++++++---------
arch/riscv/net/bpf_jit_core.c | 51 ++++-----
4 files changed, 176 insertions(+), 91 deletions(-)

--
2.34.1