ring_buffer: Use try_cmpxchg instead of cmpxchg
authorUros Bizjak <ubizjak@gmail.com>
Sun, 5 Mar 2023 15:55:32 +0000 (16:55 +0100)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 21 Mar 2023 17:59:48 +0000 (13:59 -0400)
commit8328e36da9cd8cb051394630e910cbb461f7e3ec
tree35d10a2205d1f1ca0467cc06c0e27863352f8843
parentbc92b9562abc831a65e505d2e675b51528d22d8b
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: Uros Bizjak <ubizjak@gmail.com>
Acked-by: Mukesh Ojha <quic_mojha@quicinc.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/ring_buffer.c