dmaengine:idxd: Use local64_try_cmpxchg in perfmon_pmu_event_update
authorUros Bizjak <ubizjak@gmail.com>
Mon, 3 Jul 2023 14:52:37 +0000 (16:52 +0200)
committerVinod Koul <vkoul@kernel.org>
Tue, 1 Aug 2023 18:02:06 +0000 (23:32 +0530)
commitcae701b9ccf128edea26982f73178087fc3ad180
tree7056cd55ddf4cfe83b07414e6b4b17a34128e18e
parentf1de55ff7c704b48389987f6c71ca31dc8cffe8d
dmaengine:idxd: Use local64_try_cmpxchg in perfmon_pmu_event_update

Use local64_try_cmpxchg instead of local64_cmpxchg (*ptr, old, new) == old
in perfmon_pmu_event_update.  x86 CMPXCHG instruction returns success in
ZF flag, so this change saves a compare after cmpxchg (and related move
instruction in front of cmpxchg).

Also, try_cmpxchg implicitly assigns old *ptr value to "old" when cmpxchg
fails. There is no need to re-read the value in the loop.

No functional change intended.

Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Link: https://lore.kernel.org/r/20230703145346.5206-1-ubizjak@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/idxd/perfmon.c