diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2011-04-05 04:14:25 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-04-05 04:29:36 -0400 |
commit | 49c022e657fbe661460d191fbe776a387132e2b3 (patch) | |
tree | 487b713816a5ff3d81437aeecf111ffa414f6ede /kernel/sched_fair.c | |
parent | b2a8b4b81966094703088a7bc76a313af841924d (diff) |
sched: Clean up rebalance_domains() load-balance interval calculation
Instead of the possible multiple-evaluation of num_online_cpus()
in rebalance_domains() that Linus reported, avoid it altogether
in the normal case since it's implemented with a Hamming weight
function over a cpu bitmask which can be darn expensive for those
with big iron.
This also makes it cleaner, smaller and documents the code.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1301991265.2225.12.camel@twins>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched_fair.c')
-rw-r--r-- | kernel/sched_fair.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index c7ec5c8e7b44..80ecd09452e0 100644 --- a/kernel/sched_fair.c +++ b/kernel/sched_fair.c | |||
@@ -3820,6 +3820,17 @@ void select_nohz_load_balancer(int stop_tick) | |||
3820 | 3820 | ||
3821 | static DEFINE_SPINLOCK(balancing); | 3821 | static DEFINE_SPINLOCK(balancing); |
3822 | 3822 | ||
3823 | static unsigned long __read_mostly max_load_balance_interval = HZ/10; | ||
3824 | |||
3825 | /* | ||
3826 | * Scale the max load_balance interval with the number of CPUs in the system. | ||
3827 | * This trades load-balance latency on larger machines for less cross talk. | ||
3828 | */ | ||
3829 | static void update_max_interval(void) | ||
3830 | { | ||
3831 | max_load_balance_interval = HZ*num_online_cpus()/10; | ||
3832 | } | ||
3833 | |||
3823 | /* | 3834 | /* |
3824 | * It checks each scheduling domain to see if it is due to be balanced, | 3835 | * It checks each scheduling domain to see if it is due to be balanced, |
3825 | * and initiates a balancing operation if so. | 3836 | * and initiates a balancing operation if so. |
@@ -3849,10 +3860,7 @@ static void rebalance_domains(int cpu, enum cpu_idle_type idle) | |||
3849 | 3860 | ||
3850 | /* scale ms to jiffies */ | 3861 | /* scale ms to jiffies */ |
3851 | interval = msecs_to_jiffies(interval); | 3862 | interval = msecs_to_jiffies(interval); |
3852 | if (unlikely(!interval)) | 3863 | interval = clamp(interval, 1UL, max_load_balance_interval); |
3853 | interval = 1; | ||
3854 | if (interval > HZ*num_online_cpus()/10) | ||
3855 | interval = HZ*num_online_cpus()/10; | ||
3856 | 3864 | ||
3857 | need_serialize = sd->flags & SD_SERIALIZE; | 3865 | need_serialize = sd->flags & SD_SERIALIZE; |
3858 | 3866 | ||