From: Jens Axboe <axboe@kernel.dk>
To: Ming Lei <ming.lei@redhat.com>
Cc: linux-block@vger.kernel.org,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Alan Stern <stern@rowland.harvard.edu>,
linux-pm@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Christoph Hellwig <hch@lst.de>,
Bart Van Assche <bart.vanassche@wdc.com>,
"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH RFC 3/4] blk-mq: prepare for supporting runtime PM
Date: Thu, 12 Jul 2018 08:00:29 -0600 [thread overview]
Message-ID: <a0be8ebf-e556-34c9-5985-6cda8992cd61@kernel.dk> (raw)
In-Reply-To: <20180712122836.GC2422@ming.t460p>
On 7/12/18 6:28 AM, Ming Lei wrote:
> On Thu, Jul 12, 2018 at 05:58:28PM +0800, Ming Lei wrote:
>> On Thu, Jul 12, 2018 at 12:29:05AM +0800, Ming Lei wrote:
>>> This patch introduces blk_mq_pm_add_request() which is called after
>>> allocating one request. Also blk_mq_pm_put_request() is introduced
>>> and called after one request is freed.
>>>
>>> For blk-mq, it can be quite expensive to accounting in-flight IOs,
>>> so this patch calls pm_runtime_mark_last_busy() simply after each IO
>>> is done, instead of doing that only after the last in-flight IO is done.
>>> This way is still workable, since the active non-PM IO will be checked
>>> in blk_pre_runtime_suspend(), and runtime suspend will be prevented
>>> if there is any active non-PM IO.
>>>
>>> Also makes blk_post_runtime_resume() to cover blk-mq.
>>>
>>> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
>>> Cc: Alan Stern <stern@rowland.harvard.edu>
>>> Cc: linux-pm@vger.kernel.org
>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>> Cc: Christoph Hellwig <hch@lst.de>
>>> Cc: Bart Van Assche <bart.vanassche@wdc.com>
>>> Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
>>> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
>>> Cc: linux-scsi@vger.kernel.org
>>> Signed-off-by: Ming Lei <ming.lei@redhat.com>
>>> ---
>>> block/blk-core.c | 12 ++++++++++--
>>> block/blk-mq.c | 24 ++++++++++++++++++++++++
>>> 2 files changed, 34 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/block/blk-core.c b/block/blk-core.c
>>> index c4b57d8806fe..bf66d561980d 100644
>>> --- a/block/blk-core.c
>>> +++ b/block/blk-core.c
>>> @@ -3804,12 +3804,17 @@ EXPORT_SYMBOL(blk_pm_runtime_init);
>>> int blk_pre_runtime_suspend(struct request_queue *q)
>>> {
>>> int ret = 0;
>>> + bool active;
>>>
>>> if (!q->dev)
>>> return ret;
>>>
>>> spin_lock_irq(q->queue_lock);
>>> - if (q->nr_pending) {
>>> + if (!q->mq_ops)
>>> + active = !!q->nr_pending;
>>> + else
>>> + active = !blk_mq_pm_queue_idle(q);
>>> + if (active) {
>>> ret = -EBUSY;
>>> pm_runtime_mark_last_busy(q->dev);
>>> } else {
>>
>> Looks there is one big issue, one new IO may come just after reading
>> 'active' and before writing RPM_SUSPENDING to q->rpm_status, and both
>> the suspending and the new IO may be in-progress at the same time.
>
> One idea I thought of is to use seqlock to sync changing & reading q->rpm_status,
> and looks read lock(read_seqcount_begin/read_seqcount_retry) shouldn't introduce
> big cost in fast path.
Let's please keep in mind that this is runtime pm stuff. Better to
make the rules relaxed around it, instead of adding synchronization.
--
Jens Axboe
next prev parent reply other threads:[~2018-07-12 14:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-11 16:29 [PATCH RFC 0/4] blk-mq: support runtime PM Ming Lei
2018-07-11 16:29 ` [PATCH RFC 1/4] blk-mq: introduce blk_mq_support_runtime_pm() Ming Lei
2018-07-11 17:10 ` Christoph Hellwig
2018-07-11 16:29 ` [PATCH RFC 2/4] blk-mq: introduce blk_mq_pm_queue_idle() Ming Lei
2018-07-11 17:11 ` Christoph Hellwig
2018-07-11 16:29 ` [PATCH RFC 3/4] blk-mq: prepare for supporting runtime PM Ming Lei
2018-07-11 17:19 ` Christoph Hellwig
2018-07-12 9:58 ` Ming Lei
2018-07-12 12:28 ` Ming Lei
2018-07-12 14:00 ` Jens Axboe [this message]
2018-07-12 21:32 ` Ming Lei
2018-07-12 21:44 ` Jens Axboe
2018-07-12 23:15 ` Ming Lei
2018-07-13 14:20 ` Jens Axboe
2018-07-13 20:27 ` Alan Stern
2018-07-13 20:39 ` Jens Axboe
2018-07-13 22:47 ` Ming Lei
2018-07-11 16:29 ` [PATCH RFC 4/4] scsi_mq: enable " Ming Lei
2018-07-11 17:14 ` Christoph Hellwig
2018-07-12 1:36 ` Ming Lei
2018-07-12 7:17 ` Christoph Hellwig
2018-07-12 12:21 ` Ming Lei
2018-07-11 17:28 ` Alan Stern
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=a0be8ebf-e556-34c9-5985-6cda8992cd61@kernel.dk \
--to=axboe@kernel.dk \
--cc=bart.vanassche@wdc.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=stern@rowland.harvard.edu \
/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).