From: Ming Lei <ming.lei@redhat.com>
To: Will Deacon <will@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>,
Peter Zijlstra <peterz@infradead.org>,
Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, John Garry <john.garry@huawei.com>,
Bart Van Assche <bvanassche@acm.org>,
Hannes Reinecke <hare@suse.com>,
Thomas Gleixner <tglx@linutronix.de>,
paulmck@kernel.org
Subject: Re: [PATCH V8 07/11] blk-mq: stop to handle IO and drain IO before hctx becomes inactive
Date: Wed, 6 May 2020 18:22:40 +0800 [thread overview]
Message-ID: <20200506102240.GA1261234@T590> (raw)
In-Reply-To: <20200506095610.GA8043@willie-the-truck>
On Wed, May 06, 2020 at 10:56:10AM +0100, Will Deacon wrote:
> On Wed, May 06, 2020 at 04:07:27PM +0800, Ming Lei wrote:
> > On Wed, May 06, 2020 at 08:28:03AM +0100, Will Deacon wrote:
> > > On Wed, May 06, 2020 at 09:24:25AM +0800, Ming Lei wrote:
> > > > On Tue, May 05, 2020 at 05:46:18PM +0200, Christoph Hellwig wrote:
> > > > > On Thu, Apr 30, 2020 at 10:02:54PM +0800, Ming Lei wrote:
> > > > > > BLK_MQ_S_INACTIVE is only set when the last cpu of this hctx is becoming
> > > > > > offline, and blk_mq_hctx_notify_offline() is called from cpu hotplug
> > > > > > handler. So if there is any request of this hctx submitted from somewhere,
> > > > > > it has to this last cpu. That is done by blk-mq's queue mapping.
> > > > > >
> > > > > > In case of direct issue, basically blk_mq_get_driver_tag() is run after
> > > > > > the request is allocated, that is why I mentioned the chance of
> > > > > > migration is very small.
> > > > >
> > > > > "very small" does not cut it, it has to be zero. And it seems the
> > > > > new version still has this hack.
> > > >
> > > > But smp_mb() is used for ordering the WRITE and READ, so it is correct.
> > > >
> > > > barrier() is enough when process migration doesn't happen.
> > >
> > > Without numbers I would just make the smp_mb() unconditional. Your
> > > questionable optimisation trades that for a load of the CPU ID and a
> > > conditional branch, which isn't obviously faster to me. It's also very
> >
> > The CPU ID is just percpu READ, and unlikely() has been used for
> > optimizing the conditional branch. And smp_mb() could cause CPU stall, I
> > guess, so it should be much slower than reading CPU ID.
>
> Percpu accesses aren't uniformly cheap across architectures.
I believe percpu access is cheap enough than smp_mb() in almost
every SMP ARCH, otherwise no one would use percpu variable on that
ARCH.
>
> > Let's see the attached microbench[1], the result shows that smp_mb() is
> > 10+ times slower than smp_processor_id() with one conditional branch.
>
> Nobody said anything about smp_mb() in a tight loop, so this is hardly
> surprising. Throughput of barrier instructions will hit a ceiling fairly
> quickly, but they don't have to cause stalls in general use. I would expect
> the numbers to converge if you added some back-off to the loops (e.g.
> ndelay() or something). But I was really hoping for some numbers from the
> block layer itself, since that's what we actually care about.
I believe that the microbench is enough to show smp_mb() is much heavier
and slower than smp_processor_id() with conditional branch.
Cause some aio or io uring workload just takes CPU to submit IO without
any delay, and we don't want to take extra CPU unnecessarily in IO
submission side. And IOPS may reach millions or dozens of millions
level. Storage guys have been working very hard to optimize the whole
IO path.
>
> > [ 1.239951] test_foo: smp_mb 738701907 smp_id 62904315 result 0 overflow 5120
> >
> > The micronbench is run on simple 8cores KVM guest, and cpu is
> > 'Model name: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz'.
> >
> > Result is pretty stable in my 5 runs of VM boot.
>
> Honestly, I get the impression that you're not particularly happy with me
> putting in the effort to review your patches, so I'll leave it up to
> Christoph as to whether he wants to predicate the concurrency design on
> a hokey microbenchmark.
>
> FWIW: I agree that the code should work as you have it in v10, I just think
> it's unnecessarily complicated and fragile.
Yeah, it works and it is correct, and we can document the usage, another point
is that CPU hotplug doesn't happen frequently, so we shouldn't introduce extra
cost for handling cpu hotplug in fast IO path, meantime smp_mb() won't
be something which can be ignored, especially in some big machine with
lots of CPU cores.
Thanks,
Ming
next prev parent reply other threads:[~2020-05-06 10:23 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 10:23 [PATCH V8 00/11] blk-mq: improvement CPU hotplug Ming Lei
2020-04-24 10:23 ` [PATCH V8 01/11] block: clone nr_integrity_segments and write_hint in blk_rq_prep_clone Ming Lei
2020-04-24 10:32 ` Christoph Hellwig
2020-04-24 12:43 ` Hannes Reinecke
2020-04-24 16:11 ` Martin K. Petersen
2020-04-24 10:23 ` [PATCH V8 02/11] block: add helper for copying request Ming Lei
2020-04-24 10:35 ` Christoph Hellwig
2020-04-24 12:43 ` Hannes Reinecke
2020-04-24 16:12 ` Martin K. Petersen
2020-04-24 10:23 ` [PATCH V8 03/11] blk-mq: mark blk_mq_get_driver_tag as static Ming Lei
2020-04-24 12:44 ` Hannes Reinecke
2020-04-24 16:13 ` Martin K. Petersen
2020-04-24 10:23 ` [PATCH V8 04/11] blk-mq: assign rq->tag in blk_mq_get_driver_tag Ming Lei
2020-04-24 10:35 ` Christoph Hellwig
2020-04-24 13:02 ` Hannes Reinecke
2020-04-25 2:54 ` Ming Lei
2020-04-25 18:26 ` Hannes Reinecke
2020-04-24 10:23 ` [PATCH V8 05/11] blk-mq: support rq filter callback when iterating rqs Ming Lei
2020-04-24 13:17 ` Hannes Reinecke
2020-04-25 3:04 ` Ming Lei
2020-04-24 10:23 ` [PATCH V8 06/11] blk-mq: prepare for draining IO when hctx's all CPUs are offline Ming Lei
2020-04-24 13:23 ` Hannes Reinecke
2020-04-25 3:24 ` Ming Lei
2020-04-24 10:23 ` [PATCH V8 07/11] blk-mq: stop to handle IO and drain IO before hctx becomes inactive Ming Lei
2020-04-24 10:38 ` Christoph Hellwig
2020-04-25 3:17 ` Ming Lei
2020-04-25 8:32 ` Christoph Hellwig
2020-04-25 9:34 ` Ming Lei
2020-04-25 9:53 ` Ming Lei
2020-04-25 15:48 ` Christoph Hellwig
2020-04-26 2:06 ` Ming Lei
2020-04-26 8:19 ` John Garry
2020-04-27 15:36 ` Christoph Hellwig
2020-04-28 1:10 ` Ming Lei
2020-04-27 19:03 ` Paul E. McKenney
2020-04-28 6:54 ` Christoph Hellwig
2020-04-28 15:58 ` Peter Zijlstra
2020-04-29 2:16 ` Ming Lei
2020-04-29 8:07 ` Will Deacon
2020-04-29 9:46 ` Ming Lei
2020-04-29 12:27 ` Will Deacon
2020-04-29 13:43 ` Ming Lei
2020-04-29 17:34 ` Will Deacon
2020-04-30 0:39 ` Ming Lei
2020-04-30 11:04 ` Will Deacon
2020-04-30 14:02 ` Ming Lei
2020-05-05 15:46 ` Christoph Hellwig
2020-05-06 1:24 ` Ming Lei
2020-05-06 7:28 ` Will Deacon
2020-05-06 8:07 ` Ming Lei
2020-05-06 9:56 ` Will Deacon
2020-05-06 10:22 ` Ming Lei [this message]
2020-04-29 17:46 ` Paul E. McKenney
2020-04-30 0:43 ` Ming Lei
2020-04-24 13:27 ` Hannes Reinecke
2020-04-25 3:30 ` Ming Lei
2020-04-24 13:42 ` John Garry
2020-04-25 3:41 ` Ming Lei
2020-04-24 10:23 ` [PATCH V8 08/11] block: add blk_end_flush_machinery Ming Lei
2020-04-24 10:41 ` Christoph Hellwig
2020-04-25 3:44 ` Ming Lei
2020-04-25 8:11 ` Christoph Hellwig
2020-04-25 9:51 ` Ming Lei
2020-04-24 13:47 ` Hannes Reinecke
2020-04-25 3:47 ` Ming Lei
2020-04-24 10:23 ` [PATCH V8 09/11] blk-mq: add blk_mq_hctx_handle_dead_cpu for handling cpu dead Ming Lei
2020-04-24 10:42 ` Christoph Hellwig
2020-04-25 3:48 ` Ming Lei
2020-04-24 13:48 ` Hannes Reinecke
2020-04-24 10:23 ` [PATCH V8 10/11] blk-mq: re-submit IO in case that hctx is inactive Ming Lei
2020-04-24 10:44 ` Christoph Hellwig
2020-04-25 3:52 ` Ming Lei
2020-04-24 13:55 ` Hannes Reinecke
2020-04-25 3:59 ` Ming Lei
2020-04-24 10:23 ` [PATCH V8 11/11] block: deactivate hctx when the hctx is actually inactive Ming Lei
2020-04-24 10:43 ` Christoph Hellwig
2020-04-24 13:56 ` Hannes Reinecke
2020-04-24 15:23 ` [PATCH V8 00/11] blk-mq: improvement CPU hotplug Jens Axboe
2020-04-24 15:40 ` Christoph Hellwig
2020-04-24 15:41 ` 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=20200506102240.GA1261234@T590 \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=john.garry@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
/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).