lkml.org 
[lkml]   [2004]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH] add requeue task redo
    add requeue task redo


    We can requeue tasks for cheaper then doing a complete dequeue followed by
    an enqueue. Add the requeue_task function and perform it where possible.

    Signed-off-by: Con Kolivas <kernel@kolivas.org>

    Index: linux-2.6.10-rc1-mm2/kernel/sched.c
    ===================================================================
    --- linux-2.6.10-rc1-mm2.orig/kernel/sched.c 2004-11-03 00:54:33.157137840 +1100
    +++ linux-2.6.10-rc1-mm2/kernel/sched.c 2004-11-03 00:55:48.638171430 +1100
    @@ -579,6 +579,16 @@ static void enqueue_task(struct task_str
    }

    /*
    + * Put task to the end of the run list without the overhead of dequeue
    + * followed by enqueue.
    + */
    +static void requeue_task(struct task_struct *p, prio_array_t *array)
    +{
    + list_del(&p->run_list);
    + list_add_tail(&p->run_list, array->queue + p->prio);
    +}
    +
    +/*
    * Used by the migration code - we pull tasks from the head of the
    * remote queue so we want these tasks to show up at the head of the
    * local queue:
    @@ -2425,8 +2435,7 @@ void scheduler_tick(void)
    set_tsk_need_resched(p);

    /* put it at the end of the queue: */
    - dequeue_task(p, rq->active);
    - enqueue_task(p, rq->active);
    + requeue_task(p, rq->active);
    }
    goto out_unlock;
    }
    @@ -3569,8 +3578,14 @@ asmlinkage long sys_sched_yield(void)
    } else if (!rq->expired->nr_active)
    schedstat_inc(rq, yld_exp_empty);

    - dequeue_task(current, array);
    - enqueue_task(current, target);
    + if (array != target) {
    + dequeue_task(current, array);
    + enqueue_task(current, target);
    + } else
    + /*
    + * requeue_task is cheaper so perform that if possible.
    + */
    + requeue_task(current, array);

    /*
    * Since we are going to call schedule() anyway, there's
    [unhandled content-type:application/pgp-signature]
    \
     
     \ /
      Last update: 2005-03-22 14:07    [W:0.023 / U:0.152 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site