From: Bart Van Assche <bvanassche@acm.org>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>
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 V2] sbitmap: order READ/WRITE freed instance and setting clear bit
Date: Tue, 19 Mar 2019 08:06:48 -0700 [thread overview]
Message-ID: <1553008008.152266.42.camel@acm.org> (raw)
In-Reply-To: <20190319083842.30059-1-ming.lei@redhat.com>
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?
> 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"?
> + *
> + * 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.
> + * is in use.
> + */
> + smp_mb__before_atomic();
> sbitmap_deferred_clear_bit(&sbq->sb, nr);
Thanks,
Bart.
next prev parent reply other threads:[~2019-03-19 15:06 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 [this message]
2019-03-20 3:30 ` Ming Lei
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=1553008008.152266.42.camel@acm.org \
--to=bvanassche@acm.org \
--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).