Commit 8e550632 authored by Corrado Zoccolo's avatar Corrado Zoccolo Committed by Jens Axboe

cfq-iosched: fix corner cases in idling logic

Idling logic was disabled in some corner cases, leading to unfair share
 for noidle queues.
 * the idle timer was not armed if there were other requests in the
   driver. unfortunately, those requests could come from other workloads,
   or queues for which we don't enable idling. So we will check only
   pending requests from the active queue
 * rq_noidle check on no-idle queue could disable the end of tree idle if
   the last completed request was rq_noidle. Now, we will disable that
   idle only if all the queues served in the no-idle tree had rq_noidle
   requests.
Reported-by: default avatarVivek Goyal <vgoyal@redhat.com>
Signed-off-by: default avatarCorrado Zoccolo <czoccolo@gmail.com>
Acked-by: default avatarVivek Goyal <vgoyal@redhat.com>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 76280aff
...@@ -172,6 +172,7 @@ struct cfq_data { ...@@ -172,6 +172,7 @@ struct cfq_data {
enum wl_prio_t serving_prio; enum wl_prio_t serving_prio;
enum wl_type_t serving_type; enum wl_type_t serving_type;
unsigned long workload_expires; unsigned long workload_expires;
bool noidle_tree_requires_idle;
/* /*
* Each priority tree is sorted by next_request position. These * Each priority tree is sorted by next_request position. These
...@@ -1253,9 +1254,9 @@ static void cfq_arm_slice_timer(struct cfq_data *cfqd) ...@@ -1253,9 +1254,9 @@ static void cfq_arm_slice_timer(struct cfq_data *cfqd)
return; return;
/* /*
* still requests with the driver, don't idle * still active requests from this queue, don't idle
*/ */
if (rq_in_driver(cfqd)) if (cfqq->dispatched)
return; return;
/* /*
...@@ -1478,6 +1479,7 @@ static void choose_service_tree(struct cfq_data *cfqd) ...@@ -1478,6 +1479,7 @@ static void choose_service_tree(struct cfq_data *cfqd)
slice = max_t(unsigned, slice, CFQ_MIN_TT); slice = max_t(unsigned, slice, CFQ_MIN_TT);
cfqd->workload_expires = jiffies + slice; cfqd->workload_expires = jiffies + slice;
cfqd->noidle_tree_requires_idle = false;
} }
/* /*
...@@ -2597,17 +2599,27 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq) ...@@ -2597,17 +2599,27 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
cfq_clear_cfqq_slice_new(cfqq); cfq_clear_cfqq_slice_new(cfqq);
} }
/* /*
* If there are no requests waiting in this queue, and * Idling is not enabled on:
* there are other queues ready to issue requests, AND * - expired queues
* those other queues are issuing requests within our * - idle-priority queues
* mean seek distance, give them a chance to run instead * - async queues
* of idling. * - queues with still some requests queued
* - when there is a close cooperator
*/ */
if (cfq_slice_used(cfqq) || cfq_class_idle(cfqq)) if (cfq_slice_used(cfqq) || cfq_class_idle(cfqq))
cfq_slice_expired(cfqd, 1); cfq_slice_expired(cfqd, 1);
else if (cfqq_empty && !cfq_close_cooperator(cfqd, cfqq) && else if (sync && cfqq_empty &&
sync && !rq_noidle(rq)) !cfq_close_cooperator(cfqd, cfqq)) {
cfq_arm_slice_timer(cfqd); cfqd->noidle_tree_requires_idle |= !rq_noidle(rq);
/*
* Idling is enabled for SYNC_WORKLOAD.
* SYNC_NOIDLE_WORKLOAD idles at the end of the tree
* only if we processed at least one !rq_noidle request
*/
if (cfqd->serving_type == SYNC_WORKLOAD
|| cfqd->noidle_tree_requires_idle)
cfq_arm_slice_timer(cfqd);
}
} }
if (!rq_in_driver(cfqd)) if (!rq_in_driver(cfqd))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment