From: Jens Axboe <axboe@kernel.dk>
To: Ming Lei <ming.lei@redhat.com>, Omar Sandoval <osandov@osandov.com>
Cc: linux-block@vger.kernel.org, Omar Sandoval <osandov@fb.com>,
Yi Zhang <yi.zhang@redhat.com>,
"jianchao.wang" <jianchao.w.wang@oracle.com>
Subject: Re: [PATCH V3] sbitmap: order READ/WRITE freed instance and setting clear bit
Date: Mon, 25 Mar 2019 21:10:08 -0600 [thread overview]
Message-ID: <18a3dfdb-7d32-70fa-2160-585a26540905@kernel.dk> (raw)
In-Reply-To: <20190326013309.GB30669@ming.t460p>
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@fb.com>
>
> Yeah, it is one normal race between freeing and allocating.
Applied, thanks.
--
Jens Axboe
prev parent reply other threads:[~2019-03-26 3:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-22 1:13 [PATCH V3] sbitmap: order READ/WRITE freed instance and setting clear bit Ming Lei
2019-03-25 18:52 ` Omar Sandoval
2019-03-26 1:33 ` Ming Lei
2019-03-26 3:10 ` Jens Axboe [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18a3dfdb-7d32-70fa-2160-585a26540905@kernel.dk \
--to=axboe@kernel.dk \
--cc=jianchao.w.wang@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=osandov@fb.com \
--cc=osandov@osandov.com \
--cc=yi.zhang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox