]> git.baikalelectronics.ru Git - kernel.git/commit
block/rq_qos: Use atomic_try_cmpxchg in atomic_inc_below
authorUros Bizjak <ubizjak@gmail.com>
Tue, 12 Jul 2022 15:05:47 +0000 (17:05 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 12 Jul 2022 20:38:52 +0000 (14:38 -0600)
commit170d6f8668f640cae90c583aa83945ae262f9ffb
tree00b3861f47de1e179c300fc038c78fc1a3854a5f
parent06114075e2cd30f1f174e10f2f595463a8c1498d
block/rq_qos: Use atomic_try_cmpxchg in atomic_inc_below

Use atomic_try_cmpxchg instead of atomic_cmpxchg (*ptr, old, new) == old in
atomic_inc_below. 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_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>
Link: https://lore.kernel.org/r/20220712150547.5786-1-ubizjak@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-rq-qos.c