Re: [PATCH 3/3] KVM/VMX: Use try_cmpxchg64() in posted_intr.c

From: Sean Christopherson
Date: Fri Jan 15 2021 - 14:29:29 EST


On Tue, Dec 15, 2020, Uros Bizjak wrote:
> Use try_cmpxchg64() instead of cmpxchg64() to reuse flags from
> cmpxchg/cmpxchg8b instruction. For 64 bit targets flags reuse
> avoids a CMP instruction,

It ends up doing way more (in a good way) than eliminate the CMP, at least with
gcc-10. There's a ripple effect and the compiler ends up generating the loop
in-line, whereas without the "try" version the loop is put out-of-line.

> while for 32 bit targets flags reuse avoids XOR/XOR/OR instruction sequence.
>
> Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>

Reviewed-by: Sean Christopherson <seanjc@xxxxxxxxxx>