Commit 482288d8 authored by Con Kolivas's avatar Con Kolivas Committed by Linus Torvalds

[PATCH] sched: add_requeue_task

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.

This will be hit frequently by upcoming changes to the requeueing in
timeslice granularity.
Signed-off-by: default avatarCon Kolivas <kernel@kolivas.org>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b53c4efb
...@@ -599,6 +599,15 @@ static void enqueue_task(struct task_struct *p, prio_array_t *array) ...@@ -599,6 +599,15 @@ static void enqueue_task(struct task_struct *p, prio_array_t *array)
p->array = array; p->array = array;
} }
/*
* 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_move_tail(&p->run_list, array->queue + p->prio);
}
/* /*
* Used by the migration code - we pull tasks from the head of the * 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 * remote queue so we want these tasks to show up at the head of the
...@@ -2348,8 +2357,7 @@ void scheduler_tick(int user_ticks, int sys_ticks) ...@@ -2348,8 +2357,7 @@ void scheduler_tick(int user_ticks, int sys_ticks)
set_tsk_need_resched(p); set_tsk_need_resched(p);
/* put it at the end of the queue: */ /* put it at the end of the queue: */
dequeue_task(p, rq->active); requeue_task(p, rq->active);
enqueue_task(p, rq->active);
} }
goto out_unlock; goto out_unlock;
} }
...@@ -3441,8 +3449,14 @@ asmlinkage long sys_sched_yield(void) ...@@ -3441,8 +3449,14 @@ asmlinkage long sys_sched_yield(void)
} else if (!rq->expired->nr_active) } else if (!rq->expired->nr_active)
schedstat_inc(rq, yld_exp_empty); schedstat_inc(rq, yld_exp_empty);
if (array != target) {
dequeue_task(current, array); dequeue_task(current, array);
enqueue_task(current, target); 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 * Since we are going to call schedule() anyway, there's
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment