]> git.baikalelectronics.ru Git - kernel.git/commit
blk-cgroup: Use atomic{,64}_try_cmpxchg
authorUros Bizjak <ubizjak@gmail.com>
Tue, 12 Jul 2022 15:44:55 +0000 (17:44 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 12 Jul 2022 21:46:03 +0000 (15:46 -0600)
commit9ef8b94c4f0d548c32461a9c406bab91b6165794
tree8d55b77e103b15559c7b64e034ca5ea0df21ea0e
parent0515913e15df90e66118037394220d685856b0f8
blk-cgroup: Use atomic{,64}_try_cmpxchg

Use atomic_try_cmpxchg instead of atomic_cmpxchg (*ptr, old, new) == old
in blkcg_unuse_delay, blkcg_set_delay and blkcg_clear_delay and
atomic64_try_cmpxchg in blkcg_scale_delay.  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/20220712154455.66868-1-ubizjak@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-cgroup.c
block/blk-cgroup.h