Commit 337946f8 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Thomas Gleixner

sched: update the cpu_power sum during load-balance

In order to prepare for a more dynamic cpu_power, update the group sum
while walking the sched domains during load-balance.
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarDinakar Guniguntala <dino@in.ibm.com>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Darren Hart <dvhltc@us.ibm.com>
Cc: John Kacur <jkacur@redhat.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 1724d42a
...@@ -3780,6 +3780,28 @@ static inline int check_power_save_busiest_group(struct sd_lb_stats *sds, ...@@ -3780,6 +3780,28 @@ static inline int check_power_save_busiest_group(struct sd_lb_stats *sds,
} }
#endif /* CONFIG_SCHED_MC || CONFIG_SCHED_SMT */ #endif /* CONFIG_SCHED_MC || CONFIG_SCHED_SMT */
static void update_sched_power(struct sched_domain *sd)
{
struct sched_domain *child = sd->child;
struct sched_group *group, *sdg = sd->groups;
unsigned long power = sdg->__cpu_power;
if (!child) {
/* compute cpu power for this cpu */
return;
}
sdg->__cpu_power = 0;
group = child->groups;
do {
sdg->__cpu_power += group->__cpu_power;
group = group->next;
} while (group != child->groups);
if (power != sdg->__cpu_power)
sdg->reciprocal_cpu_power = reciprocal_value(sdg->__cpu_power);
}
/** /**
* update_sg_lb_stats - Update sched_group's statistics for load balancing. * update_sg_lb_stats - Update sched_group's statistics for load balancing.
...@@ -3793,7 +3815,8 @@ static inline int check_power_save_busiest_group(struct sd_lb_stats *sds, ...@@ -3793,7 +3815,8 @@ static inline int check_power_save_busiest_group(struct sd_lb_stats *sds,
* @balance: Should we balance. * @balance: Should we balance.
* @sgs: variable to hold the statistics for this group. * @sgs: variable to hold the statistics for this group.
*/ */
static inline void update_sg_lb_stats(struct sched_group *group, int this_cpu, static inline void update_sg_lb_stats(struct sched_domain *sd,
struct sched_group *group, int this_cpu,
enum cpu_idle_type idle, int load_idx, int *sd_idle, enum cpu_idle_type idle, int load_idx, int *sd_idle,
int local_group, const struct cpumask *cpus, int local_group, const struct cpumask *cpus,
int *balance, struct sg_lb_stats *sgs) int *balance, struct sg_lb_stats *sgs)
...@@ -3804,8 +3827,11 @@ static inline void update_sg_lb_stats(struct sched_group *group, int this_cpu, ...@@ -3804,8 +3827,11 @@ static inline void update_sg_lb_stats(struct sched_group *group, int this_cpu,
unsigned long sum_avg_load_per_task; unsigned long sum_avg_load_per_task;
unsigned long avg_load_per_task; unsigned long avg_load_per_task;
if (local_group) if (local_group) {
balance_cpu = group_first_cpu(group); balance_cpu = group_first_cpu(group);
if (balance_cpu == this_cpu)
update_sched_power(sd);
}
/* Tally up the load of all CPUs in the group */ /* Tally up the load of all CPUs in the group */
sum_avg_load_per_task = avg_load_per_task = 0; sum_avg_load_per_task = avg_load_per_task = 0;
...@@ -3909,7 +3935,7 @@ static inline void update_sd_lb_stats(struct sched_domain *sd, int this_cpu, ...@@ -3909,7 +3935,7 @@ static inline void update_sd_lb_stats(struct sched_domain *sd, int this_cpu,
local_group = cpumask_test_cpu(this_cpu, local_group = cpumask_test_cpu(this_cpu,
sched_group_cpus(group)); sched_group_cpus(group));
memset(&sgs, 0, sizeof(sgs)); memset(&sgs, 0, sizeof(sgs));
update_sg_lb_stats(group, this_cpu, idle, load_idx, sd_idle, update_sg_lb_stats(sd, group, this_cpu, idle, load_idx, sd_idle,
local_group, cpus, balance, &sgs); local_group, cpus, balance, &sgs);
if (local_group && balance && !(*balance)) if (local_group && balance && !(*balance))
...@@ -3944,7 +3970,6 @@ static inline void update_sd_lb_stats(struct sched_domain *sd, int this_cpu, ...@@ -3944,7 +3970,6 @@ static inline void update_sd_lb_stats(struct sched_domain *sd, int this_cpu,
update_sd_power_savings_stats(group, sds, local_group, &sgs); update_sd_power_savings_stats(group, sds, local_group, &sgs);
group = group->next; group = group->next;
} while (group != sd->groups); } while (group != sd->groups);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment