Skip to content

Commit

Permalink
cfq-iosched: delay async IO dispatch, if sync IO was just done
Browse files Browse the repository at this point in the history
o Do not allow more than max_dispatch requests from an async queue, if some
  sync request has finished recently. This is in the hope that sync activity
  is still going on in the system and we might receive a sync request soon.
  Most likely from a sync queue which finished a request and we did not enable
  idling on it.

Signed-off-by: Vivek Goyal <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
rhvgoyal authored and Jens Axboe committed Oct 3, 2009
1 parent 1d22351 commit 365722b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ struct cfq_data {
* Fallback dummy cfqq for extreme OOM conditions
*/
struct cfq_queue oom_cfqq;

unsigned long last_end_sync_rq;
};

enum cfqq_state_flags {
Expand Down Expand Up @@ -1314,6 +1316,8 @@ static int cfq_dispatch_requests(struct request_queue *q, int force)
* Does this cfqq already have too much IO in flight?
*/
if (cfqq->dispatched >= max_dispatch) {
unsigned long load_at = cfqd->last_end_sync_rq + cfq_slice_sync;

/*
* idle queue must always only have a single IO in flight
*/
Expand All @@ -1326,6 +1330,14 @@ static int cfq_dispatch_requests(struct request_queue *q, int force)
if (cfqd->busy_queues > 1)
return 0;

/*
* If a sync request has completed recently, don't overload
* the dispatch queue yet with async requests.
*/
if (cfqd->cfq_desktop && !cfq_cfqq_sync(cfqq)
&& time_before(jiffies, load_at))
return 0;

/*
* we are the only queue, allow up to 4 times of 'quantum'
*/
Expand Down Expand Up @@ -2158,8 +2170,10 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
if (cfq_cfqq_sync(cfqq))
cfqd->sync_flight--;

if (sync)
if (sync) {
RQ_CIC(rq)->last_end_request = now;
cfqd->last_end_sync_rq = now;
}

/*
* If this is the active queue, check if it needs to be expired,
Expand Down Expand Up @@ -2483,7 +2497,7 @@ static void *cfq_init_queue(struct request_queue *q)
cfqd->cfq_slice_idle = cfq_slice_idle;
cfqd->cfq_desktop = 1;
cfqd->hw_tag = 1;

cfqd->last_end_sync_rq = jiffies;
return cfqd;
}

Expand Down

0 comments on commit 365722b

Please sign in to comment.