linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
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 V2] sbitmap: order READ/WRITE freed instance and setting clear bit
Date: Wed, 20 Mar 2019 11:30:45 +0800	[thread overview]
Message-ID: <20190320033044.GA5745@ming.t460p> (raw)
In-Reply-To: <1553008008.152266.42.camel@acm.org>

On Tue, Mar 19, 2019 at 08:06:48AM -0700, Bart Van Assche wrote:
> On Tue, 2019-03-19 at 16:38 +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.
> > 
> > The following kernel oops triggerd by block/006 on aarch64 may be fixed:
>                                                              ^^^
> 
> Does that mean that it has not been verified whether this patch fixes the
> NULL pointer issue mentioned in the patch description?

V1 has been verified by Zhang Yi, but V2 isn't done yet.

> 
> > diff --git a/lib/sbitmap.c b/lib/sbitmap.c
> > index 5b382c1244ed..941a46495e12 100644
> > --- a/lib/sbitmap.c
> > +++ b/lib/sbitmap.c
> > @@ -591,6 +591,17 @@ EXPORT_SYMBOL_GPL(sbitmap_queue_wake_up);
> >  void sbitmap_queue_clear(struct sbitmap_queue *sbq, unsigned int nr,
> >                          unsigned int cpu)
> >  {
> > +       /*
> > +        * Once the clear bit is set, the bit may be allocated out.
>              ^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> This comment is confusing. Did you perhaps mean "Once the bit is cleared"?

No, please take at look at sbitmap_deferred_clear_bit().

> 
> > +        *
> > +        * Orders READ/WRITE on the asssociated instance(such as request
> > +        * of blk_mq) by this bit for avoiding race with re-allocation,
> > +        * and its pair is the memory barrier implied in __sbitmap_get_word.
> > +        *
> > +        * One invarient is that the clear bit has to be zero when the bit
>                  ^^^^^^^^^             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>                  invariant?            I cant' make sense of this.

It is really 'clear bit', again please look at
sbitmap_deferred_clear_bit().

Thanks,
Ming

  reply	other threads:[~2019-03-20  3:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19  8:38 [PATCH V2] sbitmap: order READ/WRITE freed instance and setting clear bit Ming Lei
2019-03-19 15:06 ` Bart Van Assche
2019-03-20  3:30   ` Ming Lei [this message]
2019-03-21  1:33 ` Yi Zhang

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=20190320033044.GA5745@ming.t460p \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=jianchao.w.wang@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --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).