Skip to content

Commit

Permalink
cfq-iosched: Fix the incorrect timeslice accounting with forced_dispatch
Browse files Browse the repository at this point in the history
When CFQ dispatches requests forcefully due to a barrier or changing iosched,
it runs through all cfqq's dispatching requests and then expires each queue.
However, it does not activate a cfqq before flushing its IOs resulting in
using stale values for computing slice_used.
This patch fixes it by calling activate queue before flushing reuqests from
each queue.

This is useful mostly for barrier requests because when the iosched is changing
it really doesnt matter if we have incorrect accounting since we're going to
break down all structures anyway.

We also now expire the current timeslice before moving on with the dispatch
to accurately account slice used for that cfqq.

Signed-off-by: Divyesh Shah<dpshah@google.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
Divyesh Shah authored and Jens Axboe committed Apr 9, 2010
1 parent 02246c4 commit 3440c49
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -2205,10 +2205,13 @@ static int cfq_forced_dispatch(struct cfq_data *cfqd)
struct cfq_queue *cfqq;
int dispatched = 0;

while ((cfqq = cfq_get_next_queue_forced(cfqd)) != NULL)
/* Expire the timeslice of the current active queue first */
cfq_slice_expired(cfqd, 0);
while ((cfqq = cfq_get_next_queue_forced(cfqd)) != NULL) {
__cfq_set_active_queue(cfqd, cfqq);
dispatched += __cfq_forced_dispatch_cfqq(cfqq);
}

cfq_slice_expired(cfqd, 0);
BUG_ON(cfqd->busy_queues);

cfq_log(cfqd, "forced_dispatch=%d", dispatched);
Expand Down

0 comments on commit 3440c49

Please sign in to comment.