aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorCon Kolivas <kernel@kolivas.org>2005-01-07 21:46:13 -0800
committerLinus Torvalds <torvalds@evo.osdl.org>2005-01-07 21:46:13 -0800
commit482288d8785689476c947b9c65e642c540ca2e4f (patch)
tree6b064cbbef8027cf6656fcc89f0005fbf9141bde /kernel
parentb53c4efb5fe348108f4d3aa7ef9c5e72d0287b26 (diff)
downloadhistory-482288d8785689476c947b9c65e642c540ca2e4f.tar.gz
[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: Con Kolivas <kernel@kolivas.org> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 2efcc7c5b1fbd1..225193a8a4713e 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -600,6 +600,15 @@ static void enqueue_task(struct task_struct *p, prio_array_t *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
* remote queue so we want these tasks to show up at the head of the
* local queue:
@@ -2348,8 +2357,7 @@ void scheduler_tick(int user_ticks, int sys_ticks)
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;
}
@@ -3441,8 +3449,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