From: Hou Tao <houtao1@xxxxxxxxxx> x86-64 supports BPF_XCHG atomic operation. The implementation of xchg() and atomic_xchg() are also the same, because both of these two APIs use arch_xchg() to implement the exchange. So enabling the inlining of bpf_kptr_xchg() on x86-64. After the optimization, the performance of an artificial test which fetches the pointers through bpf_kptr_xchg() and frees the pointers through bpf_obj_drop() increases 4%. Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx> --- arch/x86/net/bpf_jit_comp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 49dac4d22a7b..9466c979ef9a 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -3201,3 +3201,8 @@ void arch_bpf_stack_walk(bool (*consume_fn)(void *cookie, u64 ip, u64 sp, u64 bp #endif WARN(1, "verification of programs using bpf_throw should have failed\n"); } + +bool bpf_jit_supports_ptr_xchg(void) +{ + return true; +} -- 2.29.2