Skip to contentSkip to conversation

block/mq-deadline: adjust the timeout period of the per_prio->dispatch

PATCH RESEND Superseded chengkaitao 3 participants 4 messages Sep 26, 2025 – Oct 3, 2025 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 block/mq-deadline: adjust the timeout period of the per_prio->dispatch

From: chengkaitao <[email protected]>

Reference function started_after()
Before modification:
Timeout for dispatch{read}: 9.5s
started_after - 0.5s < latest_start - 10s
9.5s < latest_start - started_after

Timeout for dispatch{write}: 5s
started_after - 5s < latest_start - 10s
5s < latest_start - started_after

At this point, write requests have higher priority than read requests.

After modification:
Timeout for dispatch{read/write}: 5s prio_aging_expire / 2 < latest_start - started_after

---
 block/mq-deadline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/mq-deadline.c +2 -1
index b9b7cdf1d3c9..f311168f8dfe 100644
@@ -672,7 +672,8 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
 
 	if (flags & BLK_MQ_INSERT_AT_HEAD) {
 		list_add(&rq->queuelist, &per_prio->dispatch);
-		rq->fifo_time = jiffies;
+		rq->fifo_time = jiffies + dd->fifo_expire[data_dir]
+				- dd->prio_aging_expire / 2;
 	} else {
 		deadline_add_rq_rb(per_prio, rq);
 
Signature · 1 line
2.50.1 (Apple Git-155)
maintainer
#1 lore raw
Quoted 28 lines · chengkaitao

From: chengkaitao <[email protected]>

Reference function started_after()
Before modification:
Timeout for dispatch{read}: 9.5s
started_after - 0.5s < latest_start - 10s
9.5s < latest_start - started_after

Timeout for dispatch{write}: 5s
started_after - 5s < latest_start - 10s
5s < latest_start - started_after

At this point, write requests have higher priority than read requests.

After modification:
Timeout for dispatch{read/write}: 5s prio_aging_expire / 2 < latest_start - started_after

---
 block/mq-deadline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/mq-deadline.c +0 -0
index b9b7cdf1d3c9..f311168f8dfe 100644

block/mq-deadline.c static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, · line 679

Quoted 9 lines
block/mq-deadline.c +2 -1
@@ -672,7 +672,8 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
 
 	if (flags & BLK_MQ_INSERT_AT_HEAD) {
 		list_add(&rq->queuelist, &per_prio->dispatch);
-		rq->fifo_time = jiffies;
+		rq->fifo_time = jiffies + dd->fifo_expire[data_dir]
+				- dd->prio_aging_expire / 2;
 	} else {
 		deadline_add_rq_rb(per_prio, rq);
 

Adding Damien as he's worked on mq-deadline the most recently.

Signature · 1 line
Jens Axboe
#2 lore raw
In reply to chengkaitao
Quoted 3 lines · chengkaitao

From: chengkaitao <[email protected]>

Reference function started_after()

What does this mean ?

Quoted 9 lines

Before modification:
Timeout for dispatch{read}: 9.5s
started_after - 0.5s < latest_start - 10s
9.5s < latest_start - started_after

Timeout for dispatch{write}: 5s
started_after - 5s < latest_start - 10s
5s < latest_start - started_after

Quoted 5 lines

At this point, write requests have higher priority than read requests.

After modification:
Timeout for dispatch{read/write}: 5s prio_aging_expire / 2 < latest_start - started_after

This is extremely hard to parse and understand. Can you please make full sentences that explain what the problem is, and for your example, the starting situation/state you are in ? E.g "If there are a lot of request inserted at head, then ... Blah"

Also, in the title, s/timeout period/timeout

Quoted 10 lines
---
 block/mq-deadline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/mq-deadline.c +0 -0
index b9b7cdf1d3c9..f311168f8dfe 100644

block/mq-deadline.c static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, · line 676

Quoted 6 lines
block/mq-deadline.c +2 -1
@@ -672,7 +672,8 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
 
 	if (flags & BLK_MQ_INSERT_AT_HEAD) {
 		list_add(&rq->queuelist, &per_prio->dispatch);
-		rq->fifo_time = jiffies;
+		rq->fifo_time = jiffies + dd->fifo_expire[data_dir]
+				- dd->prio_aging_expire / 2;

The request is inserted to the dispatch list directly here. So why do we need to change the timeout to switch to fifo ? Your commit message does not explain that at all, and I do not see a trivial explanation for it myself. Please clarify. I suspect that you have a situation where you see a lot of requeue at head and that completely skew the fifo/prio aging ? I am memrely guessing here. Please resend your patch with a clear commit message, and also a comment for the change above explaining what is being done.

Quoted 3 lines
block/mq-deadline.c +0 -0
 	} else {
 		deadline_add_rq_rb(per_prio, rq);
 
Signature · 2 lines
Damien Le Moal
Western Digital Research
#3 lore raw
In reply to chengkaitao
Quoted 12 lines · chengkaitao

From: chengkaitao <[email protected]>

Reference function started_after()
Before modification:
Timeout for dispatch{read}: 9.5s
started_after - 0.5s < latest_start - 10s
9.5s < latest_start - started_after

Timeout for dispatch{write}: 5s
started_after - 5s < latest_start - 10s
5s < latest_start - started_after

Quoted 7 lines

At this point, write requests have higher priority than read requests.

After modification:
Timeout for dispatch{read/write}: 5s prio_aging_expire / 2 < latest_start - started_after

Also please write your name correctly here, separating first and last names with a capital first letter for each (unless of course if this is your only name/firstname, but still missing the capital letter).

Quoted 18 lines
---
 block/mq-deadline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/mq-deadline.c +2 -1
index b9b7cdf1d3c9..f311168f8dfe 100644
@@ -672,7 +672,8 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
 
 	if (flags & BLK_MQ_INSERT_AT_HEAD) {
 		list_add(&rq->queuelist, &per_prio->dispatch);
-		rq->fifo_time = jiffies;
+		rq->fifo_time = jiffies + dd->fifo_expire[data_dir]
+				- dd->prio_aging_expire / 2;
 	} else {
 		deadline_add_rq_rb(per_prio, rq);
 
Signature · 2 lines
Damien Le Moal
Western Digital Research