aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched_rt.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2008-01-25 15:08:12 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-25 15:08:12 -0500
commite1f47d891c0f00769d6d40ac5740f943e998d089 (patch)
treeccf402b5b5a8377af811afb288c39e2e136f1700 /kernel/sched_rt.c
parenta22d7fc187ed996b66d8439db27b2303f79a8e7b (diff)
sched: RT-balance, avoid overloading
This patch changes the searching for a run queue by a waking RT task to try to pick another runqueue if the currently running task is an RT task. The reason is that RT tasks behave different than normal tasks. Preempting a normal task to run a RT task to keep its cache hot is fine, because the preempted non-RT task may wait on that same runqueue to run again unless the migration thread comes along and pulls it off. RT tasks behave differently. If one is preempted, it makes an active effort to continue to run. So by having a high priority task preempt a lower priority RT task, that lower RT task will then quickly try to run on another runqueue. This will cause that lower RT task to replace its nice hot cache (and TLB) with a completely cold one. This is for the hope that the new high priority RT task will keep its cache hot. Remeber that this high priority RT task was just woken up. So it may likely have been sleeping for several milliseconds, and will end up with a cold cache anyway. RT tasks run till they voluntarily stop, or are preempted by a higher priority task. This means that it is unlikely that the woken RT task will have a hot cache to wake up to. So pushing off a lower RT task is just killing its cache for no good reason. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched_rt.c')
-rw-r--r--kernel/sched_rt.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 87d7b3ff3861..9becc3710b60 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -160,11 +160,23 @@ static int select_task_rq_rt(struct task_struct *p, int sync)
160 struct rq *rq = task_rq(p); 160 struct rq *rq = task_rq(p);
161 161
162 /* 162 /*
163 * If the task will not preempt the RQ, try to find a better RQ 163 * If the current task is an RT task, then
164 * before we even activate the task 164 * try to see if we can wake this RT task up on another
165 * runqueue. Otherwise simply start this RT task
166 * on its current runqueue.
167 *
168 * We want to avoid overloading runqueues. Even if
169 * the RT task is of higher priority than the current RT task.
170 * RT tasks behave differently than other tasks. If
171 * one gets preempted, we try to push it off to another queue.
172 * So trying to keep a preempting RT task on the same
173 * cache hot CPU will force the running RT task to
174 * a cold CPU. So we waste all the cache for the lower
175 * RT task in hopes of saving some of a RT task
176 * that is just being woken and probably will have
177 * cold cache anyway.
165 */ 178 */
166 if ((p->prio >= rq->rt.highest_prio) 179 if (unlikely(rt_task(rq->curr))) {
167 && (p->nr_cpus_allowed > 1)) {
168 int cpu = find_lowest_rq(p); 180 int cpu = find_lowest_rq(p);
169 181
170 return (cpu == -1) ? task_cpu(p) : cpu; 182 return (cpu == -1) ? task_cpu(p) : cpu;