On 3/25/19 7:33 PM, Ming Lei wrote: > On Mon, Mar 25, 2019 at 11:52:17AM -0700, Omar Sandoval wrote: >> On Fri, Mar 22, 2019 at 09:13:51AM +0800, Ming Lei wrote: >>> Inside sbitmap_queue_clear(), once the clear bit is set, it will be >>> visiable to allocation path immediately. Meantime READ/WRITE on old >>> associated instance(such as request in case of blk-mq) may be >>> out-of-order with the setting clear bit, so race with re-allocation >>> may be triggered. >>> >>> Adds one memory barrier for ordering READ/WRITE of the freed associated >>> instance with setting clear bit for avoiding race with re-allocation. >> >> Just to make sure I understand, the race is something like this? >> >> Thread 1 Thread 2 >> sbitmap_queue_get() >> ... >> write to request _____ >> sbitmap_queue_clear() \ >> \ sbitmap_queue_get() >> \______ observes write >> >> If so, you can add >> >> Reviewed-by: Omar Sandoval <osandov@xxxxxx> > > Yeah, it is one normal race between freeing and allocating. Applied, thanks. -- Jens Axboe