Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1e3335de05da3dfbe48b8caa03db1834a2133256
Commit:     1e3335de05da3dfbe48b8caa03db1834a2133256
Parent:     b9099ff63c75216d6ca10bce5a1abcd9293c27e6
Author:     Jens Axboe <[EMAIL PROTECTED]>
AuthorDate: Wed Feb 14 19:59:49 2007 +0100
Committer:  Jens Axboe <[EMAIL PROTECTED]>
CommitDate: Mon Apr 30 09:01:21 2007 +0200

    cfq-iosched: improve preemption for cooperating tasks
    
    When testing the syslet async io approach, I discovered that CFQ
    sometimes didn't perform as well as expected. cfq_should_preempt()
    needs to better check for cooperating tasks, so fix that by allowing
    preemption of an equal priority queue if the recently queued request
    is as good a candidate for IO as the one we are currently waiting for.
    
    Signed-off-by: Jens Axboe <[EMAIL PROTECTED]>
---
 block/cfq-iosched.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index f92ba2a..bfb3967 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -867,15 +867,11 @@ static int cfq_arm_slice_timer(struct cfq_data *cfqd)
 
 static void cfq_dispatch_insert(request_queue_t *q, struct request *rq)
 {
-       struct cfq_data *cfqd = q->elevator->elevator_data;
        struct cfq_queue *cfqq = RQ_CFQQ(rq);
 
        cfq_remove_request(rq);
        cfqq->on_dispatch[rq_is_sync(rq)]++;
        elv_dispatch_sort(q, rq);
-
-       rq = list_entry(q->queue_head.prev, struct request, queuelist);
-       cfqd->last_sector = rq->sector + rq->nr_sectors;
 }
 
 /*
@@ -1585,6 +1581,7 @@ cfq_should_preempt(struct cfq_data *cfqd, struct 
cfq_queue *new_cfqq,
                   struct request *rq)
 {
        struct cfq_queue *cfqq = cfqd->active_queue;
+       sector_t dist;
 
        if (cfq_class_idle(new_cfqq))
                return 0;
@@ -1594,14 +1591,14 @@ cfq_should_preempt(struct cfq_data *cfqd, struct 
cfq_queue *new_cfqq,
 
        if (cfq_class_idle(cfqq))
                return 1;
-       if (!cfq_cfqq_wait_request(new_cfqq))
-               return 0;
+
        /*
         * if the new request is sync, but the currently running queue is
         * not, let the sync request have priority.
         */
        if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq))
                return 1;
+
        /*
         * So both queues are sync. Let the new request get disk time if
         * it's a metadata request and the current queue is doing regular IO.
@@ -1609,6 +1606,21 @@ cfq_should_preempt(struct cfq_data *cfqd, struct 
cfq_queue *new_cfqq,
        if (rq_is_meta(rq) && !cfqq->meta_pending)
                return 1;
 
+       if (!cfqd->active_cic || !cfq_cfqq_wait_request(cfqq))
+               return 0;
+
+       /*
+        * if this request is as-good as one we would expect from the
+        * current cfqq, let it preempt
+        */
+       if (rq->sector > cfqd->last_sector)
+               dist = rq->sector - cfqd->last_sector;
+       else
+               dist = cfqd->last_sector - rq->sector;
+
+       if (dist <= cfqd->active_cic->seek_mean)
+               return 1;
+
        return 0;
 }
 
@@ -1719,6 +1731,8 @@ static void cfq_completed_request(request_queue_t *q, 
struct request *rq)
        cfqq->on_dispatch[sync]--;
        cfqq->service_last = now;
 
+       cfqd->last_sector = rq->hard_sector + rq->hard_nr_sectors;
+
        if (!cfq_class_idle(cfqq))
                cfqd->last_end_request = now;
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to