diff options
author | Max Krasnyansky <maxk@qualcomm.com> | 2008-07-15 07:43:49 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-18 07:22:25 -0400 |
commit | e761b7725234276a802322549cee5255305a0930 (patch) | |
tree | 27b351a7d5fc9a93590e0effce1c5adb1bfcebc0 /include/linux | |
parent | 7ebefa8ceefed44cc321be70afc54a585a68ac0b (diff) |
cpu hotplug, sched: Introduce cpu_active_map and redo sched domain managment (take 2)
This is based on Linus' idea of creating cpu_active_map that prevents
scheduler load balancer from migrating tasks to the cpu that is going
down.
It allows us to simplify domain management code and avoid unecessary
domain rebuilds during cpu hotplug event handling.
Please ignore the cpusets part for now. It needs some more work in order
to avoid crazy lock nesting. Although I did simplfy and unify domain
reinitialization logic. We now simply call partition_sched_domains() in
all the cases. This means that we're using exact same code paths as in
cpusets case and hence the test below cover cpusets too.
Cpuset changes to make rebuild_sched_domains() callable from various
contexts are in the separate patch (right next after this one).
This not only boots but also easily handles
while true; do make clean; make -j 8; done
and
while true; do on-off-cpu 1; done
at the same time.
(on-off-cpu 1 simple does echo 0/1 > /sys/.../cpu1/online thing).
Suprisingly the box (dual-core Core2) is quite usable. In fact I'm typing
this on right now in gnome-terminal and things are moving just fine.
Also this is running with most of the debug features enabled (lockdep,
mutex, etc) no BUG_ONs or lockdep complaints so far.
I believe I addressed all of the Dmitry's comments for original Linus'
version. I changed both fair and rt balancer to mask out non-active cpus.
And replaced cpu_is_offline() with !cpu_active() in the main scheduler
code where it made sense (to me).
Signed-off-by: Max Krasnyanskiy <maxk@qualcomm.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Gregory Haskins <ghaskins@novell.com>
Cc: dmitry.adamushko@gmail.com
Cc: pj@sgi.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/cpumask.h | 6 | ||||
-rw-r--r-- | include/linux/cpuset.h | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index c24875bd9c5b..d614d2472798 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
@@ -359,13 +359,14 @@ static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp, | |||
359 | 359 | ||
360 | /* | 360 | /* |
361 | * The following particular system cpumasks and operations manage | 361 | * The following particular system cpumasks and operations manage |
362 | * possible, present and online cpus. Each of them is a fixed size | 362 | * possible, present, active and online cpus. Each of them is a fixed size |
363 | * bitmap of size NR_CPUS. | 363 | * bitmap of size NR_CPUS. |
364 | * | 364 | * |
365 | * #ifdef CONFIG_HOTPLUG_CPU | 365 | * #ifdef CONFIG_HOTPLUG_CPU |
366 | * cpu_possible_map - has bit 'cpu' set iff cpu is populatable | 366 | * cpu_possible_map - has bit 'cpu' set iff cpu is populatable |
367 | * cpu_present_map - has bit 'cpu' set iff cpu is populated | 367 | * cpu_present_map - has bit 'cpu' set iff cpu is populated |
368 | * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler | 368 | * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler |
369 | * cpu_active_map - has bit 'cpu' set iff cpu available to migration | ||
369 | * #else | 370 | * #else |
370 | * cpu_possible_map - has bit 'cpu' set iff cpu is populated | 371 | * cpu_possible_map - has bit 'cpu' set iff cpu is populated |
371 | * cpu_present_map - copy of cpu_possible_map | 372 | * cpu_present_map - copy of cpu_possible_map |
@@ -416,6 +417,7 @@ static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp, | |||
416 | extern cpumask_t cpu_possible_map; | 417 | extern cpumask_t cpu_possible_map; |
417 | extern cpumask_t cpu_online_map; | 418 | extern cpumask_t cpu_online_map; |
418 | extern cpumask_t cpu_present_map; | 419 | extern cpumask_t cpu_present_map; |
420 | extern cpumask_t cpu_active_map; | ||
419 | 421 | ||
420 | #if NR_CPUS > 1 | 422 | #if NR_CPUS > 1 |
421 | #define num_online_cpus() cpus_weight(cpu_online_map) | 423 | #define num_online_cpus() cpus_weight(cpu_online_map) |
@@ -424,6 +426,7 @@ extern cpumask_t cpu_present_map; | |||
424 | #define cpu_online(cpu) cpu_isset((cpu), cpu_online_map) | 426 | #define cpu_online(cpu) cpu_isset((cpu), cpu_online_map) |
425 | #define cpu_possible(cpu) cpu_isset((cpu), cpu_possible_map) | 427 | #define cpu_possible(cpu) cpu_isset((cpu), cpu_possible_map) |
426 | #define cpu_present(cpu) cpu_isset((cpu), cpu_present_map) | 428 | #define cpu_present(cpu) cpu_isset((cpu), cpu_present_map) |
429 | #define cpu_active(cpu) cpu_isset((cpu), cpu_active_map) | ||
427 | #else | 430 | #else |
428 | #define num_online_cpus() 1 | 431 | #define num_online_cpus() 1 |
429 | #define num_possible_cpus() 1 | 432 | #define num_possible_cpus() 1 |
@@ -431,6 +434,7 @@ extern cpumask_t cpu_present_map; | |||
431 | #define cpu_online(cpu) ((cpu) == 0) | 434 | #define cpu_online(cpu) ((cpu) == 0) |
432 | #define cpu_possible(cpu) ((cpu) == 0) | 435 | #define cpu_possible(cpu) ((cpu) == 0) |
433 | #define cpu_present(cpu) ((cpu) == 0) | 436 | #define cpu_present(cpu) ((cpu) == 0) |
437 | #define cpu_active(cpu) ((cpu) == 0) | ||
434 | #endif | 438 | #endif |
435 | 439 | ||
436 | #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) | 440 | #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) |
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index 038578362b47..e8f450c499b0 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h | |||
@@ -78,6 +78,8 @@ extern void cpuset_track_online_nodes(void); | |||
78 | 78 | ||
79 | extern int current_cpuset_is_being_rebound(void); | 79 | extern int current_cpuset_is_being_rebound(void); |
80 | 80 | ||
81 | extern void rebuild_sched_domains(void); | ||
82 | |||
81 | #else /* !CONFIG_CPUSETS */ | 83 | #else /* !CONFIG_CPUSETS */ |
82 | 84 | ||
83 | static inline int cpuset_init_early(void) { return 0; } | 85 | static inline int cpuset_init_early(void) { return 0; } |
@@ -156,6 +158,11 @@ static inline int current_cpuset_is_being_rebound(void) | |||
156 | return 0; | 158 | return 0; |
157 | } | 159 | } |
158 | 160 | ||
161 | static inline void rebuild_sched_domains(void) | ||
162 | { | ||
163 | partition_sched_domains(0, NULL, NULL); | ||
164 | } | ||
165 | |||
159 | #endif /* !CONFIG_CPUSETS */ | 166 | #endif /* !CONFIG_CPUSETS */ |
160 | 167 | ||
161 | #endif /* _LINUX_CPUSET_H */ | 168 | #endif /* _LINUX_CPUSET_H */ |