From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <Bart.VanAssche@wdc.com>
Cc: "hch@lst.de" <hch@lst.de>, "hare@suse.com" <hare@suse.com>,
"jthumshirn@suse.de" <jthumshirn@suse.de>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"oleksandr@natalenko.name" <oleksandr@natalenko.name>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"axboe@kernel.dk" <axboe@kernel.dk>
Subject: Re: [PATCH v3 5/6] block: Make SCSI device suspend and resume work reliably
Date: Tue, 26 Sep 2017 06:51:26 +0800 [thread overview]
Message-ID: <20170925225119.GB18137@ming.t460p> (raw)
In-Reply-To: <1506356419.2641.11.camel@wdc.com>
On Mon, Sep 25, 2017 at 04:20:20PM +0000, Bart Van Assche wrote:
> On Mon, 2017-09-25 at 10:26 +0800, Ming Lei wrote:
> > On Fri, Sep 22, 2017 at 03:14:04PM -0700, Bart Van Assche wrote:
> > > +int blk_queue_enter(struct request_queue *q, bool nowait, bool preempt)
> > > {
> > > while (true) {
> > > int ret;
> > >
> > > - if (percpu_ref_tryget_live(&q->q_usage_counter))
> > > - return 0;
> > > + if (percpu_ref_tryget_live(&q->q_usage_counter)) {
> > > + /*
> > > + * Ensure read order of q_usage_counter and the
> > > + * PREEMPT_ONLY queue flag.
> > > + */
> > > + smp_rmb();
> > > + if (preempt || !blk_queue_preempt_only(q))
> > > + return 0;
> > > + else
> > > + percpu_ref_put(&q->q_usage_counter);
> > > + }
> >
> > Now you introduce one smp_rmb() and test on preempt flag on
> > blk-mq's fast path, which should have been avoided, so I
> > think this way is worse than my patchset.
>
> So that means that you have not noticed that it is safe to leave out that
> smp_rmp() call because blk-mq queue freezing and unfreezing waits for a grace
> period and hence waits until all CPUs have executed a full memory barrier?
No, memory barrier has to be pair, this barrier has to be there, another
one before unfreeze/freeze can be removed because it is implied inside
freeze/unfreeze.
Actually it should have been smp_mb() between writing the percpu-refcount
and reading preempt_only flag, otherwise if the two op is reordered,
queue freeze/unfreeze may see the counter is zero, and this normal I/O
still can be observed even after queue is freezed and SCSI is put into
quiesced.
--
Ming
next prev parent reply other threads:[~2017-09-25 22:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-22 22:13 [PATCH v3 0/6] Make SCSI device suspend and resume work reliably Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 1/6] md: Make md resync and reshape threads freezable Bart Van Assche
2017-09-25 2:38 ` Ming Lei
2017-09-25 16:22 ` Bart Van Assche
2017-09-25 22:45 ` Ming Lei
2017-09-25 22:48 ` Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 2/6] block: Convert RQF_PREEMPT into REQ_PREEMPT Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 3/6] block: Add the QUEUE_FLAG_PREEMPT_ONLY request queue flag Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 4/6] scsi: Set QUEUE_FLAG_PREEMPT_ONLY while quiesced Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 5/6] block: Make SCSI device suspend and resume work reliably Bart Van Assche
2017-09-25 2:26 ` Ming Lei
2017-09-25 16:20 ` Bart Van Assche
2017-09-25 22:51 ` Ming Lei [this message]
2017-09-25 23:06 ` Bart Van Assche
2017-09-22 22:14 ` [PATCH v3 6/6] scsi-mq: Reduce suspend latency Bart Van Assche
2017-09-25 2:28 ` Ming Lei
2017-09-25 2:36 ` [PATCH v3 0/6] Make SCSI device suspend and resume work reliably Ming Lei
2017-09-25 16:17 ` Bart Van Assche
2017-09-25 16:20 ` hch
2017-09-26 9:11 ` Ming Lei
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=20170925225119.GB18137@ming.t460p \
--to=ming.lei@redhat.com \
--cc=Bart.VanAssche@wdc.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=jthumshirn@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=oleksandr@natalenko.name \
/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