diff options
author | Christoph Lameter <clameter@sgi.com> | 2006-12-10 05:20:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-10 12:55:43 -0500 |
commit | 08c183f31bdbb709f177f6d3110d5f288ea33933 (patch) | |
tree | be7b84c07f3b0bf29473bad2b7b788fa189f948e | |
parent | 1bd77f2da58e9cdd1f159217887343dadd9af417 (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>
-rw-r--r-- | include/asm-i386/topology.h | 1 | ||||
-rw-r--r-- | include/asm-ia64/topology.h | 1 | ||||
-rw-r--r-- | include/asm-powerpc/topology.h | 1 | ||||
-rw-r--r-- | include/asm-x86_64/topology.h | 1 | ||||
-rw-r--r-- | include/linux/sched.h | 1 | ||||
-rw-r--r-- | include/linux/topology.h | 3 | ||||
-rw-r--r-- | kernel/sched.c | 9 |
7 files changed, 16 insertions, 1 deletions
diff --git a/include/asm-i386/topology.h b/include/asm-i386/topology.h index 978d09596130..ac58580ad664 100644 --- a/include/asm-i386/topology.h +++ b/include/asm-i386/topology.h | |||
@@ -89,6 +89,7 @@ static inline int node_to_first_cpu(int node) | |||
89 | .flags = SD_LOAD_BALANCE \ | 89 | .flags = SD_LOAD_BALANCE \ |
90 | | SD_BALANCE_EXEC \ | 90 | | SD_BALANCE_EXEC \ |
91 | | SD_BALANCE_FORK \ | 91 | | SD_BALANCE_FORK \ |
92 | | SD_SERIALIZE \ | ||
92 | | SD_WAKE_BALANCE, \ | 93 | | SD_WAKE_BALANCE, \ |
93 | .last_balance = jiffies, \ | 94 | .last_balance = jiffies, \ |
94 | .balance_interval = 1, \ | 95 | .balance_interval = 1, \ |
diff --git a/include/asm-ia64/topology.h b/include/asm-ia64/topology.h index a6e38565ab4c..22ed6749557e 100644 --- a/include/asm-ia64/topology.h +++ b/include/asm-ia64/topology.h | |||
@@ -101,6 +101,7 @@ void build_cpu_to_node_map(void); | |||
101 | .flags = SD_LOAD_BALANCE \ | 101 | .flags = SD_LOAD_BALANCE \ |
102 | | SD_BALANCE_EXEC \ | 102 | | SD_BALANCE_EXEC \ |
103 | | SD_BALANCE_FORK \ | 103 | | SD_BALANCE_FORK \ |
104 | | SD_SERIALIZE \ | ||
104 | | SD_WAKE_BALANCE, \ | 105 | | SD_WAKE_BALANCE, \ |
105 | .last_balance = jiffies, \ | 106 | .last_balance = jiffies, \ |
106 | .balance_interval = 64, \ | 107 | .balance_interval = 64, \ |
diff --git a/include/asm-powerpc/topology.h b/include/asm-powerpc/topology.h index 50c014007de7..6610495f5f16 100644 --- a/include/asm-powerpc/topology.h +++ b/include/asm-powerpc/topology.h | |||
@@ -66,6 +66,7 @@ static inline int pcibus_to_node(struct pci_bus *bus) | |||
66 | | SD_BALANCE_EXEC \ | 66 | | SD_BALANCE_EXEC \ |
67 | | SD_BALANCE_NEWIDLE \ | 67 | | SD_BALANCE_NEWIDLE \ |
68 | | SD_WAKE_IDLE \ | 68 | | SD_WAKE_IDLE \ |
69 | | SD_SERIALIZE \ | ||
69 | | SD_WAKE_BALANCE, \ | 70 | | SD_WAKE_BALANCE, \ |
70 | .last_balance = jiffies, \ | 71 | .last_balance = jiffies, \ |
71 | .balance_interval = 1, \ | 72 | .balance_interval = 1, \ |
diff --git a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h index 5c8f49280dbc..2facec5914d2 100644 --- a/include/asm-x86_64/topology.h +++ b/include/asm-x86_64/topology.h | |||
@@ -47,6 +47,7 @@ extern int __node_distance(int, int); | |||
47 | .flags = SD_LOAD_BALANCE \ | 47 | .flags = SD_LOAD_BALANCE \ |
48 | | SD_BALANCE_FORK \ | 48 | | SD_BALANCE_FORK \ |
49 | | SD_BALANCE_EXEC \ | 49 | | SD_BALANCE_EXEC \ |
50 | | SD_SERIALIZE \ | ||
50 | | SD_WAKE_BALANCE, \ | 51 | | SD_WAKE_BALANCE, \ |
51 | .last_balance = jiffies, \ | 52 | .last_balance = jiffies, \ |
52 | .balance_interval = 1, \ | 53 | .balance_interval = 1, \ |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 1208feab46e0..ea92e5c89089 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -648,6 +648,7 @@ enum idle_type | |||
648 | #define SD_SHARE_CPUPOWER 128 /* Domain members share cpu power */ | 648 | #define SD_SHARE_CPUPOWER 128 /* Domain members share cpu power */ |
649 | #define SD_POWERSAVINGS_BALANCE 256 /* Balance for power savings */ | 649 | #define SD_POWERSAVINGS_BALANCE 256 /* Balance for power savings */ |
650 | #define SD_SHARE_PKG_RESOURCES 512 /* Domain members share cpu pkg resources */ | 650 | #define SD_SHARE_PKG_RESOURCES 512 /* Domain members share cpu pkg resources */ |
651 | #define SD_SERIALIZE 1024 /* Only a single load balancing instance */ | ||
651 | 652 | ||
652 | #define BALANCE_FOR_MC_POWER \ | 653 | #define BALANCE_FOR_MC_POWER \ |
653 | (sched_smt_power_savings ? SD_POWERSAVINGS_BALANCE : 0) | 654 | (sched_smt_power_savings ? SD_POWERSAVINGS_BALANCE : 0) |
diff --git a/include/linux/topology.h b/include/linux/topology.h index b93bb6cc6cc2..6c5a6e6e813b 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h | |||
@@ -194,7 +194,8 @@ | |||
194 | .wake_idx = 0, /* unused */ \ | 194 | .wake_idx = 0, /* unused */ \ |
195 | .forkexec_idx = 0, /* unused */ \ | 195 | .forkexec_idx = 0, /* unused */ \ |
196 | .per_cpu_gain = 100, \ | 196 | .per_cpu_gain = 100, \ |
197 | .flags = SD_LOAD_BALANCE, \ | 197 | .flags = SD_LOAD_BALANCE \ |
198 | | SD_SERIALIZE, \ | ||
198 | .last_balance = jiffies, \ | 199 | .last_balance = jiffies, \ |
199 | .balance_interval = 64, \ | 200 | .balance_interval = 64, \ |
200 | .nr_balance_failed = 0, \ | 201 | .nr_balance_failed = 0, \ |
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) | |||
2880 | * | 2880 | * |
2881 | * Balancing parameters are set up in arch_init_sched_domains. | 2881 | * Balancing parameters are set up in arch_init_sched_domains. |
2882 | */ | 2882 | */ |
2883 | static DEFINE_SPINLOCK(balancing); | ||
2883 | 2884 | ||
2884 | static void run_rebalance_domains(struct softirq_action *h) | 2885 | static void run_rebalance_domains(struct softirq_action *h) |
2885 | { | 2886 | { |
@@ -2909,6 +2910,11 @@ static void run_rebalance_domains(struct softirq_action *h) | |||
2909 | if (unlikely(!interval)) | 2910 | if (unlikely(!interval)) |
2910 | interval = 1; | 2911 | interval = 1; |
2911 | 2912 | ||
2913 | if (sd->flags & SD_SERIALIZE) { | ||
2914 | if (!spin_trylock(&balancing)) | ||
2915 | goto out; | ||
2916 | } | ||
2917 | |||
2912 | if (time_after_eq(jiffies, sd->last_balance + interval)) { | 2918 | if (time_after_eq(jiffies, sd->last_balance + interval)) { |
2913 | if (load_balance(this_cpu, this_rq, sd, idle)) { | 2919 | if (load_balance(this_cpu, this_rq, sd, idle)) { |
2914 | /* | 2920 | /* |
@@ -2920,6 +2926,9 @@ static void run_rebalance_domains(struct softirq_action *h) | |||
2920 | } | 2926 | } |
2921 | sd->last_balance = jiffies; | 2927 | sd->last_balance = jiffies; |
2922 | } | 2928 | } |
2929 | if (sd->flags & SD_SERIALIZE) | ||
2930 | spin_unlock(&balancing); | ||
2931 | out: | ||
2923 | if (time_after(next_balance, sd->last_balance + interval)) | 2932 | if (time_after(next_balance, sd->last_balance + interval)) |
2924 | next_balance = sd->last_balance + interval; | 2933 | next_balance = sd->last_balance + interval; |
2925 | } | 2934 | } |