linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Hannes Reinecke <hare@suse.de>
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 V8 10/11] blk-mq: re-submit IO in case that hctx is inactive
Date: Sat, 25 Apr 2020 11:59:43 +0800	[thread overview]
Message-ID: <20200425035943.GK477579@T590> (raw)
In-Reply-To: <1bba5ed8-21db-751b-e638-4b287db14cd0@suse.de>

On Fri, Apr 24, 2020 at 03:55:35PM +0200, Hannes Reinecke wrote:
> On 4/24/20 12:23 PM, Ming Lei wrote:
> > When all CPUs in one hctx are offline and this hctx becomes inactive, we
> > shouldn't run this hw queue for completing request any more.
> > 
> > So allocate request from one live hctx, and clone & resubmit the request,
> > either it is from sw queue or scheduler queue.
> > 
> > Cc: John Garry <john.garry@huawei.com>
> > Cc: Bart Van Assche <bvanassche@acm.org>
> > Cc: Hannes Reinecke <hare@suse.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > ---
> >   block/blk-mq.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++--
> >   1 file changed, 98 insertions(+), 4 deletions(-)
> > 
> > diff --git a/block/blk-mq.c b/block/blk-mq.c
> > index 0759e0d606b3..a4a26bb23533 100644
> > --- a/block/blk-mq.c
> > +++ b/block/blk-mq.c
> > @@ -2370,6 +2370,98 @@ static int blk_mq_hctx_notify_online(unsigned int cpu, struct hlist_node *node)
> >   	return 0;
> >   }
> > +static void blk_mq_resubmit_end_rq(struct request *rq, blk_status_t error)
> > +{
> > +	struct request *orig_rq = rq->end_io_data;
> > +
> > +	blk_mq_cleanup_rq(orig_rq);
> > +	blk_mq_end_request(orig_rq, error);
> > +
> > +	blk_put_request(rq);
> > +}
> > +
> > +static void blk_mq_resubmit_rq(struct request *rq)
> > +{
> > +	struct request *nrq;
> > +	unsigned int 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 by clearing NOWAIT */
> > +	nrq = blk_get_request(rq->q, rq->cmd_flags & ~REQ_NOWAIT, flags);
> > +	if (!nrq)
> > +		return;
> > +
> 
> Ah-ha. So what happens if we don't get a request here?

So far it isn't possible if NOWAIT is cleared because the two requests
belong to different hctx.

> 
> > +	blk_rq_copy_request(nrq, rq);
> > +
> > +	nrq->timeout = rq->timeout;
> > +	nrq->rq_disk = rq->rq_disk;
> > +	nrq->part = rq->part;
> > +
> > +	memcpy(blk_mq_rq_to_pdu(nrq), blk_mq_rq_to_pdu(rq),
> > +			rq->q->tag_set->cmd_size);
> > +
> > +	nrq->end_io = blk_mq_resubmit_end_rq;
> > +	nrq->end_io_data = rq;
> > +	nrq->bio = rq->bio;
> > +	nrq->biotail = rq->biotail;
> > +
> > +	if (blk_insert_cloned_request(nrq->q, nrq) != BLK_STS_OK)
> > +		blk_mq_request_bypass_insert(nrq, false, true);
> > +}
> > +
> 
> Not sure if that is a good idea.
> With the above code we would having to allocate an additional
> tag per request; if we're running full throttle with all tags active where
> should they be coming from?

The two requests are from different hctx, and we don't have
per-request-queue throttle in blk-mq, and scsi does have, however
no requests from this inactive hctx exists in LLD.

So no the throttle you worry about.

> 
> And all the while we _have_ perfectly valid tags; the tag of the original
> request _is_ perfectly valid, and we have made sure that it's not inflight

No, we are talking request in sw queue and scheduler queue, which aren't
assigned tag yet.

> (because if it were we would have to wait for to be completed by the
> hardware anyway).
> 
> So why can't we re-use the existing tag here?

No, the tag doesn't exist.


Thanks,
Ming


  reply	other threads:[~2020-04-25  4:00 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
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 [this message]
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=20200425035943.GK477579@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.com \
    --cc=hare@suse.de \
    --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).