From: Joseph Qi <jiangqi903@gmail.com>
To: Bart Van Assche <Bart.VanAssche@wdc.com>,
"joseph.qi@linux.alibaba.com" <joseph.qi@linux.alibaba.com>,
"axboe@kernel.dk" <axboe@kernel.dk>
Cc: "hch@lst.de" <hch@lst.de>,
"ulf.hansson@linaro.org" <ulf.hansson@linaro.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"philipp.reisner@linbit.com" <philipp.reisner@linbit.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
"keescook@chromium.org" <keescook@chromium.org>
Subject: Re: [PATCH v2 2/2] block: Fix a race between the throttling code and request queue initialization
Date: Fri, 2 Feb 2018 09:02:46 +0800 [thread overview]
Message-ID: <26f758cf-430c-aa7f-0d21-75fbad6db260@gmail.com> (raw)
In-Reply-To: <1517501761.2746.21.camel@wdc.com>
Hi Bart,
On 18/2/2 00:16, Bart Van Assche wrote:
> On Thu, 2018-02-01 at 09:53 +0800, Joseph Qi wrote:
>> I'm afraid the risk may also exist in blk_cleanup_queue, which will
>> set queue_lock to to the default internal lock.
>>
>> spin_lock_irq(lock);
>> if (q->queue_lock != &q->__queue_lock)
>> q->queue_lock = &q->__queue_lock;
>> spin_unlock_irq(lock);
>>
>> I'm thinking of getting blkg->q->queue_lock to local first, but this
>> will result in still using driver lock even the queue_lock has already
>> been set to the default internal lock.
>
> Hello Joseph,
>
> I think the race between the queue_lock assignment in blk_cleanup_queue()
> and the use of that pointer by cgroup attributes could be solved by
> removing the visibility of these attributes from blk_cleanup_queue() instead
> of __blk_release_queue(). However, last time I proposed to move code from
> __blk_release_queue() into blk_cleanup_queue() I received the feedback that
> from some kernel developers that they didn't like this.
>
> Is the block driver that triggered the race on the q->queue_lock assignment
> using legacy (single queue) or multiqueue (blk-mq) mode? If that driver is
> using legacy mode, are you aware that there are plans to remove legacy mode
> from the upstream kernel? And if your driver is using multiqueue mode, how
> about the following change instead of the two patches in this patch series:
>
We triggered this race when using single queue. I'm not sure if it
exists in multi-queue.
Do you mean upstream won't fix bugs any more in single queue?
Thanks,
Joseph
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -1093,7 +1093,7 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
> return NULL;
>
> q->request_fn = rfn;
> - if (lock)
> + if (!q->mq_ops && lock)
> q->queue_lock = lock;
> if (blk_init_allocated_queue(q) < 0) {
> blk_cleanup_queue(q);
>
> Thanks,
>
> Bart.
>
next prev parent reply other threads:[~2018-02-02 1:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-31 23:52 [PATCH v2 0/2] block: Fix a race between the throttling code and request queue initialization Bart Van Assche
2018-01-31 23:52 ` [PATCH v2 1/2] block: Add a third argument to blk_alloc_queue_node() Bart Van Assche
2018-01-31 23:53 ` [PATCH v2 2/2] block: Fix a race between the throttling code and request queue initialization Bart Van Assche
2018-02-01 1:53 ` Joseph Qi
2018-02-01 16:16 ` Bart Van Assche
2018-02-02 1:02 ` Joseph Qi [this message]
2018-02-02 14:52 ` Jens Axboe
2018-02-02 16:21 ` Bart Van Assche
2018-02-03 2:51 ` Joseph Qi
2018-02-05 17:58 ` Bart Van Assche
2018-02-07 11:54 ` Jan Kara
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=26f758cf-430c-aa7f-0d21-75fbad6db260@gmail.com \
--to=jiangqi903@gmail.com \
--cc=Bart.VanAssche@wdc.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=joseph.qi@linux.alibaba.com \
--cc=keescook@chromium.org \
--cc=linux-block@vger.kernel.org \
--cc=philipp.reisner@linbit.com \
--cc=stable@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/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