public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Irvin Cote <irvincoteg@gmail.com>
To: hch@lst.de
Cc: sagi@grimberg.me, kbusch@kernel.org, axboe@fb.com,
	linux-nvme@lists.infradead.org, Irvin Cote <irvincoteg@gmail.com>
Subject: [PATCH] nvme-pci: refactoring nvme_queue_rqs
Date: Tue,  2 May 2023 05:13:01 -0300	[thread overview]
Message-ID: <20230502081301.73007-1-irvincoteg@gmail.com> (raw)

When dealing with the queue_rqs callback, the block
layer guarantees that it only provides with us with
requests from the same queue (cf include/linux/blk-mq.h).
Therefore, we can reduce the code for nvme_queue_rqs.
We retrieve the nvmeq once because it is the same for all
the requests. Then the only thing the for loop does is 
test the requests and move them accordingly to requeue 
list. Finally we submit rqlist once outside the loop.

Signed-off-by: Irvin Cote <irvincoteg@gmail.com>
---
 drivers/nvme/host/pci.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 7f25c0fe3a0b..f6cbcb63fc5d 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -934,8 +934,9 @@ static void nvme_queue_rqs(struct request **rqlist)
 	struct request *req, *next, *prev = NULL;
 	struct request *requeue_list = NULL;
 
+	struct nvme_queue *nvmeq = *rqlist->mq_hctx->driver_data;
+
 	rq_list_for_each_safe(rqlist, req, next) {
-		struct nvme_queue *nvmeq = req->mq_hctx->driver_data;
 
 		if (!nvme_prep_rq_batch(nvmeq, req)) {
 			/* detach 'req' and add to remainder list */
@@ -946,16 +947,11 @@ static void nvme_queue_rqs(struct request **rqlist)
 				continue;
 		}
 
-		if (!next || req->mq_hctx != next->mq_hctx) {
-			/* detach rest of list, and submit */
-			req->rq_next = NULL;
-			nvme_submit_cmds(nvmeq, rqlist);
-			*rqlist = next;
-			prev = NULL;
-		} else
-			prev = req;
+		prev = req;
 	}
 
+	nvme_submit_cmds(nvmeq, rqlist);
+
 	*rqlist = requeue_list;
 }
 
-- 
2.39.2



             reply	other threads:[~2023-05-02  8:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02  8:13 Irvin Cote [this message]
2023-05-02 16:36 ` [PATCH] nvme-pci: refactoring nvme_queue_rqs Keith Busch

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=20230502081301.73007-1-irvincoteg@gmail.com \
    --to=irvincoteg@gmail.com \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=kbusch@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