From: Ming Lei <ming.lei@redhat.com>
To: John Garry <john.garry@huawei.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Daniel Wagner <dwagner@suse.de>, Wen Xiong <wenxiong@us.ibm.com>
Subject: Re: [PATCH 1/2] blk-mq: not deactivate hctx if the device doesn't use managed irq
Date: Wed, 30 Jun 2021 08:32:46 +0800 [thread overview]
Message-ID: <YNu7rs7j5/KtQjAi@T590> (raw)
In-Reply-To: <c31aa259-d3a8-8c70-efce-b7af02bfd609@huawei.com>
On Tue, Jun 29, 2021 at 04:49:56PM +0100, John Garry wrote:
> On 29/06/2021 08:49, Ming Lei wrote:
> > hctx is deactivated when all CPU in hctx->cpumask become offline by
> > draining all requests originated from this hctx and moving new
> > allocation to active hctx. This way is for avoiding inflight IO when
> > the managed irq is shutdown.
> >
> > Some drivers(nvme fc, rdma, tcp, loop) doesn't use managed irq, so
> > they needn't to deactivate hctx. Also, they are the only user of
> > blk_mq_alloc_request_hctx() which is used for connecting io queue.
> > And their requirement is that the connect request can be submitted
> > via one specified hctx on which all CPU in its hctx->cpumask may have
> > become offline.
> >
> > Address the requirement for nvme fc/rdma/loop, so the reported kernel
> > panic on the following line in blk_mq_alloc_request_hctx() can be fixed.
> >
> > data.ctx = __blk_mq_get_ctx(q, cpu)
> >
> > Cc: Sagi Grimberg <sagi@grimberg.me>
> > Cc: Daniel Wagner <dwagner@suse.de>
> > Cc: Wen Xiong <wenxiong@us.ibm.com>
> > Cc: John Garry <john.garry@huawei.com>
> > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > ---
> > block/blk-mq.c | 6 +++++-
> > include/linux/blk-mq.h | 1 +
> > 2 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/block/blk-mq.c b/block/blk-mq.c
> > index df5dc3b756f5..74632f50d969 100644
> > --- a/block/blk-mq.c
> > +++ b/block/blk-mq.c
> > @@ -494,7 +494,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
> > data.hctx = q->queue_hw_ctx[hctx_idx];
> > if (!blk_mq_hw_queue_mapped(data.hctx))
> > goto out_queue_exit;
> > - cpu = cpumask_first_and(data.hctx->cpumask, cpu_online_mask);
> > + cpu = cpumask_first(data.hctx->cpumask);
> > data.ctx = __blk_mq_get_ctx(q, cpu);
> > if (!q->elevator)
> > @@ -2570,6 +2570,10 @@ static int blk_mq_hctx_notify_offline(unsigned int cpu, struct hlist_node *node)
> > !blk_mq_last_cpu_in_hctx(cpu, hctx))
> > return 0;
> > + /* Controller doesn't use managed IRQ, no need to deactivate hctx */
> > + if (hctx->flags & BLK_MQ_F_NOT_USE_MANAGED_IRQ)
> > + return 0;
> Is there anything to be gained in registering the CPU hotplug handler for
> the hctx in this case at all?
Indeed, we may replace BLK_MQ_F_STACKING with BLK_MQ_F_NOT_USE_MANAGED_IRQ
(BLK_MQ_F_NO_MANAGED_IRQ) too, and the latter is one general solution.
>
> > +
> > /*
> > * Prevent new request from being allocated on the current hctx.
> > *
> > diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
> > index 21140132a30d..600c5dd1a069 100644
> > --- a/include/linux/blk-mq.h
> > +++ b/include/linux/blk-mq.h
> > @@ -403,6 +403,7 @@ enum {
> > */
> > BLK_MQ_F_STACKING = 1 << 2,
> > BLK_MQ_F_TAG_HCTX_SHARED = 1 << 3,
> > + BLK_MQ_F_NOT_USE_MANAGED_IRQ = 1 << 4,
>
> Many block drivers don't use managed interrupts - to be proper, why not set
> this everywhere (which doesn't use managed interrupts)? I know why, but it's
> odd.
It is just one small optimization in slow path for other drivers, not sure these
drivers are interested in such change. It only serves as fix for callers of
blk_mq_alloc_request_hctx().
Anyway, we can document the situation.
>
> As an alternative, if the default queue mapping was used (in
> blk_mq_map_queues()), then that's the same thing as
> BLK_MQ_F_NOT_USE_MANAGED_IRQ in reality, right? If so, could we
> alternatively check for that somehow?
This way can't work, for example of NVMe PCI, managed irq is used for
the default/write queues, but poll queues uses blk_mq_map_queues().
Also it can't cover all cases, such as MVMe RDMA.
Using managed irq or not is thing of driver's choice, and not sure if it
is good for block layer to provide such abstract. I'd suggest to fix the
issue still by passing one flag, given we needn't it everywhere so far.
Thanks,
Ming
next prev parent reply other threads:[~2021-06-30 0:33 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-29 7:49 [PATCH 0/2] blk-mq: fix blk_mq_alloc_request_hctx Ming Lei
2021-06-29 7:49 ` [PATCH 1/2] blk-mq: not deactivate hctx if the device doesn't use managed irq Ming Lei
2021-06-29 12:39 ` Hannes Reinecke
2021-06-29 14:17 ` Ming Lei
2021-06-29 15:49 ` John Garry
2021-06-30 0:32 ` Ming Lei [this message]
2021-06-30 9:25 ` John Garry
2021-07-01 9:52 ` Christoph Hellwig
2021-06-29 23:30 ` Damien Le Moal
2021-06-30 18:58 ` Sagi Grimberg
2021-06-30 21:57 ` Damien Le Moal
2021-07-01 14:20 ` Keith Busch
2021-06-29 7:49 ` [PATCH 2/2] nvme: pass BLK_MQ_F_NOT_USE_MANAGED_IRQ for fc/rdma/tcp/loop Ming Lei
2021-06-30 8:15 ` Hannes Reinecke
2021-06-30 8:47 ` Ming Lei
2021-06-30 8:18 ` [PATCH 0/2] blk-mq: fix blk_mq_alloc_request_hctx Hannes Reinecke
2021-06-30 8:42 ` Ming Lei
2021-06-30 9:43 ` Hannes Reinecke
2021-06-30 9:53 ` Ming Lei
2021-06-30 18:59 ` Sagi Grimberg
2021-06-30 19:46 ` Hannes Reinecke
2021-06-30 23:59 ` Ming Lei
2021-07-01 8:00 ` Hannes Reinecke
2021-07-01 9:13 ` Ming Lei
2021-07-02 9:47 ` Daniel Wagner
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=YNu7rs7j5/KtQjAi@T590 \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=dwagner@suse.de \
--cc=hch@lst.de \
--cc=john.garry@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=wenxiong@us.ibm.com \
/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