Re: [PATCH] x86/bpf: Avoid emitting LOCK prefix for XCHG atomic ops
From: Alexei Starovoitov
Date: Sun Dec 21 2025 - 19:56:40 EST
On Mon, Dec 8, 2025 at 6:34 AM Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
>
> The x86 XCHG instruction is implicitly locked when one of the
> operands is a memory location, making an explicit LOCK prefix
> unnecessary.
>
> Stop emitting the LOCK prefix for BPF_XCHG in the JIT atomic
> read-modify-write helpers. This avoids redundant instruction
> prefixes while preserving correct atomic semantics.
>
> No functional change for other atomic operations.
>
> Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
> Cc: Alexei Starovoitov <ast@xxxxxxxxxx>
> Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
> Cc: Andrii Nakryiko <andrii@xxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Borislav Petkov <bp@xxxxxxxxx>
> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
> ---
> arch/x86/net/bpf_jit_comp.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
Applied to bpf-next.