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

From: Baolu Lu
Date: Tue Apr 23 2024 - 23:46:28 EST


On 4/15/24 12:23 AM, 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(-)

Patch has been queued for iommu/vt-d.

Best regards,
baolu