Re: [PATCH] blktrace: Avoid sparse warnings when assigning q->blk_trace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(+Luis)

On 2020-05-28 02:29, Jan Kara wrote:
> 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. Furthermore
> there's no real need for atomic operations anymore since all changes to
> q->blk_trace happen under q->blk_trace_mutex. 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@xxxxxxxxx>
> Signed-off-by: Jan Kara <jack@xxxxxxx>

How about adding a reference to commit c780e86dd48e ("blktrace: Protect
q->blk_trace with RCU") in the description of this patch?

> @@ -1669,10 +1672,7 @@ static int blk_trace_setup_queue(struct request_queue *q,
>  
>  	blk_trace_setup_lba(bt, bdev);
>  
> -	ret = -EBUSY;
> -	if (cmpxchg(&q->blk_trace, NULL, bt))
> -		goto free_bt;
> -
> +	rcu_assign_pointer(q->blk_trace, bt);
>  	get_probe_ref();
>  	return 0;

This changes a conditional assignment of q->blk_trace into an
unconditional assignment. Shouldn't q->blk_trace only be assigned if
q->blk_trace == NULL?

Thanks,

Bart.




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux