From: Hannes Reinecke <hare@suse.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Ming Lei <ming.lei@redhat.com>,
Daniel Wagner <daniel.wagner@suse.com>,
Christoph Hellwig <hch@lst.de>,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
Wen Xiong <wenxiong@us.ibm.com>, Hannes Reinecke <hare@suse.de>
Subject: [PATCH] blk-mq: don't allocate requests when all cpus in a hctx are offline
Date: Wed, 30 Jun 2021 12:03:42 +0200 [thread overview]
Message-ID: <20210630100342.1100-1-hare@suse.de> (raw)
When all CPUs in a hctx are offline in blk_mq_alloc_request_hctx() we should
not try to allocate the request, as we'll fail later on in blk_mq_get_tag() anyway.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
block/blk-mq.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index f11d4018ce2e..1622d0cabe3a 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -468,13 +468,16 @@ 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;
+ ret = -EWOULDBLOCK;
+ /* all cpus in the hctx are offline, don't try to allocate a tag */
cpu = cpumask_first_and(data.hctx->cpumask, cpu_online_mask);
+ if (unlikely(cpu >= nr_cpu_ids))
+ goto out_queue_exit;
data.ctx = __blk_mq_get_ctx(q, cpu);
if (!q->elevator)
blk_mq_tag_busy(data.hctx);
- ret = -EWOULDBLOCK;
tag = blk_mq_get_tag(&data);
if (tag == BLK_MQ_NO_TAG)
goto out_queue_exit;
--
2.29.2
WARNING: multiple messages have this Message-ID (diff)
From: Hannes Reinecke <hare@suse.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Ming Lei <ming.lei@redhat.com>,
Daniel Wagner <daniel.wagner@suse.com>,
Christoph Hellwig <hch@lst.de>,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
Wen Xiong <wenxiong@us.ibm.com>, Hannes Reinecke <hare@suse.de>
Subject: [PATCH] blk-mq: don't allocate requests when all cpus in a hctx are offline
Date: Wed, 30 Jun 2021 12:03:42 +0200 [thread overview]
Message-ID: <20210630100342.1100-1-hare@suse.de> (raw)
When all CPUs in a hctx are offline in blk_mq_alloc_request_hctx() we should
not try to allocate the request, as we'll fail later on in blk_mq_get_tag() anyway.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
block/blk-mq.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index f11d4018ce2e..1622d0cabe3a 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -468,13 +468,16 @@ 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;
+ ret = -EWOULDBLOCK;
+ /* all cpus in the hctx are offline, don't try to allocate a tag */
cpu = cpumask_first_and(data.hctx->cpumask, cpu_online_mask);
+ if (unlikely(cpu >= nr_cpu_ids))
+ goto out_queue_exit;
data.ctx = __blk_mq_get_ctx(q, cpu);
if (!q->elevator)
blk_mq_tag_busy(data.hctx);
- ret = -EWOULDBLOCK;
tag = blk_mq_get_tag(&data);
if (tag == BLK_MQ_NO_TAG)
goto out_queue_exit;
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next reply other threads:[~2021-06-30 10:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-30 10:03 Hannes Reinecke [this message]
2021-06-30 10:03 ` [PATCH] blk-mq: don't allocate requests when all cpus in a hctx are offline Hannes Reinecke
2021-06-30 10:13 ` Ming Lei
2021-06-30 10:13 ` Ming Lei
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=20210630100342.1100-1-hare@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=daniel.wagner@suse.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=ming.lei@redhat.com \
--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 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.