[PATCH bpf-next 3/3] bpf, x86: Inline bpf_kptr_xchg() on x86-64

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux