[PATCH bpf-next 0/3] Use bpf_prog_pack for RV64 bpf trampoline

Pu Lehui pulehui at huaweicloud.com
Tue Jan 23 02:32:38 PST 2024


We used bpf_prog_pack to aggregate bpf programs into huge page to
relieve the iTLB pressure on the system. We can apply it to bpf
trampoline, as Song had been implemented it in core and x86 [0]. This
patch is going to use bpf_prog_pack to RV64 bpf trampoline. Since Song
and Puranjay have done a lot of work for bpf_prog_pack on RV64,
implementing this function will be easy. But one thing to mention is
that emit_call in RV64 will generate the maximum number of instructions
during dry run, but during real patching it may be optimized to 1
instruction due to distance. This is no problem as it does not overflow
the allocated RO image.

Tests about regular trampoline and struct_ops trampoline have passed, as
well as "test_verifier" with no failure cases.

Link: https://lore.kernel.org/all/20231206224054.492250-1-song@kernel.org [0]

Pu Lehui (3):
  bpf: Use precise image size for struct_ops trampoline
  bpf: Keep im address consistent between dry run and real patching
  riscv, bpf: Use bpf_prog_pack for RV64 bpf trampoline

 arch/arm64/net/bpf_jit_comp.c   |  7 ++--
 arch/riscv/net/bpf_jit_comp64.c | 66 +++++++++++++++++++++++----------
 arch/s390/net/bpf_jit_comp.c    |  7 ++--
 arch/x86/net/bpf_jit_comp.c     |  7 ++--
 include/linux/bpf.h             |  4 +-
 kernel/bpf/bpf_struct_ops.c     |  4 +-
 kernel/bpf/trampoline.c         | 43 +++++++++++----------
 7 files changed, 81 insertions(+), 57 deletions(-)

-- 
2.34.1




More information about the linux-riscv mailing list