Re: [PATCH bpf-next 2/3] bpf, x86: Don't generate lock prefix for BPF_XCHG

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

 



On 12/19/23 2:56 PM, Hou Tao wrote:
From: Hou Tao <houtao1@xxxxxxxxxx>

According to the implementation of atomic_xchg() under x86-64, the lock
prefix is not necessary for BPF_XCHG atomic operation, so just remove
it.

It's probably a good idea for the commit message to explicitly quote the
Intel docs in here, so it's easier to find on why the lock prefix would
not be needed for the xchg op.

Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx>
---
  arch/x86/net/bpf_jit_comp.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index c89a4abdd726..49dac4d22a7b 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -990,7 +990,9 @@ static int emit_atomic(u8 **pprog, u8 atomic_op,
  {
  	u8 *prog = *pprog;
- EMIT1(0xF0); /* lock prefix */
+	/* lock prefix */
+	if (atomic_op != BPF_XCHG)
+		EMIT1(0xF0);
maybe_emit_mod(&prog, dst_reg, src_reg, bpf_size == BPF_DW);





[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