* [PATCH] nvme-pci: refactoring nvme_queue_rqs
@ 2023-05-02 8:13 Irvin Cote
2023-05-02 16:36 ` Keith Busch
0 siblings, 1 reply; 2+ messages in thread
From: Irvin Cote @ 2023-05-02 8:13 UTC (permalink / raw)
To: hch; +Cc: sagi, kbusch, axboe, linux-nvme, Irvin Cote
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] nvme-pci: refactoring nvme_queue_rqs
2023-05-02 8:13 [PATCH] nvme-pci: refactoring nvme_queue_rqs Irvin Cote
@ 2023-05-02 16:36 ` Keith Busch
0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2023-05-02 16:36 UTC (permalink / raw)
To: Irvin Cote; +Cc: hch, sagi, axboe, linux-nvme
On Tue, May 02, 2023 at 05:13:01AM -0300, Irvin Cote wrote:
> 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).
blk-mq only guarantees the list of requests are all from the same
request_queue, not necessarily the same hctx. At the nvme driver
level, this means the request list is for the same namespace, but
not necessarily allocated out of the same SQ.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-02 16:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-02 8:13 [PATCH] nvme-pci: refactoring nvme_queue_rqs Irvin Cote
2023-05-02 16:36 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox