Skip to content

Commit 63b2ca3

Browse files
Nicolas Pitreingomolnar
authored andcommitted
sched: Let 'struct sched_group_power' care about CPU capacity
It is better not to think about compute capacity as being equivalent to "CPU power". The upcoming "power aware" scheduler work may create confusion with the notion of energy consumption if "power" is used too liberally. Since struct sched_group_power is really about compute capacity of sched groups, let's rename it to struct sched_group_capacity. Similarly sgp becomes sgc. Related variables and functions dealing with groups are also adjusted accordingly. Signed-off-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: Vincent Guittot <vincent.guittot@linaro.org> Cc: Daniel Lezcano <daniel.lezcano@linaro.org> Cc: Morten Rasmussen <morten.rasmussen@arm.com> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Cc: linaro-kernel@lists.linaro.org Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/n/tip-5yeix833vvgf2uyj5o36hpu9@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 0fedc6c commit 63b2ca3

4 files changed

Lines changed: 115 additions & 115 deletions

File tree

‎include/linux/sched.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ typedef const int (*sched_domain_flags_f)(void);
10131013
struct sd_data {
10141014
struct sched_domain **__percpu sd;
10151015
struct sched_group **__percpu sg;
1016-
struct sched_group_power **__percpu sgp;
1016+
struct sched_group_capacity **__percpu sgc;
10171017
};
10181018

10191019
struct sched_domain_topology_level {

‎kernel/sched/core.c‎

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5221,14 +5221,13 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
52215221
}
52225222

52235223
/*
5224-
* Even though we initialize ->power to something semi-sane,
5225-
* we leave power_orig unset. This allows us to detect if
5224+
* Even though we initialize ->capacity to something semi-sane,
5225+
* we leave capacity_orig unset. This allows us to detect if
52265226
* domain iteration is still funny without causing /0 traps.
52275227
*/
5228-
if (!group->sgp->power_orig) {
5228+
if (!group->sgc->capacity_orig) {
52295229
printk(KERN_CONT "\n");
5230-
printk(KERN_ERR "ERROR: domain->cpu_power not "
5231-
"set\n");
5230+
printk(KERN_ERR "ERROR: domain->cpu_capacity not set\n");
52325231
break;
52335232
}
52345233

@@ -5250,9 +5249,9 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
52505249
cpulist_scnprintf(str, sizeof(str), sched_group_cpus(group));
52515250

52525251
printk(KERN_CONT " %s", str);
5253-
if (group->sgp->power != SCHED_POWER_SCALE) {
5254-
printk(KERN_CONT " (cpu_power = %d)",
5255-
group->sgp->power);
5252+
if (group->sgc->capacity != SCHED_POWER_SCALE) {
5253+
printk(KERN_CONT " (cpu_capacity = %d)",
5254+
group->sgc->capacity);
52565255
}
52575256

52585257
group = group->next;
@@ -5466,7 +5465,7 @@ static struct root_domain *alloc_rootdomain(void)
54665465
return rd;
54675466
}
54685467

5469-
static void free_sched_groups(struct sched_group *sg, int free_sgp)
5468+
static void free_sched_groups(struct sched_group *sg, int free_sgc)
54705469
{
54715470
struct sched_group *tmp, *first;
54725471

@@ -5477,8 +5476,8 @@ static void free_sched_groups(struct sched_group *sg, int free_sgp)
54775476
do {
54785477
tmp = sg->next;
54795478

5480-
if (free_sgp && atomic_dec_and_test(&sg->sgp->ref))
5481-
kfree(sg->sgp);
5479+
if (free_sgc && atomic_dec_and_test(&sg->sgc->ref))
5480+
kfree(sg->sgc);
54825481

54835482
kfree(sg);
54845483
sg = tmp;
@@ -5496,7 +5495,7 @@ static void free_sched_domain(struct rcu_head *rcu)
54965495
if (sd->flags & SD_OVERLAP) {
54975496
free_sched_groups(sd->groups, 1);
54985497
} else if (atomic_dec_and_test(&sd->groups->ref)) {
5499-
kfree(sd->groups->sgp);
5498+
kfree(sd->groups->sgc);
55005499
kfree(sd->groups);
55015500
}
55025501
kfree(sd);
@@ -5707,17 +5706,17 @@ build_overlap_sched_groups(struct sched_domain *sd, int cpu)
57075706

57085707
cpumask_or(covered, covered, sg_span);
57095708

5710-
sg->sgp = *per_cpu_ptr(sdd->sgp, i);
5711-
if (atomic_inc_return(&sg->sgp->ref) == 1)
5709+
sg->sgc = *per_cpu_ptr(sdd->sgc, i);
5710+
if (atomic_inc_return(&sg->sgc->ref) == 1)
57125711
build_group_mask(sd, sg);
57135712

57145713
/*
5715-
* Initialize sgp->power such that even if we mess up the
5714+
* Initialize sgc->capacity such that even if we mess up the
57165715
* domains and no possible iteration will get us here, we won't
57175716
* die on a /0 trap.
57185717
*/
5719-
sg->sgp->power = SCHED_POWER_SCALE * cpumask_weight(sg_span);
5720-
sg->sgp->power_orig = sg->sgp->power;
5718+
sg->sgc->capacity = SCHED_POWER_SCALE * cpumask_weight(sg_span);
5719+
sg->sgc->capacity_orig = sg->sgc->capacity;
57215720

57225721
/*
57235722
* Make sure the first group of this domain contains the
@@ -5755,8 +5754,8 @@ static int get_group(int cpu, struct sd_data *sdd, struct sched_group **sg)
57555754

57565755
if (sg) {
57575756
*sg = *per_cpu_ptr(sdd->sg, cpu);
5758-
(*sg)->sgp = *per_cpu_ptr(sdd->sgp, cpu);
5759-
atomic_set(&(*sg)->sgp->ref, 1); /* for claim_allocations */
5757+
(*sg)->sgc = *per_cpu_ptr(sdd->sgc, cpu);
5758+
atomic_set(&(*sg)->sgc->ref, 1); /* for claim_allocations */
57605759
}
57615760

57625761
return cpu;
@@ -5819,16 +5818,16 @@ build_sched_groups(struct sched_domain *sd, int cpu)
58195818
}
58205819

58215820
/*
5822-
* Initialize sched groups cpu_power.
5821+
* Initialize sched groups cpu_capacity.
58235822
*
5824-
* cpu_power indicates the capacity of sched group, which is used while
5823+
* cpu_capacity indicates the capacity of sched group, which is used while
58255824
* distributing the load between different sched groups in a sched domain.
5826-
* Typically cpu_power for all the groups in a sched domain will be same unless
5827-
* there are asymmetries in the topology. If there are asymmetries, group
5828-
* having more cpu_power will pickup more load compared to the group having
5829-
* less cpu_power.
5825+
* Typically cpu_capacity for all the groups in a sched domain will be same
5826+
* unless there are asymmetries in the topology. If there are asymmetries,
5827+
* group having more cpu_capacity will pickup more load compared to the
5828+
* group having less cpu_capacity.
58305829
*/
5831-
static void init_sched_groups_power(int cpu, struct sched_domain *sd)
5830+
static void init_sched_groups_capacity(int cpu, struct sched_domain *sd)
58325831
{
58335832
struct sched_group *sg = sd->groups;
58345833

@@ -5842,8 +5841,8 @@ static void init_sched_groups_power(int cpu, struct sched_domain *sd)
58425841
if (cpu != group_balance_cpu(sg))
58435842
return;
58445843

5845-
update_group_power(sd, cpu);
5846-
atomic_set(&sg->sgp->nr_busy_cpus, sg->group_weight);
5844+
update_group_capacity(sd, cpu);
5845+
atomic_set(&sg->sgc->nr_busy_cpus, sg->group_weight);
58475846
}
58485847

58495848
/*
@@ -5934,8 +5933,8 @@ static void claim_allocations(int cpu, struct sched_domain *sd)
59345933
if (atomic_read(&(*per_cpu_ptr(sdd->sg, cpu))->ref))
59355934
*per_cpu_ptr(sdd->sg, cpu) = NULL;
59365935

5937-
if (atomic_read(&(*per_cpu_ptr(sdd->sgp, cpu))->ref))
5938-
*per_cpu_ptr(sdd->sgp, cpu) = NULL;
5936+
if (atomic_read(&(*per_cpu_ptr(sdd->sgc, cpu))->ref))
5937+
*per_cpu_ptr(sdd->sgc, cpu) = NULL;
59395938
}
59405939

59415940
#ifdef CONFIG_NUMA
@@ -6337,14 +6336,14 @@ static int __sdt_alloc(const struct cpumask *cpu_map)
63376336
if (!sdd->sg)
63386337
return -ENOMEM;
63396338

6340-
sdd->sgp = alloc_percpu(struct sched_group_power *);
6341-
if (!sdd->sgp)
6339+
sdd->sgc = alloc_percpu(struct sched_group_capacity *);
6340+
if (!sdd->sgc)
63426341
return -ENOMEM;
63436342

63446343
for_each_cpu(j, cpu_map) {
63456344
struct sched_domain *sd;
63466345
struct sched_group *sg;
6347-
struct sched_group_power *sgp;
6346+
struct sched_group_capacity *sgc;
63486347

63496348
sd = kzalloc_node(sizeof(struct sched_domain) + cpumask_size(),
63506349
GFP_KERNEL, cpu_to_node(j));
@@ -6362,12 +6361,12 @@ static int __sdt_alloc(const struct cpumask *cpu_map)
63626361

63636362
*per_cpu_ptr(sdd->sg, j) = sg;
63646363

6365-
sgp = kzalloc_node(sizeof(struct sched_group_power) + cpumask_size(),
6364+
sgc = kzalloc_node(sizeof(struct sched_group_capacity) + cpumask_size(),
63666365
GFP_KERNEL, cpu_to_node(j));
6367-
if (!sgp)
6366+
if (!sgc)
63686367
return -ENOMEM;
63696368

6370-
*per_cpu_ptr(sdd->sgp, j) = sgp;
6369+
*per_cpu_ptr(sdd->sgc, j) = sgc;
63716370
}
63726371
}
63736372

@@ -6394,15 +6393,15 @@ static void __sdt_free(const struct cpumask *cpu_map)
63946393

63956394
if (sdd->sg)
63966395
kfree(*per_cpu_ptr(sdd->sg, j));
6397-
if (sdd->sgp)
6398-
kfree(*per_cpu_ptr(sdd->sgp, j));
6396+
if (sdd->sgc)
6397+
kfree(*per_cpu_ptr(sdd->sgc, j));
63996398
}
64006399
free_percpu(sdd->sd);
64016400
sdd->sd = NULL;
64026401
free_percpu(sdd->sg);
64036402
sdd->sg = NULL;
6404-
free_percpu(sdd->sgp);
6405-
sdd->sgp = NULL;
6403+
free_percpu(sdd->sgc);
6404+
sdd->sgc = NULL;
64066405
}
64076406
}
64086407

@@ -6479,7 +6478,7 @@ static int build_sched_domains(const struct cpumask *cpu_map,
64796478

64806479
for (sd = *per_cpu_ptr(d.sd, i); sd; sd = sd->parent) {
64816480
claim_allocations(i, sd);
6482-
init_sched_groups_power(i, sd);
6481+
init_sched_groups_capacity(i, sd);
64836482
}
64846483
}
64856484

0 commit comments

Comments
 (0)