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 <[email protected]>