10
10
#include <linux/types.h>
11
11
12
12
/**
13
- * em_cap_state - Capacity state of a performance domain
13
+ * em_perf_state - Performance state of a performance domain
14
14
* @frequency: The CPU frequency in KHz, for consistency with CPUFreq
15
15
* @power: The power consumed by 1 CPU at this level, in milli-watts
16
16
* @cost: The cost coefficient associated with this level, used during
17
17
* energy calculation. Equal to: power * max_frequency / frequency
18
18
*/
19
- struct em_cap_state {
19
+ struct em_perf_state {
20
20
unsigned long frequency ;
21
21
unsigned long power ;
22
22
unsigned long cost ;
23
23
};
24
24
25
25
/**
26
26
* em_perf_domain - Performance domain
27
- * @table: List of capacity states, in ascending order
28
- * @nr_cap_states : Number of capacity states
27
+ * @table: List of performance states, in ascending order
28
+ * @nr_perf_states : Number of performance states
29
29
* @cpus: Cpumask covering the CPUs of the domain
30
30
*
31
31
* A "performance domain" represents a group of CPUs whose performance is
@@ -34,22 +34,27 @@ struct em_cap_state {
34
34
* CPUFreq policies.
35
35
*/
36
36
struct em_perf_domain {
37
- struct em_cap_state * table ;
38
- int nr_cap_states ;
37
+ struct em_perf_state * table ;
38
+ int nr_perf_states ;
39
39
unsigned long cpus [];
40
40
};
41
41
42
+ #define em_span_cpus (em ) (to_cpumask((em)->cpus))
43
+
42
44
#ifdef CONFIG_ENERGY_MODEL
43
45
#define EM_CPU_MAX_POWER 0xFFFF
44
46
45
47
struct em_data_callback {
46
48
/**
47
- * active_power() - Provide power at the next capacity state of a CPU
48
- * @power : Active power at the capacity state in mW (modified)
49
- * @freq : Frequency at the capacity state in kHz (modified)
49
+ * active_power() - Provide power at the next performance state of
50
+ * a CPU
51
+ * @power : Active power at the performance state in mW
52
+ * (modified)
53
+ * @freq : Frequency at the performance state in kHz
54
+ * (modified)
50
55
* @cpu : CPU for which we do this operation
51
56
*
52
- * active_power() must find the lowest capacity state of 'cpu' above
57
+ * active_power() must find the lowest performance state of 'cpu' above
53
58
* 'freq' and update 'power' and 'freq' to the matching active power
54
59
* and frequency.
55
60
*
@@ -80,46 +85,46 @@ static inline unsigned long em_pd_energy(struct em_perf_domain *pd,
80
85
unsigned long max_util , unsigned long sum_util )
81
86
{
82
87
unsigned long freq , scale_cpu ;
83
- struct em_cap_state * cs ;
88
+ struct em_perf_state * ps ;
84
89
int i , cpu ;
85
90
86
91
/*
87
- * In order to predict the capacity state, map the utilization of the
88
- * most utilized CPU of the performance domain to a requested frequency,
89
- * like schedutil.
92
+ * In order to predict the performance state, map the utilization of
93
+ * the most utilized CPU of the performance domain to a requested
94
+ * frequency, like schedutil.
90
95
*/
91
96
cpu = cpumask_first (to_cpumask (pd -> cpus ));
92
97
scale_cpu = arch_scale_cpu_capacity (cpu );
93
- cs = & pd -> table [pd -> nr_cap_states - 1 ];
94
- freq = map_util_freq (max_util , cs -> frequency , scale_cpu );
98
+ ps = & pd -> table [pd -> nr_perf_states - 1 ];
99
+ freq = map_util_freq (max_util , ps -> frequency , scale_cpu );
95
100
96
101
/*
97
- * Find the lowest capacity state of the Energy Model above the
102
+ * Find the lowest performance state of the Energy Model above the
98
103
* requested frequency.
99
104
*/
100
- for (i = 0 ; i < pd -> nr_cap_states ; i ++ ) {
101
- cs = & pd -> table [i ];
102
- if (cs -> frequency >= freq )
105
+ for (i = 0 ; i < pd -> nr_perf_states ; i ++ ) {
106
+ ps = & pd -> table [i ];
107
+ if (ps -> frequency >= freq )
103
108
break ;
104
109
}
105
110
106
111
/*
107
- * The capacity of a CPU in the domain at that capacity state (cs )
112
+ * The capacity of a CPU in the domain at the performance state (ps )
108
113
* can be computed as:
109
114
*
110
- * cs ->freq * scale_cpu
111
- * cs ->cap = -------------------- (1)
115
+ * ps ->freq * scale_cpu
116
+ * ps ->cap = -------------------- (1)
112
117
* cpu_max_freq
113
118
*
114
119
* So, ignoring the costs of idle states (which are not available in
115
- * the EM), the energy consumed by this CPU at that capacity state is
116
- * estimated as:
120
+ * the EM), the energy consumed by this CPU at that performance state
121
+ * is estimated as:
117
122
*
118
- * cs ->power * cpu_util
123
+ * ps ->power * cpu_util
119
124
* cpu_nrg = -------------------- (2)
120
- * cs ->cap
125
+ * ps ->cap
121
126
*
122
- * since 'cpu_util / cs ->cap' represents its percentage of busy time.
127
+ * since 'cpu_util / ps ->cap' represents its percentage of busy time.
123
128
*
124
129
* NOTE: Although the result of this computation actually is in
125
130
* units of power, it can be manipulated as an energy value
@@ -129,34 +134,35 @@ static inline unsigned long em_pd_energy(struct em_perf_domain *pd,
129
134
* By injecting (1) in (2), 'cpu_nrg' can be re-expressed as a product
130
135
* of two terms:
131
136
*
132
- * cs ->power * cpu_max_freq cpu_util
137
+ * ps ->power * cpu_max_freq cpu_util
133
138
* cpu_nrg = ------------------------ * --------- (3)
134
- * cs ->freq scale_cpu
139
+ * ps ->freq scale_cpu
135
140
*
136
- * The first term is static, and is stored in the em_cap_state struct
137
- * as 'cs ->cost'.
141
+ * The first term is static, and is stored in the em_perf_state struct
142
+ * as 'ps ->cost'.
138
143
*
139
144
* Since all CPUs of the domain have the same micro-architecture, they
140
- * share the same 'cs ->cost', and the same CPU capacity. Hence, the
145
+ * share the same 'ps ->cost', and the same CPU capacity. Hence, the
141
146
* total energy of the domain (which is the simple sum of the energy of
142
147
* all of its CPUs) can be factorized as:
143
148
*
144
- * cs ->cost * \Sum cpu_util
149
+ * ps ->cost * \Sum cpu_util
145
150
* pd_nrg = ------------------------ (4)
146
151
* scale_cpu
147
152
*/
148
- return cs -> cost * sum_util / scale_cpu ;
153
+ return ps -> cost * sum_util / scale_cpu ;
149
154
}
150
155
151
156
/**
152
- * em_pd_nr_cap_states() - Get the number of capacity states of a perf. domain
157
+ * em_pd_nr_perf_states() - Get the number of performance states of a perf.
158
+ * domain
153
159
* @pd : performance domain for which this must be done
154
160
*
155
- * Return: the number of capacity states in the performance domain table
161
+ * Return: the number of performance states in the performance domain table
156
162
*/
157
- static inline int em_pd_nr_cap_states (struct em_perf_domain * pd )
163
+ static inline int em_pd_nr_perf_states (struct em_perf_domain * pd )
158
164
{
159
- return pd -> nr_cap_states ;
165
+ return pd -> nr_perf_states ;
160
166
}
161
167
162
168
#else
@@ -177,7 +183,7 @@ static inline unsigned long em_pd_energy(struct em_perf_domain *pd,
177
183
{
178
184
return 0 ;
179
185
}
180
- static inline int em_pd_nr_cap_states (struct em_perf_domain * pd )
186
+ static inline int em_pd_nr_perf_states (struct em_perf_domain * pd )
181
187
{
182
188
return 0 ;
183
189
}
0 commit comments