mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
Merge branch 'risc-v-jit-support-for-bpf_get_current_task-_btf'
Varun R Mallya says: ==================== RISC-V JIT support for bpf_get_current_task/_btf These two patches add support for the bpf_get_current_task and bpf_get_current_task_btf kfuncs in RISC-V JIT and add a selftest. The first patch adds support for cpu and feature detection on the JIT disassembly helper function as RISC-V JITed code was not being disassembled using `LLVMCreateDisasm` as it was missing the "+c" CPU feature and JITed code contained RISC-V Compressed (C) Extension. This patch generalizes that to detect CPU features and enables testing on more RISC-V JIT work ahead. The second patch, which actually adds this support has been benchmarked on QEMU RISC-V and shows significant improvements. It was benchmarked using a simple loop inside a bpf program that ran bpf_get_current_task() and execution time was measured. It used bpf_prog_test_run_opts() to repeatedly trigger the BPF program. The loop ran in 1 second intervals and it kept firing bpf_prog_test_run_opts() as fast as possible until a second had elapsed and then reported statistics. ==================== Link: https://patch.msgid.link/20260602205847.102825-1-varunrmallya@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
commit
b984529052
|
|
@ -1808,6 +1808,13 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
|
|||
break;
|
||||
}
|
||||
|
||||
/* Implement helper call to bpf_get_current_task/_btf() inline */
|
||||
if (insn->src_reg == 0 && (insn->imm == BPF_FUNC_get_current_task ||
|
||||
insn->imm == BPF_FUNC_get_current_task_btf)) {
|
||||
emit_mv(bpf_to_rv_reg(BPF_REG_0, ctx), RV_REG_TP, ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
mark_call(ctx);
|
||||
ret = bpf_jit_get_func_addr(ctx->prog, insn, extra_pass,
|
||||
&addr, &fixed_addr);
|
||||
|
|
@ -2138,6 +2145,8 @@ bool bpf_jit_inlines_helper_call(s32 imm)
|
|||
{
|
||||
switch (imm) {
|
||||
case BPF_FUNC_get_smp_processor_id:
|
||||
case BPF_FUNC_get_current_task:
|
||||
case BPF_FUNC_get_current_task_btf:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -96,10 +96,19 @@ static int disasm_one_func(FILE *text_out, uint8_t *image, __u32 len)
|
|||
__u32 *label_pc, pc;
|
||||
int i, cnt, err = 0;
|
||||
char buf[64];
|
||||
char *cpu, *features;
|
||||
|
||||
triple = LLVMGetDefaultTargetTriple();
|
||||
ctx = LLVMCreateDisasm(triple, &labels, 0, NULL, lookup_symbol);
|
||||
if (!ASSERT_OK_PTR(ctx, "LLVMCreateDisasm")) {
|
||||
|
||||
cpu = LLVMGetHostCPUName();
|
||||
features = LLVMGetHostCPUFeatures();
|
||||
|
||||
ctx = LLVMCreateDisasmCPUFeatures(triple, cpu, features, &labels, 0, NULL, lookup_symbol);
|
||||
|
||||
LLVMDisposeMessage(cpu);
|
||||
LLVMDisposeMessage(features);
|
||||
|
||||
if (!ASSERT_OK_PTR(ctx, "LLVMCreateDisasmCPUFeatures")) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ __arch_x86_64
|
|||
__jited(" addq %gs:{{.*}}, %rax")
|
||||
__arch_arm64
|
||||
__jited(" mrs x8, SP_EL0")
|
||||
__arch_riscv64
|
||||
__jited(" mv a5, tp")
|
||||
int inline_bpf_get_current_task(void)
|
||||
{
|
||||
bpf_get_current_task();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user