summaryrefslogtreecommitdiff
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2006-12-10 02:20:29 -0800
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-10 09:55:43 -0800
commit08c183f31bdbb709f177f6d3110d5f288ea33933 (patch)
treebe7b84c07f3b0bf29473bad2b7b788fa189f948e /kernel/sched.c
parent1bd77f2da58e9cdd1f159217887343dadd9af417 (diff)
[PATCH] sched: add option to serialize load balancing
Large sched domains can be very expensive to scan. Add an option SD_SERIALIZE to the sched domain flags. If that flag is set then we make sure that no other such domain is being balanced. [akpm@osdl.org: build fix] Signed-off-by: Christoph Lameter <clameter@sgi.com> Cc: Peter Williams <pwil3058@bigpond.net.au> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Christoph Lameter <clameter@sgi.com> Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com> Cc: "Chen, Kenneth W" <kenneth.w.chen@intel.com> Acked-by: Ingo Molnar <mingo@elte.hu> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 0a4a26b21f69..2b2b780939c9 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2880,6 +2880,7 @@ static void update_load(struct rq *this_rq)
*
* Balancing parameters are set up in arch_init_sched_domains.
*/
+static DEFINE_SPINLOCK(balancing);
static void run_rebalance_domains(struct softirq_action *h)
{
@@ -2909,6 +2910,11 @@ static void run_rebalance_domains(struct softirq_action *h)
if (unlikely(!interval))
interval = 1;
+ if (sd->flags & SD_SERIALIZE) {
+ if (!spin_trylock(&balancing))
+ goto out;
+ }
+
if (time_after_eq(jiffies, sd->last_balance + interval)) {
if (load_balance(this_cpu, this_rq, sd, idle)) {
/*
@@ -2920,6 +2926,9 @@ static void run_rebalance_domains(struct softirq_action *h)
}
sd->last_balance = jiffies;
}
+ if (sd->flags & SD_SERIALIZE)
+ spin_unlock(&balancing);
+out:
if (time_after(next_balance, sd->last_balance + interval))
next_balance = sd->last_balance + interval;
}