]> www.infradead.org Git - users/jedix/linux-maple.git/commit
xfs: Use try_cmpxchg() in xlog_cil_insert_pcp_aggregate()
authorUros Bizjak <ubizjak@gmail.com>
Mon, 23 Sep 2024 12:22:17 +0000 (14:22 +0200)
committerCarlos Maiolino <cem@kernel.org>
Mon, 7 Oct 2024 06:00:11 +0000 (08:00 +0200)
commit20195d011c840b01fa91a85ebcd099ca95fbf8fc
tree1e9f0af89a9089da333eb0e353eb775fe35772bb
parent6148b77960cc43547e4b819bfa5f064fb83dc2ae
xfs: Use try_cmpxchg() in xlog_cil_insert_pcp_aggregate()

Use !try_cmpxchg instead of cmpxchg (*ptr, old, new) != old in
xlog_cil_insert_pcp_aggregate().  x86 CMPXCHG instruction returns
success in ZF flag, so this change saves a compare after 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.

Note that the value from *ptr should be read using READ_ONCE to
prevent the compiler from merging, refetching or reordering the read.

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-by: Christoph Hellwig <hch@infradead.org>
Cc: Chandan Babu R <chandan.babu@oracle.com>
Cc: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_log_cil.c