From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, John Garry <john.garry@huawei.com>,
Hannes Reinecke <hare@suse.com>, Christoph Hellwig <hch@lst.de>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH V10 07/11] blk-mq: stop to handle IO and drain IO before hctx becomes inactive
Date: Sat, 9 May 2020 10:20:51 +0800 [thread overview]
Message-ID: <20200509022051.GC1392681@T590> (raw)
In-Reply-To: <dbada06d-fcc4-55df-935e-2a46433f28a1@acm.org>
On Fri, May 08, 2020 at 04:39:46PM -0700, Bart Van Assche wrote:
> On 2020-05-04 19:09, Ming Lei wrote:
> > -static bool blk_mq_get_driver_tag(struct request *rq)
> > +static bool blk_mq_get_driver_tag(struct request *rq, bool direct_issue)
> > {
> > if (rq->tag != -1)
> > return true;
> > - return __blk_mq_get_driver_tag(rq);
> > +
> > + if (!__blk_mq_get_driver_tag(rq))
> > + return false;
> > + /*
> > + * In case that direct issue IO process is migrated to other CPU
> > + * which may not belong to this hctx, add one memory barrier so we
> > + * can order driver tag assignment and checking BLK_MQ_S_INACTIVE.
> > + * Otherwise, barrier() is enough given both setting BLK_MQ_S_INACTIVE
> > + * and driver tag assignment are run on the same CPU because
> > + * BLK_MQ_S_INACTIVE is only set after the last CPU of this hctx is
> > + * becoming offline.
> > + *
> > + * Process migration might happen after the check on current processor
> > + * id, smp_mb() is implied by processor migration, so no need to worry
> > + * about it.
> > + */
> > + if (unlikely(direct_issue && rq->mq_ctx->cpu != raw_smp_processor_id()))
> > + smp_mb();
> > + else
> > + barrier();
> > +
> > + if (unlikely(test_bit(BLK_MQ_S_INACTIVE, &rq->mq_hctx->state))) {
> > + blk_mq_put_driver_tag(rq);
> > + return false;
> > + }
> > + return true;
> > }
>
> How much does this patch slow down the hot path?
Basically zero cost is added to hot path, exactly:
> + if (unlikely(direct_issue && rq->mq_ctx->cpu != raw_smp_processor_id()))
In case of direct issue, chance of the io process migration is very
small, since basically direct issue follows request allocation and the
time is quite small, so smp_mb() won't be run most of times.
> + smp_mb();
> + else
> + barrier();
So barrier() is added most of times, however the effect can be ignored
since it is just a compiler barrier.
> +
> + if (unlikely(test_bit(BLK_MQ_S_INACTIVE, &rq->mq_hctx->state))) {
hctx->state is always checked in hot path, so basically zero cost.
> + blk_mq_put_driver_tag(rq);
> + return false;
> + }
>
> Can CPU migration be fixed without affecting the hot path, e.g. by using
> the request queue freezing mechanism?
Why do we want to fix CPU migration of direct issue IO process? It may not be
necessary or quite difficultly:
1) preempt disable is removed previously in cleanup patch since request
is allocated
2) we have drivers which may set BLOCKING, so .queue_rq() may sleep
Not sure why you mention queue freezing.
Thanks,
Ming
next prev parent reply other threads:[~2020-05-09 2:21 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 2:09 [PATCH V10 00/11] blk-mq: improvement CPU hotplug Ming Lei
2020-05-05 2:09 ` [PATCH V10 01/11] block: clone nr_integrity_segments and write_hint in blk_rq_prep_clone Ming Lei
2020-05-05 2:09 ` [PATCH V10 02/11] block: add helper for copying request Ming Lei
2020-05-05 2:09 ` [PATCH V10 03/11] blk-mq: mark blk_mq_get_driver_tag as static Ming Lei
2020-05-05 2:09 ` [PATCH V10 04/11] blk-mq: assign rq->tag in blk_mq_get_driver_tag Ming Lei
2020-05-05 2:09 ` [PATCH V10 05/11] blk-mq: support rq filter callback when iterating rqs Ming Lei
2020-05-08 23:32 ` Bart Van Assche
2020-05-09 0:18 ` Bart Van Assche
2020-05-09 2:05 ` Ming Lei
2020-05-09 3:08 ` Bart Van Assche
2020-05-09 3:52 ` Ming Lei
2020-05-05 2:09 ` [PATCH V10 06/11] blk-mq: prepare for draining IO when hctx's all CPUs are offline Ming Lei
2020-05-05 6:14 ` Hannes Reinecke
2020-05-08 23:26 ` Bart Van Assche
2020-05-09 2:09 ` Ming Lei
2020-05-09 3:11 ` Bart Van Assche
2020-05-09 3:56 ` Ming Lei
2020-05-05 2:09 ` [PATCH V10 07/11] blk-mq: stop to handle IO and drain IO before hctx becomes inactive Ming Lei
2020-05-08 23:39 ` Bart Van Assche
2020-05-09 2:20 ` Ming Lei [this message]
2020-05-09 3:24 ` Bart Van Assche
2020-05-09 4:10 ` Ming Lei
2020-05-09 14:18 ` Bart Van Assche
2020-05-11 1:45 ` Ming Lei
2020-05-11 3:20 ` Bart Van Assche
2020-05-11 3:48 ` Ming Lei
2020-05-11 20:56 ` Bart Van Assche
2020-05-12 1:25 ` Ming Lei
2020-05-05 2:09 ` [PATCH V10 08/11] block: add blk_end_flush_machinery Ming Lei
2020-05-05 2:09 ` [PATCH V10 09/11] blk-mq: add blk_mq_hctx_handle_dead_cpu for handling cpu dead Ming Lei
2020-05-05 2:09 ` [PATCH V10 10/11] blk-mq: re-submit IO in case that hctx is inactive Ming Lei
2020-05-05 2:09 ` [PATCH V10 11/11] block: deactivate hctx when the hctx is actually inactive Ming Lei
2020-05-09 14:07 ` Bart Van Assche
2020-05-11 2:11 ` Ming Lei
2020-05-11 3:30 ` Bart Van Assche
2020-05-11 4:08 ` Ming Lei
2020-05-11 20:52 ` Bart Van Assche
2020-05-12 1:43 ` Ming Lei
2020-05-12 2:08 ` Ming Lei
2020-05-08 21:49 ` [PATCH V10 00/11] blk-mq: improvement CPU hotplug Ming Lei
2020-05-09 3:17 ` 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=20200509022051.GC1392681@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=tglx@linutronix.de \
/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).