Re: [PATCH] iommu/intel: Use try_cmpxchg64{,_local}() in iommu.c

From: Jason Gunthorpe
Date: Mon Apr 15 2024 - 12:32:10 EST


On Sun, Apr 14, 2024 at 06:23:11PM +0200, Uros Bizjak wrote:
> Replace this pattern in iommu.c:
>
> cmpxchg64{,_local}(*ptr, 0, new) != 0
>
> ... with the simpler and faster:
>
> !try_cmpxchg64{,_local}(*ptr, &tmp, new)
>
> The x86 CMPXCHG instruction returns success in the ZF flag, so this change
> saves a compare after the CMPXCHG.
>
> No functional change intended.
>
> Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
> Cc: David Woodhouse <dwmw2@xxxxxxxxxxxxx>
> Cc: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
> Cc: Joerg Roedel <joro@xxxxxxxxxx>
> Cc: Will Deacon <will@xxxxxxxxxx>
> Cc: Robin Murphy <robin.murphy@xxxxxxx>
> ---
> drivers/iommu/intel/iommu.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Jason