From: Christoph Hellwig <hch@lst.de>
To: Ming Lei <ming.lei@redhat.com>
Cc: 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>, Christoph Hellwig <hch@lst.de>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH V7 7/9] blk-mq: re-submit IO in case that hctx is inactive
Date: Thu, 23 Apr 2020 09:50:11 +0200 [thread overview]
Message-ID: <20200423075011.GH10951@lst.de> (raw)
In-Reply-To: <20200418030925.31996-8-ming.lei@redhat.com>
> +static void blk_mq_resubmit_passthrough_io(struct request *rq)
> +{
> + struct request *nrq;
> + unsigned int flags = 0, cmd_flags = 0;
> + struct blk_mq_hw_ctx *hctx = rq->mq_hctx;
> + struct blk_mq_tags *tags = rq->q->elevator ? hctx->sched_tags :
> + hctx->tags;
> + bool reserved = blk_mq_tag_is_reserved(tags, rq->internal_tag);
> +
> + if (rq->rq_flags & RQF_PREEMPT)
> + flags |= BLK_MQ_REQ_PREEMPT;
> + if (reserved)
> + flags |= BLK_MQ_REQ_RESERVED;
> +
> + /* avoid allocation failure & IO merge */
> + cmd_flags = (rq->cmd_flags & ~REQ_NOWAIT) | REQ_NOMERGE;
> +
> + nrq = blk_get_request(rq->q, cmd_flags, flags);
> + if (!nrq)
> + return;
> +
> + nrq->__sector = blk_rq_pos(rq);
> + nrq->__data_len = blk_rq_bytes(rq);
> + if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) {
> + nrq->rq_flags |= RQF_SPECIAL_PAYLOAD;
> + nrq->special_vec = rq->special_vec;
> + }
> +#if defined(CONFIG_BLK_DEV_INTEGRITY)
> + nrq->nr_integrity_segments = rq->nr_integrity_segments;
> +#endif
> + nrq->nr_phys_segments = rq->nr_phys_segments;
> + nrq->ioprio = rq->ioprio;
> + nrq->extra_len = rq->extra_len;
> + nrq->rq_disk = rq->rq_disk;
> + nrq->part = rq->part;
> + nrq->write_hint = rq->write_hint;
> + nrq->timeout = rq->timeout;
This should share code with blk_rq_prep_clone() using a helper.
Note that blk_rq_prep_clone seems to miss things like the
write_hint and timeout, which we should fix as well.
> +static void blk_mq_resubmit_fs_io(struct request *rq)
> +{
> + struct bio_list list;
> + struct bio *bio;
> +
> + bio_list_init(&list);
> + blk_steal_bios(&list, rq);
> +
> + while (true) {
> + bio = bio_list_pop(&list);
> + if (!bio)
> + break;
> +
> + generic_make_request(bio);
> + }
This could be simplified to:
while ((bio = bio_list_pop(&list)))
generic_make_request(bio);
but then again the generic_make_request seems weird. Do we need
actually need any of the checks in generic_make_request? Shouldn't
we call into blk_mq_make_request directly?
Then again I wonder why the passthrough case doesn't work for
FS requests?
> static int blk_mq_hctx_notify_dead(unsigned int cpu, struct hlist_node *node)
> {
> @@ -2394,14 +2482,38 @@ static int blk_mq_hctx_notify_dead(unsigned int cpu, struct hlist_node *node)
> }
> spin_unlock(&ctx->lock);
>
> + if (!test_bit(BLK_MQ_S_INACTIVE, &hctx->state)) {
> + if (!list_empty(&tmp)) {
> + spin_lock(&hctx->lock);
> + list_splice_tail_init(&tmp, &hctx->dispatch);
> + spin_unlock(&hctx->lock);
> + blk_mq_run_hw_queue(hctx, true);
> + }
> + } else {
What about an early return or two here to save a level of indentation
later?
if (!test_bit(BLK_MQ_S_INACTIVE, &hctx->state)) {
if (list_empty(&tmp))
return 0;
spin_lock(&hctx->lock);
list_splice_tail_init(&tmp, &hctx->dispatch);
spin_unlock(&hctx->lock);
blk_mq_run_hw_queue(hctx, true);
return 0;
}
...
next prev parent reply other threads:[~2020-04-23 7:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-18 3:09 [PATCH V7 0/9] blk-mq: improvement CPU hotplug Ming Lei
2020-04-18 3:09 ` [PATCH V7 1/9] blk-mq: mark blk_mq_get_driver_tag as static Ming Lei
2020-04-23 7:14 ` Christoph Hellwig
2020-04-18 3:09 ` [PATCH V7 2/9] blk-mq: assign rq->tag in blk_mq_get_driver_tag Ming Lei
2020-04-23 7:30 ` Christoph Hellwig
2020-04-18 3:09 ` [PATCH V7 3/9] blk-mq: prepare for draining IO when hctx's all CPUs are offline Ming Lei
2020-04-23 7:31 ` Christoph Hellwig
2020-04-18 3:09 ` [PATCH V7 4/9] blk-mq: support rq filter callback when iterating rqs Ming Lei
2020-04-20 10:34 ` John Garry
2020-04-23 7:31 ` Christoph Hellwig
2020-04-23 7:32 ` Christoph Hellwig
2020-04-18 3:09 ` [PATCH V7 5/9] blk-mq: stop to handle IO and drain IO before hctx becomes inactive Ming Lei
2020-04-23 7:38 ` Christoph Hellwig
2020-04-18 3:09 ` [PATCH V7 6/9] block: add blk_end_flush_machinery Ming Lei
2020-04-23 7:40 ` Christoph Hellwig
2020-04-18 3:09 ` [PATCH V7 7/9] blk-mq: re-submit IO in case that hctx is inactive Ming Lei
2020-04-23 7:50 ` Christoph Hellwig [this message]
2020-04-23 8:46 ` Ming Lei
2020-04-18 3:09 ` [PATCH V7 8/9] blk-mq: handle requests dispatched from IO scheduler in case of inactive hctx Ming Lei
2020-04-23 7:51 ` Christoph Hellwig
2020-04-18 3:09 ` [PATCH V7 9/9] block: deactivate hctx when the hctx is actually inactive Ming Lei
2020-04-20 10:29 ` [PATCH V7 0/9] blk-mq: improvement CPU hotplug John Garry
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=20200423075011.GH10951@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=hare@suse.com \
--cc=john.garry@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.