Skip to contentSkip to conversation

cfq-iosched: fix no-idle preemption logic

PATCH In review Corrado Zoccolo 2 participants 2 messages Nov 24, 2009 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 cfq-iosched: fix no-idle preemption logic

An incoming no-idle queue should preempt the active no-idle queue only if the active queue is idling due to service tree empty. Previous code was buggy in two ways:
* it relied on service_tree field to be set on the active queue, while it is not set when the code is idling for a new request
* it didn't check for the service tree empty condition, so could lead to LIFO behaviour if multiple queues with depth > 1 were preempting each other on an non-NCQ device.

---
 block/cfq-iosched.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
block/cfq-iosched.c +3 -2
index 6925ab9..2a304f4 100644
@@ -2401,8 +2401,9 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
 	if (cfq_class_idle(cfqq))
 		return true;
 
-	if (cfqd->serving_type == SYNC_NOIDLE_WORKLOAD
-	    && new_cfqq->service_tree == cfqq->service_tree)
+	if (cfqd->serving_type == SYNC_NOIDLE_WORKLOAD &&
+	    cfqq_type(new_cfqq) == SYNC_NOIDLE_WORKLOAD &&
+	    new_cfqq->service_tree->count == 1)
 		return true;
 
 	/*
Signature · 1 line
1.6.2.5
Acked-by on v1 2/4
#1 lore raw
Quoted 20 lines · Corrado Zoccolo

An incoming no-idle queue should preempt the active no-idle queue only if the active queue is idling due to service tree empty. Previous code was buggy in two ways:
* it relied on service_tree field to be set on the active queue, while it is not set when the code is idling for a new request
* it didn't check for the service tree empty condition, so could lead to LIFO behaviour if multiple queues with depth > 1 were preempting each other on an non-NCQ device.

---
 block/cfq-iosched.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
block/cfq-iosched.c +0 -0
index 6925ab9..2a304f4 100644

block/cfq-iosched.c cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq, · line 2408

Quoted 10 lines
block/cfq-iosched.c +3 -2
@@ -2401,8 +2401,9 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
 	if (cfq_class_idle(cfqq))
 		return true;
 
-	if (cfqd->serving_type == SYNC_NOIDLE_WORKLOAD
-	    && new_cfqq->service_tree == cfqq->service_tree)
+	if (cfqd->serving_type == SYNC_NOIDLE_WORKLOAD &&
+	    cfqq_type(new_cfqq) == SYNC_NOIDLE_WORKLOAD &&
+	    new_cfqq->service_tree->count == 1)
 		return true;
 

Looks good to me.

Thanks
Vivek