Re: [PATCH] iommu/amd: Use try_cmpxchg64 in alloc_pte and free_clear_pte
From: Joerg Roedel
Date: Thu Jun 23 2022 - 03:44:25 EST
On Wed, May 25, 2022 at 04:54:16PM +0200, Uros Bizjak wrote:
> Use try_cmpxchg64 instead of cmpxchg64 (*ptr, old, new) != old in
> alloc_pte and free_clear_pte. cmpxchg returns success in ZF flag, so this
> change saves a compare after cmpxchg (and related move instruction
> in front of cmpxchg). Also, remove racy explicit assignment to pteval
> when cmpxchg fails, this is what try_cmpxchg does implicitly from
> *pte in an atomic way.
>
> Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
> Cc: Joerg Roedel <joro@xxxxxxxxxx>
> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
> Cc: Will Deacon <will@xxxxxxxxxx>
> ---
> drivers/iommu/amd/io_pgtable.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
Applied, thanks.