From: Bart Van Assche Date: Sun, 21 Jun 2020 20:55:04 +0000 (-0700) Subject: fio: Use atomic_load_acquire() and atomic_store_release() where appropriate X-Git-Tag: fio-3.21~28^2~4 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=0337173e060e5e6d476312d3780cbb7c39604ed6 fio: Use atomic_load_acquire() and atomic_store_release() where appropriate The write_barrier() in io_completed() and also the read barriers in verify.c are misplaced: the write barrier should occur before the flags update instead of after and the read barriers should occur after the flags read instead of before. Fix this by using atomic_{load_acquire, store_release}() instead of read and write barriers. Signed-off-by: Bart Van Assche --- diff --git a/io_u.c b/io_u.c index ae1438fd..7f50906b 100644 --- a/io_u.c +++ b/io_u.c @@ -1934,8 +1934,8 @@ static void io_completed(struct thread_data *td, struct io_u **io_u_ptr, if (io_u->error) unlog_io_piece(td, io_u); else { - io_u->ipo->flags &= ~IP_F_IN_FLIGHT; - write_barrier(); + atomic_store_release(&io_u->ipo->flags, + io_u->ipo->flags & ~IP_F_IN_FLIGHT); } } diff --git a/verify.c b/verify.c index b7fa6693..5ee0029d 100644 --- a/verify.c +++ b/verify.c @@ -8,6 +8,7 @@ #include #include +#include "arch/arch.h" #include "fio.h" #include "verify.h" #include "trim.h" @@ -1309,8 +1310,7 @@ int get_next_verify(struct thread_data *td, struct io_u *io_u) /* * Ensure that the associated IO has completed */ - read_barrier(); - if (ipo->flags & IP_F_IN_FLIGHT) + if (atomic_load_acquire(&ipo->flags) & IP_F_IN_FLIGHT) goto nothing; rb_erase(n, &td->io_hist_tree); @@ -1322,8 +1322,7 @@ int get_next_verify(struct thread_data *td, struct io_u *io_u) /* * Ensure that the associated IO has completed */ - read_barrier(); - if (ipo->flags & IP_F_IN_FLIGHT) + if (atomic_load_acquire(&ipo->flags) & IP_F_IN_FLIGHT) goto nothing; flist_del(&ipo->list);