aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched_fair.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2010-04-16 08:59:29 -0400
committerIngo Molnar <mingo@elte.hu>2010-04-23 05:02:02 -0400
commit669c55e9f99b90e46eaa0f98a67ec53d46dc969a (patch)
tree9f60bcf779e5ec786c05b8053b59e091edcb418c /kernel/sched_fair.c
parent74f5187ac873042f502227701ed1727e7c5fbfa9 (diff)
sched: Pre-compute cpumask_weight(sched_domain_span(sd))
Dave reported that his large SPARC machines spend lots of time in hweight64(), try and optimize some of those needless cpumask_weight() invocations (esp. with the large offstack cpumasks these are very expensive indeed). Reported-by: David Miller <davem@davemloft.net> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched_fair.c')
-rw-r--r--kernel/sched_fair.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 88d3053ac7c2..0a413c7e3ab8 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1508,9 +1508,7 @@ select_task_rq_fair(struct rq *rq, struct task_struct *p, int sd_flag, int wake_
1508 * Pick the largest domain to update shares over 1508 * Pick the largest domain to update shares over
1509 */ 1509 */
1510 tmp = sd; 1510 tmp = sd;
1511 if (affine_sd && (!tmp || 1511 if (affine_sd && (!tmp || affine_sd->span_weight > sd->span_weight))
1512 cpumask_weight(sched_domain_span(affine_sd)) >
1513 cpumask_weight(sched_domain_span(sd))))
1514 tmp = affine_sd; 1512 tmp = affine_sd;
1515 1513
1516 if (tmp) { 1514 if (tmp) {
@@ -1554,10 +1552,10 @@ select_task_rq_fair(struct rq *rq, struct task_struct *p, int sd_flag, int wake_
1554 1552
1555 /* Now try balancing at a lower domain level of new_cpu */ 1553 /* Now try balancing at a lower domain level of new_cpu */
1556 cpu = new_cpu; 1554 cpu = new_cpu;
1557 weight = cpumask_weight(sched_domain_span(sd)); 1555 weight = sd->span_weight;
1558 sd = NULL; 1556 sd = NULL;
1559 for_each_domain(cpu, tmp) { 1557 for_each_domain(cpu, tmp) {
1560 if (weight <= cpumask_weight(sched_domain_span(tmp))) 1558 if (weight <= tmp->span_weight)
1561 break; 1559 break;
1562 if (tmp->flags & sd_flag) 1560 if (tmp->flags & sd_flag)
1563 sd = tmp; 1561 sd = tmp;
@@ -2243,7 +2241,7 @@ unsigned long __weak arch_scale_freq_power(struct sched_domain *sd, int cpu)
2243 2241
2244unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu) 2242unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu)
2245{ 2243{
2246 unsigned long weight = cpumask_weight(sched_domain_span(sd)); 2244 unsigned long weight = sd->span_weight;
2247 unsigned long smt_gain = sd->smt_gain; 2245 unsigned long smt_gain = sd->smt_gain;
2248 2246
2249 smt_gain /= weight; 2247 smt_gain /= weight;
@@ -2276,7 +2274,7 @@ unsigned long scale_rt_power(int cpu)
2276 2274
2277static void update_cpu_power(struct sched_domain *sd, int cpu) 2275static void update_cpu_power(struct sched_domain *sd, int cpu)
2278{ 2276{
2279 unsigned long weight = cpumask_weight(sched_domain_span(sd)); 2277 unsigned long weight = sd->span_weight;
2280 unsigned long power = SCHED_LOAD_SCALE; 2278 unsigned long power = SCHED_LOAD_SCALE;
2281 struct sched_group *sdg = sd->groups; 2279 struct sched_group *sdg = sd->groups;
2282 2280