From: axboe@fb.com (Jens Axboe)
Subject: [PATCH] NVMe: limit max completion iterations in nvme_process_cq()
Date: Fri, 14 Nov 2014 09:48:36 -0700 [thread overview]
Message-ID: <20141114164836.GB12860@kernel.dk> (raw)
This is an unbounded loop. If we have per-cpu queues this is
usually not a problem, but if CPUs share a queue, then we could
have some of them continually queueing IO and the loop could take
forever to exit.
Limit max iterations to the queue depth of the given completion
queue, which seems like a nice number to use.
Signed-off-by: Jens Axboe <axboe at fb.com>
---
drivers/block/nvme-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index f2964dfcea6c..fc2fc53992cb 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -697,12 +697,13 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
static int nvme_process_cq(struct nvme_queue *nvmeq)
{
+ unsigned int max_iter = nvmeq->q_depth;
u16 head, phase;
head = nvmeq->cq_head;
phase = nvmeq->cq_phase;
- for (;;) {
+ while (max_iter--) {
void *ctx;
nvme_completion_fn fn;
struct nvme_completion cqe = nvmeq->cqes[head];
--
1.9.1
--
Jens Axboe
next reply other threads:[~2014-11-14 16:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-14 16:48 Jens Axboe [this message]
2014-11-14 17:56 ` [PATCH] NVMe: limit max completion iterations in nvme_process_cq() Keith Busch
2014-11-14 18:00 ` 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=20141114164836.GB12860@kernel.dk \
--to=axboe@fb.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.