Commit 53c583d2 authored by Corrado Zoccolo's avatar Corrado Zoccolo Committed by Jens Axboe

cfq-iosched: requests "in flight" vs "in driver" clarification

Counters for requests "in flight" and "in driver" are used asymmetrically
in cfq_may_dispatch, and have slightly different meaning.
We split the rq_in_flight counter (was sync_flight) to count both sync
and async requests, in order to use this one, which is more accurate in
some corner cases.
The rq_in_driver counter is coalesced, since individual sync/async counts
are not used any more.
Signed-off-by: default avatarCorrado Zoccolo <czoccolo@gmail.com>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 87c3a922
...@@ -222,8 +222,8 @@ struct cfq_data { ...@@ -222,8 +222,8 @@ struct cfq_data {
unsigned int busy_queues; unsigned int busy_queues;
int rq_in_driver[2]; int rq_in_driver;
int sync_flight; int rq_in_flight[2];
/* /*
* queue-depth detection * queue-depth detection
...@@ -416,11 +416,6 @@ static struct cfq_queue *cfq_get_queue(struct cfq_data *, bool, ...@@ -416,11 +416,6 @@ static struct cfq_queue *cfq_get_queue(struct cfq_data *, bool,
static struct cfq_io_context *cfq_cic_lookup(struct cfq_data *, static struct cfq_io_context *cfq_cic_lookup(struct cfq_data *,
struct io_context *); struct io_context *);
static inline int rq_in_driver(struct cfq_data *cfqd)
{
return cfqd->rq_in_driver[0] + cfqd->rq_in_driver[1];
}
static inline struct cfq_queue *cic_to_cfqq(struct cfq_io_context *cic, static inline struct cfq_queue *cic_to_cfqq(struct cfq_io_context *cic,
bool is_sync) bool is_sync)
{ {
...@@ -1414,9 +1409,9 @@ static void cfq_activate_request(struct request_queue *q, struct request *rq) ...@@ -1414,9 +1409,9 @@ static void cfq_activate_request(struct request_queue *q, struct request *rq)
{ {
struct cfq_data *cfqd = q->elevator->elevator_data; struct cfq_data *cfqd = q->elevator->elevator_data;
cfqd->rq_in_driver[rq_is_sync(rq)]++; cfqd->rq_in_driver++;
cfq_log_cfqq(cfqd, RQ_CFQQ(rq), "activate rq, drv=%d", cfq_log_cfqq(cfqd, RQ_CFQQ(rq), "activate rq, drv=%d",
rq_in_driver(cfqd)); cfqd->rq_in_driver);
cfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq); cfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq);
} }
...@@ -1424,12 +1419,11 @@ static void cfq_activate_request(struct request_queue *q, struct request *rq) ...@@ -1424,12 +1419,11 @@ static void cfq_activate_request(struct request_queue *q, struct request *rq)
static void cfq_deactivate_request(struct request_queue *q, struct request *rq) static void cfq_deactivate_request(struct request_queue *q, struct request *rq)
{ {
struct cfq_data *cfqd = q->elevator->elevator_data; struct cfq_data *cfqd = q->elevator->elevator_data;
const int sync = rq_is_sync(rq);
WARN_ON(!cfqd->rq_in_driver[sync]); WARN_ON(!cfqd->rq_in_driver);
cfqd->rq_in_driver[sync]--; cfqd->rq_in_driver--;
cfq_log_cfqq(cfqd, RQ_CFQQ(rq), "deactivate rq, drv=%d", cfq_log_cfqq(cfqd, RQ_CFQQ(rq), "deactivate rq, drv=%d",
rq_in_driver(cfqd)); cfqd->rq_in_driver);
} }
static void cfq_remove_request(struct request *rq) static void cfq_remove_request(struct request *rq)
...@@ -1863,8 +1857,7 @@ static void cfq_dispatch_insert(struct request_queue *q, struct request *rq) ...@@ -1863,8 +1857,7 @@ static void cfq_dispatch_insert(struct request_queue *q, struct request *rq)
cfqq->dispatched++; cfqq->dispatched++;
elv_dispatch_sort(q, rq); elv_dispatch_sort(q, rq);
if (cfq_cfqq_sync(cfqq)) cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]++;
cfqd->sync_flight++;
cfqq->nr_sectors += blk_rq_sectors(rq); cfqq->nr_sectors += blk_rq_sectors(rq);
} }
...@@ -2211,13 +2204,13 @@ static bool cfq_may_dispatch(struct cfq_data *cfqd, struct cfq_queue *cfqq) ...@@ -2211,13 +2204,13 @@ static bool cfq_may_dispatch(struct cfq_data *cfqd, struct cfq_queue *cfqq)
/* /*
* Drain async requests before we start sync IO * Drain async requests before we start sync IO
*/ */
if (cfq_should_idle(cfqd, cfqq) && cfqd->rq_in_driver[BLK_RW_ASYNC]) if (cfq_should_idle(cfqd, cfqq) && cfqd->rq_in_flight[BLK_RW_ASYNC])
return false; return false;
/* /*
* If this is an async queue and we have sync IO in flight, let it wait * If this is an async queue and we have sync IO in flight, let it wait
*/ */
if (cfqd->sync_flight && !cfq_cfqq_sync(cfqq)) if (cfqd->rq_in_flight[BLK_RW_SYNC] && !cfq_cfqq_sync(cfqq))
return false; return false;
max_dispatch = cfqd->cfq_quantum; max_dispatch = cfqd->cfq_quantum;
...@@ -3189,14 +3182,14 @@ static void cfq_update_hw_tag(struct cfq_data *cfqd) ...@@ -3189,14 +3182,14 @@ static void cfq_update_hw_tag(struct cfq_data *cfqd)
{ {
struct cfq_queue *cfqq = cfqd->active_queue; struct cfq_queue *cfqq = cfqd->active_queue;
if (rq_in_driver(cfqd) > cfqd->hw_tag_est_depth) if (cfqd->rq_in_driver > cfqd->hw_tag_est_depth)
cfqd->hw_tag_est_depth = rq_in_driver(cfqd); cfqd->hw_tag_est_depth = cfqd->rq_in_driver;
if (cfqd->hw_tag == 1) if (cfqd->hw_tag == 1)
return; return;
if (cfqd->rq_queued <= CFQ_HW_QUEUE_MIN && if (cfqd->rq_queued <= CFQ_HW_QUEUE_MIN &&
rq_in_driver(cfqd) <= CFQ_HW_QUEUE_MIN) cfqd->rq_in_driver <= CFQ_HW_QUEUE_MIN)
return; return;
/* /*
...@@ -3206,7 +3199,7 @@ static void cfq_update_hw_tag(struct cfq_data *cfqd) ...@@ -3206,7 +3199,7 @@ static void cfq_update_hw_tag(struct cfq_data *cfqd)
*/ */
if (cfqq && cfq_cfqq_idle_window(cfqq) && if (cfqq && cfq_cfqq_idle_window(cfqq) &&
cfqq->dispatched + cfqq->queued[0] + cfqq->queued[1] < cfqq->dispatched + cfqq->queued[0] + cfqq->queued[1] <
CFQ_HW_QUEUE_MIN && rq_in_driver(cfqd) < CFQ_HW_QUEUE_MIN) CFQ_HW_QUEUE_MIN && cfqd->rq_in_driver < CFQ_HW_QUEUE_MIN)
return; return;
if (cfqd->hw_tag_samples++ < 50) if (cfqd->hw_tag_samples++ < 50)
...@@ -3259,13 +3252,12 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq) ...@@ -3259,13 +3252,12 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
cfq_update_hw_tag(cfqd); cfq_update_hw_tag(cfqd);
WARN_ON(!cfqd->rq_in_driver[sync]); WARN_ON(!cfqd->rq_in_driver);
WARN_ON(!cfqq->dispatched); WARN_ON(!cfqq->dispatched);
cfqd->rq_in_driver[sync]--; cfqd->rq_in_driver--;
cfqq->dispatched--; cfqq->dispatched--;
if (cfq_cfqq_sync(cfqq)) cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]--;
cfqd->sync_flight--;
if (sync) { if (sync) {
RQ_CIC(rq)->last_end_request = now; RQ_CIC(rq)->last_end_request = now;
...@@ -3319,7 +3311,7 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq) ...@@ -3319,7 +3311,7 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
} }
} }
if (!rq_in_driver(cfqd)) if (!cfqd->rq_in_driver)
cfq_schedule_dispatch(cfqd); cfq_schedule_dispatch(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