diff options
author | Uros Bizjak <[email protected]> | 2024-01-24 11:49:53 +0100 |
---|---|---|
committer | Ingo Molnar <[email protected]> | 2024-03-01 13:02:05 +0100 |
commit | ce3576ebd62d99f79c1dc98824e2ef6d6ab68434 (patch) | |
tree | ff97be9bf28a71d1b790982c793ebbe8591c7695 /lib/test_fortify/write_overflow-strncpy-src.c | |
parent | e807c2a37044a51de89d6d4f8a1f5ecfb3752f36 (diff) |
locking/rtmutex: Use try_cmpxchg_relaxed() in mark_rt_mutex_waiters()
Use try_cmpxchg() instead of cmpxchg(*ptr, old, new) == old.
The x86 CMPXCHG instruction returns success in the 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.
Note that the value from *ptr should be read using READ_ONCE() to prevent
the compiler from merging, refetching or reordering the read.
No functional change intended.
Signed-off-by: Uros Bizjak <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Waiman Long <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'lib/test_fortify/write_overflow-strncpy-src.c')
0 files changed, 0 insertions, 0 deletions