diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2022-07-12 17:27:41 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-07-12 22:39:06 +0200 |
commit | 939f9dd040fe1063d884f8f0f89b037093fe2341 (patch) | |
tree | 71f1874add6d679773e8bd0d4000690fde284f85 /block/blk-core.c | |
parent | block/rq_qos: Use atomic_try_cmpxchg in atomic_inc_below (diff) | |
download | linux-939f9dd040fe1063d884f8f0f89b037093fe2341.tar.xz linux-939f9dd040fe1063d884f8f0f89b037093fe2341.zip |
block: Use try_cmpxchg in update_io_ticks
Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in
update_io_ticks. x86 CMPXCHG instruction returns success in ZF flag,
so this change saves a compare after cmpxchg (and related
move instruction in front of cmpxchg).
No functional change intended.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>
Link: https://lore.kernel.org/r/20220712152741.7324-1-ubizjak@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r-- | block/blk-core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index b530ce7b370c..8365996a8ef8 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -943,7 +943,7 @@ void update_io_ticks(struct block_device *part, unsigned long now, bool end) again: stamp = READ_ONCE(part->bd_stamp); if (unlikely(time_after(now, stamp))) { - if (likely(cmpxchg(&part->bd_stamp, stamp, now) == stamp)) + if (likely(try_cmpxchg(&part->bd_stamp, &stamp, now))) __part_stat_add(part, io_ticks, end ? now - stamp : 1); } if (part->bd_partno) { |