]> git.baikalelectronics.ru Git - kernel.git/commit
blktrace: Avoid sparse warnings when assigning q->blk_trace
authorJan Kara <jack@suse.cz>
Fri, 5 Jun 2020 14:58:37 +0000 (16:58 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 17 Jun 2020 15:07:11 +0000 (09:07 -0600)
commit64191d958b59d5109df29dd35bf70b21d0260b36
tree6e0b3e4b26c3ccbbd9300ec69883b95d99400fcf
parent844552860f75bcd7b5d5fa43c55dfec235029192
blktrace: Avoid sparse warnings when assigning q->blk_trace

Mostly for historical reasons, q->blk_trace is assigned through xchg()
and cmpxchg() atomic operations. Although this is correct, sparse
complains about this because it violates rcu annotations since commit
84158af9ef7d ("blktrace: Protect q->blk_trace with RCU") which started
to use rcu for accessing q->blk_trace. Furthermore there's no real need
for atomic operations anymore since all changes to q->blk_trace happen
under q->blk_trace_mutex and since it also makes more sense to check if
q->blk_trace is set with the mutex held earlier.

So let's just replace xchg() with rcu_replace_pointer() and cmpxchg()
with explicit check and rcu_assign_pointer(). This makes the code more
efficient and sparse happy.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
kernel/trace/blktrace.c