Commit ba328f82 authored by Yuqi Jin's avatar Yuqi Jin Committed by Joerg Roedel

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: default avatarYuqi Jin <jinyuqi@huawei.com>
Signed-off-by: default avatarShaokun Zhang <zhangshaokun@hisilicon.com>
Reviewed-by: default avatarRobin Murphy <robin.murphy@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Link: https://lore.kernel.org/r/1598517834-30275-1-git-send-email-zhangshaokun@hisilicon.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 4604393c
...@@ -579,7 +579,7 @@ void queue_iova(struct iova_domain *iovad, ...@@ -579,7 +579,7 @@ void queue_iova(struct iova_domain *iovad,
/* Avoid false sharing as much as possible. */ /* Avoid false sharing as much as possible. */
if (!atomic_read(&iovad->fq_timer_on) && 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, mod_timer(&iovad->fq_timer,
jiffies + msecs_to_jiffies(IOVA_FQ_TIMEOUT)); jiffies + msecs_to_jiffies(IOVA_FQ_TIMEOUT));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment