Skip to content
Commit 8328e36d authored by Uros Bizjak's avatar Uros Bizjak Committed by Steven Rostedt (Google)
Browse files

ring_buffer: Use try_cmpxchg instead of cmpxchg

Use try_cmpxchg instead of 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.

Link: https://lkml.kernel.org/r/20230305155532.5549-4-ubizjak@gmail.com



Cc: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
Acked-by: default avatarMukesh Ojha <quic_mojha@quicinc.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent bc92b956
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment