aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorDmitry Adamushko <dmitry.adamushko@gmail.com>2008-05-12 15:21:15 -0400
committerIngo Molnar <mingo@elte.hu>2008-06-06 09:19:30 -0400
commitd07355f5def74d060333563b36ab51b89fd44cdd (patch)
treee39af1fccaaa98b7ae4cc80628e8a8b69f73ebc1 /kernel/sched.c
parent6d299f1b53b84e2665f402d9bcc494800aba6386 (diff)
sched: check for SD_SERIALIZE atomically in rebalance_domains()
Nothing really serious here, mainly just a matter of nit-picking :-/ From: Dmitry Adamushko <dmitry.adamushko@gmail.com> For CONFIG_SCHED_DEBUG && CONFIG_SYSCT configs, sd->flags can be altered while being manipulated in rebalance_domains(). Let's do an atomic check. We rely here on the atomicity of read/write accesses for aligned words. Signed-off-by: Dmitry Adamushko <dmitry.adamushko@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 8a1257b65560..90329f1f8941 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3668,6 +3668,7 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle)
3668 /* Earliest time when we have to do rebalance again */ 3668 /* Earliest time when we have to do rebalance again */
3669 unsigned long next_balance = jiffies + 60*HZ; 3669 unsigned long next_balance = jiffies + 60*HZ;
3670 int update_next_balance = 0; 3670 int update_next_balance = 0;
3671 int need_serialize;
3671 cpumask_t tmp; 3672 cpumask_t tmp;
3672 3673
3673 for_each_domain(cpu, sd) { 3674 for_each_domain(cpu, sd) {
@@ -3685,8 +3686,9 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle)
3685 if (interval > HZ*NR_CPUS/10) 3686 if (interval > HZ*NR_CPUS/10)
3686 interval = HZ*NR_CPUS/10; 3687 interval = HZ*NR_CPUS/10;
3687 3688
3689 need_serialize = sd->flags & SD_SERIALIZE;
3688 3690
3689 if (sd->flags & SD_SERIALIZE) { 3691 if (need_serialize) {
3690 if (!spin_trylock(&balancing)) 3692 if (!spin_trylock(&balancing))
3691 goto out; 3693 goto out;
3692 } 3694 }
@@ -3702,7 +3704,7 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle)
3702 } 3704 }
3703 sd->last_balance = jiffies; 3705 sd->last_balance = jiffies;
3704 } 3706 }
3705 if (sd->flags & SD_SERIALIZE) 3707 if (need_serialize)
3706 spin_unlock(&balancing); 3708 spin_unlock(&balancing);
3707out: 3709out:
3708 if (time_after(next_balance, sd->last_balance + interval)) { 3710 if (time_after(next_balance, sd->last_balance + interval)) {