perf/x86/rapl: Use local64_try_cmpxchg in rapl_event_update()
authorUros Bizjak <ubizjak@gmail.com>
Mon, 7 Aug 2023 14:51:15 +0000 (16:51 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 3 Oct 2023 19:13:45 +0000 (21:13 +0200)
commitbcc6ec3d954bbcc8bec34a21c05ea536a2e96d6f
treecf909666dfcc86ec6ec2c583c4db4cd5696264fe
parent1ce19bf90bd55bf54f9ed75d594029db63d395b0
perf/x86/rapl: Use local64_try_cmpxchg in rapl_event_update()

Use local64_try_cmpxchg() instead of local64_cmpxchg(*ptr, old, new) == old.

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.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20230807145134.3176-2-ubizjak@gmail.com
arch/x86/events/rapl.c