From: Caleb Sander Mateos <csander@purestorage.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>
Cc: Caleb Sander Mateos <csander@purestorage.com>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] nvme-pci: deduplicate empty request list checks in nvme_queue_rqs()
Date: Tue, 18 Nov 2025 19:17:00 -0700 [thread overview]
Message-ID: <20251119021701.3165123-1-csander@purestorage.com> (raw)
nvme_queue_rqs() checks that nvmeq is non-NULL before calling
nvme_submit_cmds() and nvme_submit_cmds() checks that submit_list is
non-empty before doing anything. A NULL nvmeq means no requests were
processed from the rqlist in nvme_queue_rqs() since the last call to
nvme_submit_cmds(), which implies submit_list is empty. So just check
that submit_list is non-empty before calling nvme_submit_cmds() and drop
the check for NULL nvmeq.
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
drivers/nvme/host/pci.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 15c12e6cba88..8b562563ef89 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1199,13 +1199,10 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
static void nvme_submit_cmds(struct nvme_queue *nvmeq, struct rq_list *rqlist)
{
struct request *req;
- if (rq_list_empty(rqlist))
- return;
-
spin_lock(&nvmeq->sq_lock);
while ((req = rq_list_pop(rqlist))) {
struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
nvme_sq_copy_cmd(nvmeq, &iod->cmd);
@@ -1230,25 +1227,26 @@ static bool nvme_prep_rq_batch(struct nvme_queue *nvmeq, struct request *req)
static void nvme_queue_rqs(struct rq_list *rqlist)
{
struct rq_list submit_list = { };
struct rq_list requeue_list = { };
- struct nvme_queue *nvmeq = NULL;
+ struct nvme_queue *nvmeq;
struct request *req;
while ((req = rq_list_pop(rqlist))) {
- if (nvmeq && nvmeq != req->mq_hctx->driver_data)
+ if (!rq_list_empty(&submit_list) &&
+ nvmeq != req->mq_hctx->driver_data)
nvme_submit_cmds(nvmeq, &submit_list);
nvmeq = req->mq_hctx->driver_data;
if (nvme_prep_rq_batch(nvmeq, req))
rq_list_add_tail(&submit_list, req);
else
rq_list_add_tail(&requeue_list, req);
}
- if (nvmeq)
+ if (!rq_list_empty(&submit_list))
nvme_submit_cmds(nvmeq, &submit_list);
*rqlist = requeue_list;
}
static __always_inline void nvme_pci_unmap_rq(struct request *req)
--
2.45.2
next reply other threads:[~2025-11-19 2:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 2:17 Caleb Sander Mateos [this message]
2025-11-19 5:48 ` [PATCH] nvme-pci: deduplicate empty request list checks in nvme_queue_rqs() Christoph Hellwig
2025-11-19 16:01 ` Caleb Sander Mateos
2025-11-20 6:49 ` Christoph Hellwig
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=20251119021701.3165123-1-csander@purestorage.com \
--to=csander@purestorage.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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