Skip to content

Commit 931688a

Browse files
committed
Merge branches 'pm-powercap', 'pm-opp' and 'pm-em'
Merge power capping updates, OPP (operating performance points) updates and energy model management documentation updates for 6.20-rc1/7.0-rc1: - Add PL4 support for Ice Lake to the Intel RAPL power capping driver (Daniel Tang) - Replace sprintf() with sysfs_emit() in power capping sysfs show functions (Sumeet Pawnikar) - Make dev_pm_opp_get_level() return value match the documentation after a previous update of the latter (Aleks Todorov) - Use scoped for each OF child loop in the OPP code (Krzysztof Kozlowski) - Fix a bug in an example code snippet and correct typos in the energy model management documentation (Patrick Little) * pm-powercap: powercap: intel_rapl: Add PL4 support for Ice Lake powercap: Replace sprintf() with sysfs_emit() in sysfs show functions * pm-opp: OPP: Return correct value in dev_pm_opp_get_level OPP: of: Simplify with scoped for each OF child loop * pm-em: PM: EM: Documentation: Fix bug in example code snippet Documentation: Fix typos in energy model documentation
4 parents 073dcc0 + 54b3cd5 + e121ed7 + 1c7442d commit 931688a

6 files changed

Lines changed: 22 additions & 24 deletions

File tree

Documentation/power/energy-model.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ subsystems willing to use that information to make energy-aware decisions.
1414
The source of the information about the power consumed by devices can vary greatly
1515
from one platform to another. These power costs can be estimated using
1616
devicetree data in some cases. In others, the firmware will know better.
17-
Alternatively, userspace might be best positioned. And so on. In order to avoid
18-
each and every client subsystem to re-implement support for each and every
17+
Alternatively, userspace might be best positioned. In order to avoid
18+
having each and every client subsystem re-implement support for each and every
1919
possible source of information on its own, the EM framework intervenes as an
2020
abstraction layer which standardizes the format of power cost tables in the
2121
kernel, hence enabling to avoid redundant work.
@@ -32,7 +32,7 @@ be found in the Intelligent Power Allocation in
3232
Documentation/driver-api/thermal/power_allocator.rst.
3333
Kernel subsystems might implement automatic detection to check whether EM
3434
registered devices have inconsistent scale (based on EM internal flag).
35-
Important thing to keep in mind is that when the power values are expressed in
35+
An important thing to keep in mind is that when the power values are expressed in
3636
an 'abstract scale' deriving real energy in micro-Joules would not be possible.
3737

3838
The figure below depicts an example of drivers (Arm-specific here, but the
@@ -82,7 +82,7 @@ using kref mechanism. The device driver which provided the new EM at runtime,
8282
should call EM API to free it safely when it's no longer needed. The EM
8383
framework will handle the clean-up when it's possible.
8484

85-
The kernel code which want to modify the EM values is protected from concurrent
85+
The kernel code which wants to modify the EM values is protected from concurrent
8686
access using a mutex. Therefore, the device driver code must run in sleeping
8787
context when it tries to modify the EM.
8888

@@ -113,7 +113,7 @@ Registration of 'advanced' EM
113113
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114114

115115
The 'advanced' EM gets its name due to the fact that the driver is allowed
116-
to provide more precised power model. It's not limited to some implemented math
116+
to provide a more precise power model. It's not limited to some implemented math
117117
formula in the framework (like it is in 'simple' EM case). It can better reflect
118118
the real power measurements performed for each performance state. Thus, this
119119
registration method should be preferred in case considering EM static power
@@ -172,7 +172,7 @@ Registration of 'simple' EM
172172
~~~~~~~~~~~~~~~~~~~~~~~~~~~
173173

174174
The 'simple' EM is registered using the framework helper function
175-
cpufreq_register_em_with_opp(). It implements a power model which is tight to
175+
cpufreq_register_em_with_opp(). It implements a power model which is tied to a
176176
math formula::
177177

178178
Power = C * V^2 * f
@@ -251,7 +251,7 @@ It returns the 'struct em_perf_state' pointer which is an array of performance
251251
states in ascending order.
252252
This function must be called in the RCU read lock section (after the
253253
rcu_read_lock()). When the EM table is not needed anymore there is a need to
254-
call rcu_real_unlock(). In this way the EM safely uses the RCU read section
254+
call rcu_read_unlock(). In this way the EM safely uses the RCU read section
255255
and protects the users. It also allows the EM framework to manage the memory
256256
and free it. More details how to use it can be found in Section 3.2 in the
257257
example driver.
@@ -308,12 +308,12 @@ EM framework::
308308
05
309309
06 /* Use the 'foo' protocol to ceil the frequency */
310310
07 freq = foo_get_freq_ceil(dev, *KHz);
311-
08 if (freq < 0);
311+
08 if (freq < 0)
312312
09 return freq;
313313
10
314314
11 /* Estimate the power cost for the dev at the relevant freq. */
315315
12 power = foo_estimate_power(dev, freq);
316-
13 if (power < 0);
316+
13 if (power < 0)
317317
14 return power;
318318
15
319319
16 /* Return the values to the EM framework */

Documentation/scheduler/sched-energy.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,15 @@ Example 2.
244244

245245

246246
From these calculations, the Case 1 has the lowest total energy. So CPU 1
247-
is be the best candidate from an energy-efficiency standpoint.
247+
is the best candidate from an energy-efficiency standpoint.
248248

249249
Big CPUs are generally more power hungry than the little ones and are thus used
250250
mainly when a task doesn't fit the littles. However, little CPUs aren't always
251251
necessarily more energy-efficient than big CPUs. For some systems, the high OPPs
252252
of the little CPUs can be less energy-efficient than the lowest OPPs of the
253253
bigs, for example. So, if the little CPUs happen to have enough utilization at
254254
a specific point in time, a small task waking up at that moment could be better
255-
of executing on the big side in order to save energy, even though it would fit
255+
off executing on the big side in order to save energy, even though it would fit
256256
on the little side.
257257

258258
And even in the case where all OPPs of the big CPUs are less energy-efficient
@@ -285,7 +285,7 @@ much that can be done by the scheduler to save energy without severely harming
285285
throughput. In order to avoid hurting performance with EAS, CPUs are flagged as
286286
'over-utilized' as soon as they are used at more than 80% of their compute
287287
capacity. As long as no CPUs are over-utilized in a root domain, load balancing
288-
is disabled and EAS overridess the wake-up balancing code. EAS is likely to load
288+
is disabled and EAS overrides the wake-up balancing code. EAS is likely to load
289289
the most energy efficient CPUs of the system more than the others if that can be
290290
done without harming throughput. So, the load-balancer is disabled to prevent
291291
it from breaking the energy-efficient task placement found by EAS. It is safe to
@@ -385,7 +385,7 @@ Using EAS with any other governor than schedutil is not supported.
385385
6.5 Scale-invariant utilization signals
386386
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
387387

388-
In order to make accurate prediction across CPUs and for all performance
388+
In order to make accurate predictions across CPUs and for all performance
389389
states, EAS needs frequency-invariant and CPU-invariant PELT signals. These can
390390
be obtained using the architecture-defined arch_scale{cpu,freq}_capacity()
391391
callbacks.

drivers/opp/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp)
241241
{
242242
if (IS_ERR_OR_NULL(opp) || !opp->available) {
243243
pr_err("%s: Invalid parameters\n", __func__);
244-
return 0;
244+
return U32_MAX;
245245
}
246246

247247
return opp->level;

drivers/opp/of.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,6 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table,
956956
/* Initializes OPP tables based on new bindings */
957957
static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
958958
{
959-
struct device_node *np;
960959
int ret, count = 0;
961960
struct dev_pm_opp *opp;
962961

@@ -971,13 +970,12 @@ static int _of_add_opp_table_v2(struct device *dev, struct opp_table *opp_table)
971970
}
972971

973972
/* We have opp-table node now, iterate over it and add OPPs */
974-
for_each_available_child_of_node(opp_table->np, np) {
973+
for_each_available_child_of_node_scoped(opp_table->np, np) {
975974
opp = _opp_add_static_v2(opp_table, dev, np);
976975
if (IS_ERR(opp)) {
977976
ret = PTR_ERR(opp);
978977
dev_err(dev, "%s: Failed to add OPP, %d\n", __func__,
979978
ret);
980-
of_node_put(np);
981979
goto remove_static_opp;
982980
} else if (opp) {
983981
count++;

drivers/powercap/intel_rapl_msr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ static int rapl_msr_write_raw(int cpu, struct reg_action *ra)
162162

163163
/* List of verified CPUs. */
164164
static const struct x86_cpu_id pl4_support_ids[] = {
165+
X86_MATCH_VFM(INTEL_ICELAKE_L, NULL),
165166
X86_MATCH_VFM(INTEL_TIGERLAKE_L, NULL),
166167
X86_MATCH_VFM(INTEL_ALDERLAKE, NULL),
167168
X86_MATCH_VFM(INTEL_ALDERLAKE_L, NULL),

drivers/powercap/powercap_sys.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static ssize_t _attr##_show(struct device *dev, \
2727
\
2828
if (power_zone->ops->get_##_attr) { \
2929
if (!power_zone->ops->get_##_attr(power_zone, &value)) \
30-
len = sprintf(buf, "%lld\n", value); \
30+
len = sysfs_emit(buf, "%lld\n", value); \
3131
} \
3232
\
3333
return len; \
@@ -75,7 +75,7 @@ static ssize_t show_constraint_##_attr(struct device *dev, \
7575
pconst = &power_zone->constraints[id]; \
7676
if (pconst && pconst->ops && pconst->ops->get_##_attr) { \
7777
if (!pconst->ops->get_##_attr(power_zone, id, &value)) \
78-
len = sprintf(buf, "%lld\n", value); \
78+
len = sysfs_emit(buf, "%lld\n", value); \
7979
} \
8080
\
8181
return len; \
@@ -171,9 +171,8 @@ static ssize_t show_constraint_name(struct device *dev,
171171
if (pconst && pconst->ops && pconst->ops->get_name) {
172172
name = pconst->ops->get_name(power_zone, id);
173173
if (name) {
174-
sprintf(buf, "%.*s\n", POWERCAP_CONSTRAINT_NAME_LEN - 1,
175-
name);
176-
len = strlen(buf);
174+
len = sysfs_emit(buf, "%.*s\n",
175+
POWERCAP_CONSTRAINT_NAME_LEN - 1, name);
177176
}
178177
}
179178

@@ -350,7 +349,7 @@ static ssize_t name_show(struct device *dev,
350349
{
351350
struct powercap_zone *power_zone = to_powercap_zone(dev);
352351

353-
return sprintf(buf, "%s\n", power_zone->name);
352+
return sysfs_emit(buf, "%s\n", power_zone->name);
354353
}
355354

356355
static DEVICE_ATTR_RO(name);
@@ -438,7 +437,7 @@ static ssize_t enabled_show(struct device *dev,
438437
mode = false;
439438
}
440439

441-
return sprintf(buf, "%d\n", mode);
440+
return sysfs_emit(buf, "%d\n", mode);
442441
}
443442

444443
static ssize_t enabled_store(struct device *dev,

0 commit comments

Comments
 (0)