From: Bart Van Assche <bart.vanassche@sandisk.com>
To: Tejun Heo <tj@kernel.org>
Cc: Ming Lei <tom.leiming@gmail.com>, Jens Axboe <axboe@fb.com>,
"Christoph Hellwig" <hch@lst.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Akinobu Mita <akinobu.mita@gmail.com>
Subject: Re: [PATCH 3/3] blk-mq: Fix the queue freezing mechanism
Date: Thu, 24 Sep 2015 10:35:41 -0700 [thread overview]
Message-ID: <5604346D.3080000@sandisk.com> (raw)
In-Reply-To: <20150924165354.GB25415@mtj.duckdns.org>
On 09/24/2015 09:54 AM, Tejun Heo wrote:
> On Thu, Sep 24, 2015 at 09:43:48AM -0700, Bart Van Assche wrote:
>> On 09/23/2015 08:23 PM, Ming Lei wrote:
>>> IMO, mq_freeze_depth should only be accessed in slow path, and looks
>>> the race just happens during the small window between increasing
>>> 'mq_freeze_depth' and killing the percpu counter.
>>
>> Hello Ming,
>>
>> My concern is that *not* checking mq_freeze_depth in the hot path can cause
>> a livelock. If there is a software layer, e.g. multipathd, that periodically
>> submits new commands and if these commands take time to process e.g. because
>> the transport layer is unavailable, how to guarantee that freezing ever
>> succeeds without checking mq_freeze_depth in the hot path ?
>
> I couldn't tell what the patch was trying to do from the patch
> description, so including the above prolly is a good idea. Isn't the
> above guaranteed by percpu_ref_kill() preventing new tryget_live()'s?
My interpretation of the percpu_ref_tryget_live() implementation in
<linux/percpu-refcount.h> is that the tryget operation will only fail if
the refcount is in atomic mode and additionally the __PERCPU_REF_DEAD
flag has been set.
> Also, what does the barriers do in your patch?
My intention was to guarantee that on architectures that do not provide
the same ordering guarantees as x86 (e.g. PPC or ARM) that the store and
load operations on mq_freeze_depth and mq_usage_counter would not be
reordered. However, it is probably safe to leave out the barrier I
proposed to introduce in blk_mq_queue_enter() since it is acceptable
that there is some delay in communicating mq_freeze_depth updates from
the CPU that modified that counter to the CPU that reads that counter.
> The only race condition that I can see there is if unfreeze and freeze
> race each other and freeze tries to kill the ref which hasn't finished
> reinit yet. We prolly want to put mutexes around freeze/unfreeze so
> that they're serialized if something like that can happen (it isn't a
> hot path to begin with).
My concern is that the following could happen if mq_freeze_depth is not
checked in the hot path of blk_mq_queue_enter():
* mq_usage_counter >= 1 before blk_mq_freeze_queue() is called.
* blk_mq_freeze_queue() keeps waiting forever if new requests are queued
faster than that these requests complete.
Bart.
next prev parent reply other threads:[~2015-09-24 17:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-23 22:11 [PATCH 0/3] Block layer patches for kernel v4.4 Bart Van Assche
2015-09-23 22:12 ` [PATCH 1/3] blk-cgroup: Declare local symbols static Bart Van Assche
2015-09-25 15:35 ` Tejun Heo
2015-09-23 22:12 ` [PATCH 2/3] bsg: Add sparse annotations to bsg_request_fn() Bart Van Assche
2015-09-23 22:14 ` [PATCH 3/3] blk-mq: Fix the queue freezing mechanism Bart Van Assche
2015-09-24 3:22 ` Ming Lei
2015-09-24 16:43 ` Bart Van Assche
2015-09-24 16:53 ` Tejun Heo
2015-09-24 17:35 ` Bart Van Assche [this message]
2015-09-24 17:49 ` Tejun Heo
2015-09-24 18:09 ` Bart Van Assche
2015-09-24 18:14 ` Tejun Heo
2015-09-24 22:54 ` Bart Van Assche
2015-09-24 22:56 ` Tejun Heo
2015-09-24 19:04 ` Bart Van Assche
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=5604346D.3080000@sandisk.com \
--to=bart.vanassche@sandisk.com \
--cc=akinobu.mita@gmail.com \
--cc=axboe@fb.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).