mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 1/1] nvme: complete directly for hctx with only one ctx mapping
@ 2023-05-30  2:41 Po-Wen Kao
  2023-05-30  2:49 ` Stanley Chu
  2023-05-30 17:45 ` Keith Busch
  0 siblings, 2 replies; 5+ messages in thread
From: Po-Wen Kao @ 2023-05-30  2:41 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek,
	Jens Axboe, Keith Busch, Christoph Hellwig, Sagi Grimberg,
	Matthias Brugger, AngeloGioacchino Del Regno
  Cc: wsd_upstream, peter.wang, stanley.chu, powen.kao, alice.chao,
	naomi.chu, chun-hung.wu, cc.chou, eddie.huang, Ed Tsai,
	linux-block, linux-nvme

From: Ed Tsai <ed.tsai@mediatek.com>

Refer to
commit f168420c62e7
("blk-mq: don't redirect completion for hctx withs only one ctx mapping")
When nvme applies a 1:1 mapping of hctx and ctx, there will be no remote
request.

But for ufs, the submission and completion queue could be asymmetric.
(e.g. Multiple SQs share one CQ) Therefore, 1:1 mapping of hctx and
ctx won't complete request on the submission cpu. In this situation,
put this condition in block layer could violate the
QUEUE_FLAG_SAME_FORCE, as a result, move this back to nvme.

Signed-off-by: Ed Tsai <ed.tsai@mediatek.com>
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
---
 block/blk-mq.c           | 8 +++-----
 drivers/nvme/host/nvme.h | 4 ++++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 1749f5890606..b60c78f5ad46 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1181,12 +1181,10 @@ bool blk_mq_complete_request_remote(struct request *rq)
 	WRITE_ONCE(rq->state, MQ_RQ_COMPLETE);
 
 	/*
-	 * For request which hctx has only one ctx mapping,
-	 * or a polled request, always complete locally,
-	 * it's pointless to redirect the completion.
+	 * For a polled request, always complete locally, it's pointless
+	 * to redirect the completion.
 	 */
-	if (rq->mq_hctx->nr_ctx == 1 ||
-		rq->cmd_flags & REQ_POLLED)
+	if (rq->cmd_flags & REQ_POLLED)
 		return false;
 
 	if (blk_mq_complete_need_ipi(rq)) {
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 7cf8e44d135e..acc9b1ce071d 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -702,6 +702,10 @@ static inline bool nvme_try_complete_req(struct request *req, __le16 status,
 	nvme_should_fail(req);
 	if (unlikely(blk_should_fake_timeout(req->q)))
 		return true;
+	if (likely(req->mq_hctx->nr_ctx == 1)) {
+		WRITE_ONCE(req->state, MQ_RQ_COMPLETE);
+		return false;
+	}
 	return blk_mq_complete_request_remote(req);
 }
 
-- 
2.18.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-31  1:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30  2:41 [PATCH v1 1/1] nvme: complete directly for hctx with only one ctx mapping Po-Wen Kao
2023-05-30  2:49 ` Stanley Chu
2023-05-30 17:45 ` Keith Busch
2023-05-31  1:14   ` Ed Tsai (蔡宗軒)
2023-05-31  1:32   ` Ed Tsai (蔡宗軒)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®