]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bcachefs: Use try_cmpxchg() family of functions instead of cmpxchg()
authorUros Bizjak <ubizjak@gmail.com>
Thu, 23 May 2024 09:19:26 +0000 (11:19 +0200)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Jul 2024 23:00:12 +0000 (19:00 -0400)
commit68573b936d3fceda9cd5cce3a577e035d19ad426
tree872f291bf9b8d6f439c9d0a5bd372d42557e8e6b
parente76a2b65b0565f55ea668ec46d54f6a00b8ea9fc
bcachefs: Use try_cmpxchg() family of functions instead of cmpxchg()

Use try_cmpxchg() family of functions 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.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Brian Foster <bfoster@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_cache.c
fs/bcachefs/btree_io.c
fs/bcachefs/btree_trans_commit.c
fs/bcachefs/btree_update_interior.c
fs/bcachefs/buckets.c
fs/bcachefs/buckets.h
fs/bcachefs/io_write.c
fs/bcachefs/journal.c
fs/bcachefs/journal.h
fs/bcachefs/journal_io.c
fs/bcachefs/two_state_shared_lock.h