public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche@wdc.com>
To: "tom.leiming@gmail.com" <tom.leiming@gmail.com>
Cc: "hch@lst.de" <hch@lst.de>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"jthumshirn@suse.de" <jthumshirn@suse.de>,
	"stern@rowland.harvard.edu" <stern@rowland.harvard.edu>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"ming.lei@redhat.com" <ming.lei@redhat.com>
Subject: Re: [PATCH 2/3] block, scsi: Rework runtime power management
Date: Wed, 18 Jul 2018 15:45:15 +0000	[thread overview]
Message-ID: <60ce50f281bf41483b53246d509697f6d95360f8.camel@wdc.com> (raw)
In-Reply-To: <CACVXFVPP6bY9YijDSyQg9OOR4ge9LyR+naWNDeLGOS=WFL_7CA@mail.gmail.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-7", Size: 2172 bytes --]

On Wed, 2018-07-18 at 20:16 +-0800, Ming Lei wrote:
+AD4- On Wed, Jul 18, 2018 at 7:49 AM, Bart Van Assche +ADw-bart.vanassche+=
AEA-wdc.com+AD4- wrote:
+AD4- +AD4- +AEAAQA- -3801,8 +-3778,11 +AEAAQA- int blk+AF8-pre+AF8-runtime=
+AF8-suspend(struct request+AF8-queue +ACo-q)
+AD4- +AD4-         if (+ACE-q-+AD4-dev)
+AD4- +AD4-                 return ret+ADs-
+AD4- +AD4-=20
+AD4- +AD4- +-       blk+AF8-set+AF8-preempt+AF8-only(q)+ADs-
+AD4- +AD4- +-       blk+AF8-freeze+AF8-queue+AF8-start(q)+ADs-
+AD4- +AD4- +-
+AD4- +AD4-         spin+AF8-lock+AF8-irq(q-+AD4-queue+AF8-lock)+ADs-
+AD4- +AD4- -       if (q-+AD4-nr+AF8-pending) +AHs-
+AD4- +AD4- +-       if (+ACE-percpu+AF8-ref+AF8-is+AF8-zero(+ACY-q-+AD4-q+=
AF8-usage+AF8-counter)) +AHs-
+AD4-=20
+AD4- This way can't work reliably because the percpu ref isn't in atomic m=
ode
+AD4- yet after blk+AF8-freeze+AF8-queue+AF8-start() returns, then percpu+A=
F8-ref+AF8-is+AF8-zero() won't
+AD4- see accurate value of the counter, finally the device may be put down=
 before
+AD4- in-flight requests are completed by hardware.

Hello Ming,

The blk+AF8-freeze+AF8-queue+AF8-start() implementation is as follows:

void blk+AF8-freeze+AF8-queue+AF8-start(struct request+AF8-queue +ACo-q)
+AHs-
	int freeze+AF8-depth+ADs-

	freeze+AF8-depth +AD0- atomic+AF8-inc+AF8-return(+ACY-q-+AD4-mq+AF8-freeze=
+AF8-depth)+ADs-
	if (freeze+AF8-depth +AD0APQ- 1) +AHs-
		percpu+AF8-ref+AF8-kill(+ACY-q-+AD4-q+AF8-usage+AF8-counter)+ADs-
		if (q-+AD4-mq+AF8-ops)
			blk+AF8-mq+AF8-run+AF8-hw+AF8-queues(q, false)+ADs-
	+AH0-
+AH0-

>From the documentation header in include/linux/percpu-refcount.h above
percpu+AF8-ref+AF8-kill():

 +ACo- Switches +AEA-ref into atomic mode before gathering up the percpu co=
unters
 +ACo- and dropping the initial ref.

In other words, I think that after blk+AF8-freeze+AF8-queue+AF8-start() ret=
urns that it is
guaranteed that q-+AD4-q+AF8-usage+AF8-counter is in atomic mode. However, =
we may need to
serialize concurrent blk+AF8-freeze+AF8-queue+AF8-start() calls to guarante=
e that this is
always the case if multiple threads call blk+AF8-freeze+AF8-queue+AF8-start=
() concurrently.

Bart.=

  reply	other threads:[~2018-07-18 15:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17 23:49 [PATCH 0/3] blk-mq: Enable runtime power management Bart Van Assche
2018-07-17 23:49 ` [PATCH 1/3] block: Fix a comment in a header file Bart Van Assche
2018-07-18  6:47   ` Johannes Thumshirn
2018-07-17 23:49 ` [PATCH 2/3] block, scsi: Rework runtime power management Bart Van Assche
2018-07-18 12:16   ` Ming Lei
2018-07-18 15:45     ` Bart Van Assche [this message]
2018-07-18 22:45       ` Ming Lei
2018-07-19 15:54         ` Bart Van Assche
2018-07-19 23:26           ` Ming Lei
2018-07-17 23:49 ` [PATCH 3/3] blk-mq: Enable support for " 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=60ce50f281bf41483b53246d509697f6d95360f8.camel@wdc.com \
    --to=bart.vanassche@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=stern@rowland.harvard.edu \
    --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