sched: Break out cpu_power from the sched_group structure
Commit-ID: 9c3f75cbd144014bea6af866a154cc2e73ab2287 Gitweb: http://git.kernel.org/tip/9c3f75cbd144014bea6af866a154cc2e73ab2287 Author: Peter Zijlstra <[email protected]> AuthorDate: Thu, 14 Jul 2011 13:00:06 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 20 Jul 2011 18:32:40 +0200
sched: Break out cpu_power from the sched_group structure
In order to prepare for non-unique sched_groups per domain, we need to carry the cpu_power elsewhere, so put a level of indirection in.
Reported-and-tested-by Anton Blanchard <[email protected]>
Signed-off-by Peter Zijlstra <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Andrew Morton <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- include/linux/sched.h | 14 +++++++++----- kernel/sched.c | 32 ++++++++++++++++++++++++++------ kernel/sched_fair.c | 46 +++++++++++++++++++++++----------------------- 3 files changed, 58 insertions(+), 34 deletions(-)
include/linux/sched.h +9 -5
@@ -893,16 +893,20 @@ static inline int sd_power_saving_flags(void)return 0 ; } -struct sched_group { -struct sched_group *next;/* Must be a circular list */ -atomic_t ref; - +struct sched_group_power {/* * CPU power of this group, SCHED_LOAD_SCALE being max power for a * single CPU. */ -unsigned int cpu_power, cpu_power_orig; +unsigned int power, power_orig; +}; + +struct sched_group { +struct sched_group *next;/* Must be a circular list */ +atomic_t ref; +unsigned int group_weight; +struct sched_group_power *sgp;/* * The CPUs this group covers.
kernel/sched.c +26 -6
@@ -6557,7 +6557,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,break ; } -if (!group->cpu_power) { +if (!group->sgp->power) {printk (KERN_CONT "\n" );printk (KERN_ERR "ERROR: domain->cpu_power not " "set\n" );
@@ -6581,9 +6581,9 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,cpulist_scnprintf (str,sizeof (str),sched_group_cpus (group));printk (KERN_CONT " %s" , str); -if (group->cpu_power !=SCHED_POWER_SCALE ) { +if (group->sgp->power !=SCHED_POWER_SCALE ) {printk (KERN_CONT " (cpu_power = %d)" , - group->cpu_power); + group->sgp->power); } group = group->next;
@@ -6777,8 +6777,10 @@ static struct root_domain *alloc_rootdomain(void)static void free_sched_domain (struct rcu_head *rcu) { struct sched_domain *sd = container_of(rcu, struct sched_domain, rcu); -if (atomic_dec_and_test (&sd->groups->ref)) +if (atomic_dec_and_test (&sd->groups->ref)) { +kfree (sd->groups->sgp);kfree (sd->groups); + }kfree (sd); }
@@ -6945,6 +6947,7 @@ int sched_smt_power_savings = 0, sched_mc_power_savings = 0;struct sd_data {struct sched_domain **__percpu sd;struct sched_group **__percpu sg; +struct sched_group_power **__percpu sgp; };struct s_data {
@@ -6981,8 +6984,10 @@ static int get_group(int cpu, struct sd_data *sdd, struct sched_group **sg)if (child) cpu =cpumask_first (sched_domain_span (child)); -if (sg) +if (sg) { *sg = *per_cpu_ptr (sdd->sg, cpu); + (*sg)->sgp = *per_cpu_ptr (sdd->sgp, cpu); + }return cpu; }
@@ -7020,7 +7025,7 @@ build_sched_groups(struct sched_domain *sd)continue ;cpumask_clear (sched_group_cpus (sg)); - sg->cpu_power =0 ; + sg->sgp->power =0 ;for_each_cpu (j, span) {if (get_group (j, sdd,NULL ) != group)
@@ -7185,6 +7190,7 @@ static void claim_allocations(int cpu, struct sched_domain *sd)if (cpu ==cpumask_first (sched_group_cpus (sg))) {WARN_ON_ONCE (*per_cpu_ptr (sdd->sg, cpu) != sg); *per_cpu_ptr (sdd->sg, cpu) =NULL ; + *per_cpu_ptr (sdd->sgp, cpu) =NULL ; } }
@@ -7234,9 +7240,14 @@ static int __sdt_alloc(const struct cpumask *cpu_map)if (!sdd->sg)return -ENOMEM ; + sdd->sgp = alloc_percpu(struct sched_group_power *); +if (!sdd->sgp) +return -ENOMEM ; +for_each_cpu (j, cpu_map) {struct sched_domain *sd;struct sched_group *sg; +struct sched_group_power *sgp; sd =kzalloc_node (sizeof (struct sched_domain ) +cpumask_size (),GFP_KERNEL ,cpu_to_node (j));
@@ -7251,6 +7262,13 @@ static int __sdt_alloc(const struct cpumask *cpu_map)return -ENOMEM ; *per_cpu_ptr (sdd->sg, j) = sg; + + sgp =kzalloc_node (sizeof (struct sched_group_power ), +GFP_KERNEL ,cpu_to_node (j)); +if (!sgp) +return -ENOMEM ; + + *per_cpu_ptr (sdd->sgp, j) = sgp; } }
@@ -7268,9 +7286,11 @@ static void __sdt_free(const struct cpumask *cpu_map)for_each_cpu (j, cpu_map) {kfree (*per_cpu_ptr (sdd->sd, j));kfree (*per_cpu_ptr (sdd->sg, j)); +kfree (*per_cpu_ptr (sdd->sgp, j)); }free_percpu (sdd->sd);free_percpu (sdd->sg); +free_percpu (sdd->sgp); } }
kernel/sched_fair.c +23 -23
140 lines not on this page · raw message