Skip to content

Commit ced549f

Browse files
Nicolas Pitreingomolnar
authored andcommitted
sched: Remove remaining dubious usage of "power"
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. This is the remaining "power" -> "capacity" rename for local symbols. Those symbols visible to the rest of the kernel are not included yet. 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-yyyhohzhkwnaotr3lx8zd5aa@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 63b2ca3 commit ced549f

3 files changed

Lines changed: 55 additions & 55 deletions

File tree

‎kernel/sched/core.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5764,7 +5764,7 @@ static int get_group(int cpu, struct sd_data *sdd, struct sched_group **sg)
57645764
/*
57655765
* build_sched_groups will build a circular linked list of the groups
57665766
* covered by the given span, and will set each group's ->cpumask correctly,
5767-
* and ->cpu_power to 0.
5767+
* and ->cpu_capacity to 0.
57685768
*
57695769
* Assumes the sched_domain tree is fully constructed
57705770
*/
@@ -6471,7 +6471,7 @@ static int build_sched_domains(const struct cpumask *cpu_map,
64716471
}
64726472
}
64736473

6474-
/* Calculate CPU power for physical packages and nodes */
6474+
/* Calculate CPU capacity for physical packages and nodes */
64756475
for (i = nr_cpumask_bits-1; i >= 0; i--) {
64766476
if (!cpumask_test_cpu(i, cpu_map))
64776477
continue;
@@ -6921,7 +6921,7 @@ void __init sched_init(void)
69216921
#ifdef CONFIG_SMP
69226922
rq->sd = NULL;
69236923
rq->rd = NULL;
6924-
rq->cpu_power = SCHED_POWER_SCALE;
6924+
rq->cpu_capacity = SCHED_POWER_SCALE;
69256925
rq->post_schedule = 0;
69266926
rq->active_balance = 0;
69276927
rq->next_balance = jiffies;

‎kernel/sched/fair.c‎

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ bool should_numa_migrate_memory(struct task_struct *p, struct page * page,
10171017
static unsigned long weighted_cpuload(const int cpu);
10181018
static unsigned long source_load(int cpu, int type);
10191019
static unsigned long target_load(int cpu, int type);
1020-
static unsigned long power_of(int cpu);
1020+
static unsigned long capacity_of(int cpu);
10211021
static long effective_load(struct task_group *tg, int cpu, long wl, long wg);
10221022

10231023
/* Cached statistics for all CPUs within a node */
@@ -1046,7 +1046,7 @@ static void update_numa_stats(struct numa_stats *ns, int nid)
10461046

10471047
ns->nr_running += rq->nr_running;
10481048
ns->load += weighted_cpuload(cpu);
1049-
ns->compute_capacity += power_of(cpu);
1049+
ns->compute_capacity += capacity_of(cpu);
10501050

10511051
cpus++;
10521052
}
@@ -1214,7 +1214,7 @@ static void task_numa_compare(struct task_numa_env *env,
12141214
orig_dst_load = env->dst_stats.load;
12151215
orig_src_load = env->src_stats.load;
12161216

1217-
/* XXX missing power terms */
1217+
/* XXX missing capacity terms */
12181218
load = task_h_load(env->p);
12191219
dst_load = orig_dst_load + load;
12201220
src_load = orig_src_load - load;
@@ -4043,9 +4043,9 @@ static unsigned long target_load(int cpu, int type)
40434043
return max(rq->cpu_load[type-1], total);
40444044
}
40454045

4046-
static unsigned long power_of(int cpu)
4046+
static unsigned long capacity_of(int cpu)
40474047
{
4048-
return cpu_rq(cpu)->cpu_power;
4048+
return cpu_rq(cpu)->cpu_capacity;
40494049
}
40504050

40514051
static unsigned long cpu_avg_load_per_task(int cpu)
@@ -4288,12 +4288,12 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
42884288
s64 this_eff_load, prev_eff_load;
42894289

42904290
this_eff_load = 100;
4291-
this_eff_load *= power_of(prev_cpu);
4291+
this_eff_load *= capacity_of(prev_cpu);
42924292
this_eff_load *= this_load +
42934293
effective_load(tg, this_cpu, weight, weight);
42944294

42954295
prev_eff_load = 100 + (sd->imbalance_pct - 100) / 2;
4296-
prev_eff_load *= power_of(this_cpu);
4296+
prev_eff_load *= capacity_of(this_cpu);
42974297
prev_eff_load *= load + effective_load(tg, prev_cpu, 0, weight);
42984298

42994299
balanced = this_eff_load <= prev_eff_load;
@@ -4950,14 +4950,14 @@ static bool yield_to_task_fair(struct rq *rq, struct task_struct *p, bool preemp
49504950
*
49514951
* W'_i,n = (2^n - 1) / 2^n * W_i,n + 1 / 2^n * W_i,0 (3)
49524952
*
4953-
* P_i is the cpu power (or compute capacity) of cpu i, typically it is the
4953+
* C_i is the compute capacity of cpu i, typically it is the
49544954
* fraction of 'recent' time available for SCHED_OTHER task execution. But it
49554955
* can also include other factors [XXX].
49564956
*
49574957
* To achieve this balance we define a measure of imbalance which follows
49584958
* directly from (1):
49594959
*
4960-
* imb_i,j = max{ avg(W/P), W_i/P_i } - min{ avg(W/P), W_j/P_j } (4)
4960+
* imb_i,j = max{ avg(W/C), W_i/C_i } - min{ avg(W/C), W_j/C_j } (4)
49614961
*
49624962
* We them move tasks around to minimize the imbalance. In the continuous
49634963
* function space it is obvious this converges, in the discrete case we get
@@ -5607,17 +5607,17 @@ static inline int get_sd_load_idx(struct sched_domain *sd,
56075607
return load_idx;
56085608
}
56095609

5610-
static unsigned long default_scale_freq_power(struct sched_domain *sd, int cpu)
5610+
static unsigned long default_scale_capacity(struct sched_domain *sd, int cpu)
56115611
{
56125612
return SCHED_POWER_SCALE;
56135613
}
56145614

56155615
unsigned long __weak arch_scale_freq_power(struct sched_domain *sd, int cpu)
56165616
{
5617-
return default_scale_freq_power(sd, cpu);
5617+
return default_scale_capacity(sd, cpu);
56185618
}
56195619

5620-
static unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu)
5620+
static unsigned long default_scale_smt_capacity(struct sched_domain *sd, int cpu)
56215621
{
56225622
unsigned long weight = sd->span_weight;
56235623
unsigned long smt_gain = sd->smt_gain;
@@ -5629,10 +5629,10 @@ static unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu)
56295629

56305630
unsigned long __weak arch_scale_smt_power(struct sched_domain *sd, int cpu)
56315631
{
5632-
return default_scale_smt_power(sd, cpu);
5632+
return default_scale_smt_capacity(sd, cpu);
56335633
}
56345634

5635-
static unsigned long scale_rt_power(int cpu)
5635+
static unsigned long scale_rt_capacity(int cpu)
56365636
{
56375637
struct rq *rq = cpu_rq(cpu);
56385638
u64 total, available, age_stamp, avg;
@@ -5652,7 +5652,7 @@ static unsigned long scale_rt_power(int cpu)
56525652
total = sched_avg_period() + delta;
56535653

56545654
if (unlikely(total < avg)) {
5655-
/* Ensures that power won't end up being negative */
5655+
/* Ensures that capacity won't end up being negative */
56565656
available = 0;
56575657
} else {
56585658
available = total - avg;
@@ -5666,38 +5666,38 @@ static unsigned long scale_rt_power(int cpu)
56665666
return div_u64(available, total);
56675667
}
56685668

5669-
static void update_cpu_power(struct sched_domain *sd, int cpu)
5669+
static void update_cpu_capacity(struct sched_domain *sd, int cpu)
56705670
{
56715671
unsigned long weight = sd->span_weight;
5672-
unsigned long power = SCHED_POWER_SCALE;
5672+
unsigned long capacity = SCHED_POWER_SCALE;
56735673
struct sched_group *sdg = sd->groups;
56745674

56755675
if ((sd->flags & SD_SHARE_CPUPOWER) && weight > 1) {
56765676
if (sched_feat(ARCH_POWER))
5677-
power *= arch_scale_smt_power(sd, cpu);
5677+
capacity *= arch_scale_smt_power(sd, cpu);
56785678
else
5679-
power *= default_scale_smt_power(sd, cpu);
5679+
capacity *= default_scale_smt_capacity(sd, cpu);
56805680

5681-
power >>= SCHED_POWER_SHIFT;
5681+
capacity >>= SCHED_POWER_SHIFT;
56825682
}
56835683

5684-
sdg->sgc->capacity_orig = power;
5684+
sdg->sgc->capacity_orig = capacity;
56855685

56865686
if (sched_feat(ARCH_POWER))
5687-
power *= arch_scale_freq_power(sd, cpu);
5687+
capacity *= arch_scale_freq_power(sd, cpu);
56885688
else
5689-
power *= default_scale_freq_power(sd, cpu);
5689+
capacity *= default_scale_capacity(sd, cpu);
56905690

5691-
power >>= SCHED_POWER_SHIFT;
5691+
capacity >>= SCHED_POWER_SHIFT;
56925692

5693-
power *= scale_rt_power(cpu);
5694-
power >>= SCHED_POWER_SHIFT;
5693+
capacity *= scale_rt_capacity(cpu);
5694+
capacity >>= SCHED_POWER_SHIFT;
56955695

5696-
if (!power)
5697-
power = 1;
5696+
if (!capacity)
5697+
capacity = 1;
56985698

5699-
cpu_rq(cpu)->cpu_power = power;
5700-
sdg->sgc->capacity = power;
5699+
cpu_rq(cpu)->cpu_capacity = capacity;
5700+
sdg->sgc->capacity = capacity;
57015701
}
57025702

57035703
void update_group_capacity(struct sched_domain *sd, int cpu)
@@ -5712,7 +5712,7 @@ void update_group_capacity(struct sched_domain *sd, int cpu)
57125712
sdg->sgc->next_update = jiffies + interval;
57135713

57145714
if (!child) {
5715-
update_cpu_power(sd, cpu);
5715+
update_cpu_capacity(sd, cpu);
57165716
return;
57175717
}
57185718

@@ -5733,17 +5733,17 @@ void update_group_capacity(struct sched_domain *sd, int cpu)
57335733
* gets here before we've attached the domains to the
57345734
* runqueues.
57355735
*
5736-
* Use power_of(), which is set irrespective of domains
5737-
* in update_cpu_power().
5736+
* Use capacity_of(), which is set irrespective of domains
5737+
* in update_cpu_capacity().
57385738
*
57395739
* This avoids capacity/capacity_orig from being 0 and
57405740
* causing divide-by-zero issues on boot.
57415741
*
57425742
* Runtime updates will correct capacity_orig.
57435743
*/
57445744
if (unlikely(!rq->sd)) {
5745-
capacity_orig += power_of(cpu);
5746-
capacity += power_of(cpu);
5745+
capacity_orig += capacity_of(cpu);
5746+
capacity += capacity_of(cpu);
57475747
continue;
57485748
}
57495749

@@ -5831,7 +5831,7 @@ static inline int sg_imbalanced(struct sched_group *group)
58315831
/*
58325832
* Compute the group capacity factor.
58335833
*
5834-
* Avoid the issue where N*frac(smt_power) >= 1 creates 'phantom' cores by
5834+
* Avoid the issue where N*frac(smt_capacity) >= 1 creates 'phantom' cores by
58355835
* first dividing out the smt factor and computing the actual number of cores
58365836
* and limit unit capacity with that.
58375837
*/
@@ -6129,7 +6129,7 @@ void fix_small_imbalance(struct lb_env *env, struct sd_lb_stats *sds)
61296129

61306130
/*
61316131
* OK, we don't have enough imbalance to justify moving tasks,
6132-
* however we may be able to increase total CPU power used by
6132+
* however we may be able to increase total CPU capacity used by
61336133
* moving them.
61346134
*/
61356135

@@ -6190,7 +6190,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
61906190
/*
61916191
* In the presence of smp nice balancing, certain scenarios can have
61926192
* max load less than avg load(as we skip the groups at or below
6193-
* its cpu_power, while calculating max_load..)
6193+
* its cpu_capacity, while calculating max_load..)
61946194
*/
61956195
if (busiest->avg_load <= sds->avg_load ||
61966196
local->avg_load >= sds->avg_load) {
@@ -6345,11 +6345,11 @@ static struct rq *find_busiest_queue(struct lb_env *env,
63456345
struct sched_group *group)
63466346
{
63476347
struct rq *busiest = NULL, *rq;
6348-
unsigned long busiest_load = 0, busiest_power = 1;
6348+
unsigned long busiest_load = 0, busiest_capacity = 1;
63496349
int i;
63506350

63516351
for_each_cpu_and(i, sched_group_cpus(group), env->cpus) {
6352-
unsigned long power, capacity_factor, wl;
6352+
unsigned long capacity, capacity_factor, wl;
63536353
enum fbq_type rt;
63546354

63556355
rq = cpu_rq(i);
@@ -6377,34 +6377,34 @@ static struct rq *find_busiest_queue(struct lb_env *env,
63776377
if (rt > env->fbq_type)
63786378
continue;
63796379

6380-
power = power_of(i);
6381-
capacity_factor = DIV_ROUND_CLOSEST(power, SCHED_POWER_SCALE);
6380+
capacity = capacity_of(i);
6381+
capacity_factor = DIV_ROUND_CLOSEST(capacity, SCHED_POWER_SCALE);
63826382
if (!capacity_factor)
63836383
capacity_factor = fix_small_capacity(env->sd, group);
63846384

63856385
wl = weighted_cpuload(i);
63866386

63876387
/*
63886388
* When comparing with imbalance, use weighted_cpuload()
6389-
* which is not scaled with the cpu power.
6389+
* which is not scaled with the cpu capacity.
63906390
*/
63916391
if (capacity_factor && rq->nr_running == 1 && wl > env->imbalance)
63926392
continue;
63936393

63946394
/*
63956395
* For the load comparisons with the other cpu's, consider
6396-
* the weighted_cpuload() scaled with the cpu power, so that
6397-
* the load can be moved away from the cpu that is potentially
6398-
* running at a lower capacity.
6396+
* the weighted_cpuload() scaled with the cpu capacity, so
6397+
* that the load can be moved away from the cpu that is
6398+
* potentially running at a lower capacity.
63996399
*
6400-
* Thus we're looking for max(wl_i / power_i), crosswise
6400+
* Thus we're looking for max(wl_i / capacity_i), crosswise
64016401
* multiplication to rid ourselves of the division works out
6402-
* to: wl_i * power_j > wl_j * power_i; where j is our
6403-
* previous maximum.
6402+
* to: wl_i * capacity_j > wl_j * capacity_i; where j is
6403+
* our previous maximum.
64046404
*/
6405-
if (wl * busiest_power > busiest_load * power) {
6405+
if (wl * busiest_capacity > busiest_load * capacity) {
64066406
busiest_load = wl;
6407-
busiest_power = power;
6407+
busiest_capacity = capacity;
64086408
busiest = rq;
64096409
}
64106410
}

‎kernel/sched/sched.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ struct rq {
567567
struct root_domain *rd;
568568
struct sched_domain *sd;
569569

570-
unsigned long cpu_power;
570+
unsigned long cpu_capacity;
571571

572572
unsigned char idle_balance;
573573
/* For active balancing */

0 commit comments

Comments
 (0)