io_uring: Use atomic_long_try_cmpxchg in __io_account_mem
authorUros Bizjak <ubizjak@gmail.com>
Thu, 14 Jul 2022 16:33:01 +0000 (18:33 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 21 Jul 2022 14:47:09 +0000 (08:47 -0600)
commit60875e71909321fb60aee7731fde33a120629279
tree5eab8703e26e76224459e2655a94fb050798225c
parentc56eab65de36c6750a872c4d3750fce70bbe248e
io_uring: Use atomic_long_try_cmpxchg in __io_account_mem

Use atomic_long_try_cmpxchg instead of
atomic_long_cmpxchg (*ptr, old, new) == old in __io_account_mem.
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, atomic_long_try_cmpxchg implicitly assigns old *ptr value
to "old" when cmpxchg fails, enabling further code simplifications.

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/rsrc.c