linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	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 11:52:17 -0700	[thread overview]
Message-ID: <20190325185217.GE5826@vader> (raw)
In-Reply-To: <20190322011351.4082-1-ming.lei@redhat.com>

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>

  reply	other threads:[~2019-03-25 18:52 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 [this message]
2019-03-26  1:33   ` Ming Lei
2019-03-26  3:10     ` Jens Axboe

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=20190325185217.GE5826@vader \
    --to=osandov@osandov.com \
    --cc=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=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;
as well as URLs for NNTP newsgroup(s).