linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Tejun Heo <tj@kernel.org>, Akinobu Mita <akinobu.mita@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ming Lei <tom.leiming@gmail.com>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v4 6/7] blk-mq: fix freeze queue race
Date: Tue, 29 Sep 2015 09:01:31 -0600	[thread overview]
Message-ID: <560AA7CB.2070107@kernel.dk> (raw)
In-Reply-To: <20150928144839.GA2589@mtj.duckdns.org>

On 09/28/2015 08:48 AM, Tejun Heo wrote:
> Hello,
>
> On Sun, Sep 27, 2015 at 10:06:05PM +0900, Akinobu Mita wrote:
>>>>   void blk_mq_finish_init(struct request_queue *q)
>>>>   {
>>>> +     mutex_lock(&q->mq_freeze_lock);
>>>>        percpu_ref_switch_to_percpu(&q->mq_usage_counter);
>>>> +     mutex_unlock(&q->mq_freeze_lock);
>>>
>>> This looks weird to me.  What can it race against at this point?
>>
>> The possible scenario is described in commit log (1. ~ 7.).  In summary,
>> blk_mq_finish_init() and blk_mq_freeze_queue_start() can be executed
>> at the same time, so this is required to serialize the execution of
>> percpu_ref_switch_to_percpu() by blk_mq_finish_init() and
>> percpu_ref_kill() by blk_mq_freeze_queue_start().
>
> Ah, you're right.  I was thinking that percpu_ref_switch_to_percpu()
> being called after blk_mq_freeze_queue_start() would be buggy and thus
> the above can't be enough but that is safe as long as the calls are
> properly synchronized.  Hmmm... maybe we should add synchronization to
> those operations from percpu_ref side.

I think that would be very useful, it seems sort of half-assed if the 
caller side has to provide serialization for that.

-- 
Jens Axboe


  parent reply	other threads:[~2015-09-29 15:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-26 17:09 [PATCH v4 0/7] blk-mq: fix race conditions on cpu hotplug handling Akinobu Mita
2015-09-26 17:09 ` [PATCH v4 1/7] blk-mq: avoid setting hctx->tags->cpumask before allocation Akinobu Mita
2015-09-26 18:12   ` Christoph Hellwig
2015-09-26 17:09 ` [PATCH v4 2/7] blk-mq: fix sysfs registration/unregistration race Akinobu Mita
2015-09-29  6:51   ` Christoph Hellwig
2015-09-26 17:09 ` [PATCH v4 3/7] blk-mq: Fix use after of free q->mq_map Akinobu Mita
2015-09-29  6:52   ` Christoph Hellwig
2015-10-05 23:50     ` Akinobu Mita
2015-10-06  9:43       ` Christoph Hellwig
2015-09-26 17:09 ` [PATCH v4 4/7] blk-mq: fix q->mq_usage_counter access race Akinobu Mita
2015-09-29  6:53   ` Christoph Hellwig
2015-09-26 17:09 ` [PATCH v4 5/7] blk-mq: avoid inserting requests before establishing new mapping Akinobu Mita
2015-09-29  6:54   ` Christoph Hellwig
2015-09-26 17:09 ` [PATCH v4 6/7] blk-mq: fix freeze queue race Akinobu Mita
2015-09-26 17:32   ` Tejun Heo
2015-09-27 13:06     ` Akinobu Mita
2015-09-28 14:48       ` Tejun Heo
2015-09-29  6:55         ` Christoph Hellwig
2015-09-29 15:01         ` Jens Axboe [this message]
2015-09-29 15:03           ` Tejun Heo
2015-09-29 21:50             ` Tejun Heo
2015-09-30 10:32               ` Akinobu Mita
2015-09-26 17:09 ` [PATCH v4 7/7] blk-mq: fix deadlock when reading cpu_list Akinobu Mita
2015-09-29  6:58   ` Christoph Hellwig
2015-09-29 17:31 ` [PATCH v4 0/7] blk-mq: fix race conditions on cpu hotplug handling 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=560AA7CB.2070107@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=akinobu.mita@gmail.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=tom.leiming@gmail.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).