aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-03-04 19:27:02 -0500
committerIngo Molnar <mingo@elte.hu>2009-03-05 08:04:44 -0500
commit8a0be9ef8225638d26b455788f988c8f84ce9e75 (patch)
tree7c4468532d09c405bd884f9f6ff2207619764355 /kernel
parent49d2d266adff27793fed247a2e9e672d59b6ddc6 (diff)
sched: don't rebalance if attached on NULL domain
Impact: fix function graph trace hang / drop pointless softirq on UP While debugging a function graph trace hang on an old PII, I saw that it consumed most of its time on the timer interrupt. And the domain rebalancing softirq was the most concerned. The timer interrupt calls trigger_load_balance() which will decide if it is worth to schedule a rebalancing softirq. In case of builtin UP kernel, no problem arises because there is no domain question. In case of builtin SMP kernel running on an SMP box, still no problem, the softirq will be raised each time we reach the next_balance time. In case of builtin SMP kernel running on a UP box (most distros provide default SMP kernels, whatever the box you have), then the CPU is attached to the NULL sched domain. So a kind of unexpected behaviour happen: trigger_load_balance() -> raises the rebalancing softirq later on softirq: run_rebalance_domains() -> rebalance_domains() where the for_each_domain(cpu, sd) is not taken because of the NULL domain we are attached at. Which means rq->next_balance is never updated. So on the next timer tick, we will enter trigger_load_balance() which will always reschedule() the rebalacing softirq: if (time_after_eq(jiffies, rq->next_balance)) raise_softirq(SCHED_SOFTIRQ); So for each tick, we process this pointless softirq. This patch fixes it by checking if we are attached to the null domain before raising the softirq, another possible fix would be to set the maximal possible JIFFIES value to rq->next_balance if we are attached to the NULL domain. v2: build fix on UP Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Peter Zijlstra <peterz@infradead.org> LKML-Reference: <49af242d.1c07d00a.32d5.ffffc019@mx.google.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index dfae1bf6d5b2..e509dbd7d77f 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4148,6 +4148,11 @@ static void run_rebalance_domains(struct softirq_action *h)
4148#endif 4148#endif
4149} 4149}
4150 4150
4151static inline int on_null_domain(int cpu)
4152{
4153 return !rcu_dereference(cpu_rq(cpu)->sd);
4154}
4155
4151/* 4156/*
4152 * Trigger the SCHED_SOFTIRQ if it is time to do periodic load balancing. 4157 * Trigger the SCHED_SOFTIRQ if it is time to do periodic load balancing.
4153 * 4158 *
@@ -4205,7 +4210,9 @@ static inline void trigger_load_balance(struct rq *rq, int cpu)
4205 cpumask_test_cpu(cpu, nohz.cpu_mask)) 4210 cpumask_test_cpu(cpu, nohz.cpu_mask))
4206 return; 4211 return;
4207#endif 4212#endif
4208 if (time_after_eq(jiffies, rq->next_balance)) 4213 /* Don't need to rebalance while attached to NULL domain */
4214 if (time_after_eq(jiffies, rq->next_balance) &&
4215 likely(!on_null_domain(cpu)))
4209 raise_softirq(SCHED_SOFTIRQ); 4216 raise_softirq(SCHED_SOFTIRQ);
4210} 4217}
4211 4218