public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH, minor] sched: check for SD_SERIALIZE atomically in rebalance_domains()
@ 2008-05-05 21:46 Dmitry Adamushko
  2008-05-06 12:36 ` Ingo Molnar
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Adamushko @ 2008-05-05 21:46 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, dmitry.adamushko



Nothing really serious here, mainly just a matter of nit-picking :-/


From: Dmitry Adamushko <dmitry.adamushko@gmail.com>
Subject: sched: check for SD_SERIALIZE atomically in rebalance_domains()
    
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>

---

diff --git a/kernel/sched.c b/kernel/sched.c
index 4a378bc..e106e61 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4153,6 +4153,7 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle)
 	/* Earliest time when we have to do rebalance again */
 	unsigned long next_balance = jiffies + 60*HZ;
 	int update_next_balance = 0;
+	int need_serialize;
 	cpumask_t tmp;
 
 	for_each_domain(cpu, sd) {
@@ -4170,8 +4171,9 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle)
 		if (interval > HZ*NR_CPUS/10)
 			interval = HZ*NR_CPUS/10;
 
+		need_serialize = sd->flags & SD_SERIALIZE;
 
-		if (sd->flags & SD_SERIALIZE) {
+		if (need_serialize) {
 			if (!spin_trylock(&balancing))
 				goto out;
 		}
@@ -4187,7 +4189,7 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle)
 			}
 			sd->last_balance = jiffies;
 		}
-		if (sd->flags & SD_SERIALIZE)
+		if (need_serialize)
 			spin_unlock(&balancing);
 out:
 		if (time_after(next_balance, sd->last_balance + interval)) {



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH, minor] sched: check for SD_SERIALIZE atomically in rebalance_domains()
  2008-05-05 21:46 [PATCH, minor] sched: check for SD_SERIALIZE atomically in rebalance_domains() Dmitry Adamushko
@ 2008-05-06 12:36 ` Ingo Molnar
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2008-05-06 12:36 UTC (permalink / raw)
  To: Dmitry Adamushko; +Cc: LKML, Peter Zijlstra


* Dmitry Adamushko <dmitry.adamushko@gmail.com> wrote:

> 
> Nothing really serious here, mainly just a matter of nit-picking :-/
> 
> 
> From: Dmitry Adamushko <dmitry.adamushko@gmail.com>
> Subject: sched: check for SD_SERIALIZE atomically in rebalance_domains()
>     
> 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.

applied, thanks Dmitry.

	Ingo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-05-06 12:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-05 21:46 [PATCH, minor] sched: check for SD_SERIALIZE atomically in rebalance_domains() Dmitry Adamushko
2008-05-06 12:36 ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox