Thread (7 messages) 7 messages, 3 authors, 2021-08-27

Re: [PATCH] mq-deadline: Fix request accounting

flat view

From: Bart Van Assche <bvanassche@acm.org>
Date: 2021-08-27 02:22:53
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

On 8/24/21 2:35 PM, Niklas Cassel wrote:
Reviewed-by: Niklas Cassel <redacted>
Tested-by: Niklas Cassel <redacted>
Hi Niklas,

Thank you for the help, that's really appreciated. Earlier today I discovered
that this patch does not handle requeuing correctly so I have started testing
the patch below.

---
 block/mq-deadline.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index dbd74bae9f11..c4c3c2e3f446 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -712,7 +712,10 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
 	blk_req_zone_write_unlock(rq);

 	prio = ioprio_class_to_prio[ioprio_class];
-	dd_count(dd, inserted, prio);
+	if (!rq->elv.priv[0]) {
+		dd_count(dd, inserted, prio);
+		rq->elv.priv[0] = (void *)(uintptr_t)1;
+	}

 	if (blk_mq_sched_try_insert_merge(q, rq, &free)) {
 		blk_mq_free_requests(&free);
@@ -761,12 +764,10 @@ static void dd_insert_requests(struct blk_mq_hw_ctx *hctx,
 	spin_unlock(&dd->lock);
 }

-/*
- * Nothing to do here. This is defined only to ensure that .finish_request
- * method is called upon request completion.
- */
+/* Callback from inside blk_mq_rq_ctx_init(). */
 static void dd_prepare_request(struct request *rq)
 {
+	rq->elv.priv[0] = NULL;
 }

 /*
@@ -793,6 +794,14 @@ static void dd_finish_request(struct request *rq)
 	const enum dd_prio prio = ioprio_class_to_prio[ioprio_class];
 	struct dd_per_prio *per_prio = &dd->per_prio[prio];

+	/*
+	 * The block layer core may call dd_finish_request() without having
+	 * called dd_insert_requests(). Skip requests that bypassed I/O
+	 * scheduling. See also blk_mq_request_bypass_insert().
+	 */
+	if (!rq->elv.priv[0])
+		return;
+
 	dd_count(dd, completed, prio);

 	if (blk_queue_is_zoned(q)) {
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help