From: Yuqi Jin Date: Thu, 27 Aug 2020 08:43:54 +0000 (+0800) Subject: iommu/iova: Replace cmpxchg with xchg in queue_iova X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ba328f82613260a098de7b4aff58743cd8733507;p=linux.git iommu/iova: Replace cmpxchg with xchg in queue_iova The performance of the atomic_xchg is better than atomic_cmpxchg because no comparison is required. While the value of @fq_timer_on can only be 0 or 1. Let's use atomic_xchg instead of atomic_cmpxchg here because we only need to check that the value changes from 0 to 1 or from 1 to 1. Signed-off-by: Yuqi Jin Signed-off-by: Shaokun Zhang Reviewed-by: Robin Murphy Cc: Joerg Roedel Link: https://lore.kernel.org/r/1598517834-30275-1-git-send-email-zhangshaokun@hisilicon.com Signed-off-by: Joerg Roedel --- diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index 45a251da54537..30d969a4c5fde 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -579,7 +579,7 @@ void queue_iova(struct iova_domain *iovad, /* Avoid false sharing as much as possible. */ if (!atomic_read(&iovad->fq_timer_on) && - !atomic_cmpxchg(&iovad->fq_timer_on, 0, 1)) + !atomic_xchg(&iovad->fq_timer_on, 1)) mod_timer(&iovad->fq_timer, jiffies + msecs_to_jiffies(IOVA_FQ_TIMEOUT)); }