Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176497
b: refs/heads/master
c: 7667aa0
h: refs/heads/master
i:
  176495: c09d1da
v: v3
  • Loading branch information
Vivek Goyal authored and Jens Axboe committed Dec 9, 2009
1 parent f2c76ac commit 545d429
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c244bb50a9baa2ec47a458bbafb36b5e559ed5fa
refs/heads/master: 7667aa0630407bc07dc38dcc79d29cc0a65553c1
54 changes: 48 additions & 6 deletions trunk/block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -2141,8 +2141,22 @@ static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd)
/*
* The active queue has run out of time, expire it and select new.
*/
if (cfq_slice_used(cfqq) && !cfq_cfqq_must_dispatch(cfqq))
goto expire;
if (cfq_slice_used(cfqq) && !cfq_cfqq_must_dispatch(cfqq)) {
/*
* If slice had not expired at the completion of last request
* we might not have turned on wait_busy flag. Don't expire
* the queue yet. Allow the group to get backlogged.
*
* The very fact that we have used the slice, that means we
* have been idling all along on this queue and it should be
* ok to wait for this request to complete.
*/
if (cfqq->cfqg->nr_cfqq == 1 && cfqq->dispatched
&& cfq_should_idle(cfqd, cfqq))
goto keep_queue;
else
goto expire;
}

/*
* The active queue has requests and isn't expired, allow it to
Expand Down Expand Up @@ -3256,6 +3270,35 @@ static void cfq_update_hw_tag(struct cfq_data *cfqd)
cfqd->hw_tag = 0;
}

static bool cfq_should_wait_busy(struct cfq_data *cfqd, struct cfq_queue *cfqq)
{
struct cfq_io_context *cic = cfqd->active_cic;

/* If there are other queues in the group, don't wait */
if (cfqq->cfqg->nr_cfqq > 1)
return false;

if (cfq_slice_used(cfqq))
return true;

/* if slice left is less than think time, wait busy */
if (cic && sample_valid(cic->ttime_samples)
&& (cfqq->slice_end - jiffies < cic->ttime_mean))
return true;

/*
* If think times is less than a jiffy than ttime_mean=0 and above
* will not be true. It might happen that slice has not expired yet
* but will expire soon (4-5 ns) during select_queue(). To cover the
* case where think time is less than a jiffy, mark the queue wait
* busy if only 1 jiffy is left in the slice.
*/
if (cfqq->slice_end - jiffies == 1)
return true;

return false;
}

static void cfq_completed_request(struct request_queue *q, struct request *rq)
{
struct cfq_queue *cfqq = RQ_CFQQ(rq);
Expand Down Expand Up @@ -3295,11 +3338,10 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
}

/*
* If this queue consumed its slice and this is last queue
* in the group, wait for next request before we expire
* the queue
* Should we wait for next request to come in before we expire
* the queue.
*/
if (cfq_slice_used(cfqq) && cfqq->cfqg->nr_cfqq == 1) {
if (cfq_should_wait_busy(cfqd, cfqq)) {
cfqq->slice_end = jiffies + cfqd->cfq_slice_idle;
cfq_mark_cfqq_wait_busy(cfqq);
}
Expand Down

0 comments on commit 545d429

Please sign in to comment.