Skip to content

Commit ed562d2

Browse files
committed
Merge branches 'pm-cpufreq' and 'pm-cpuidle'
* pm-cpufreq: cpufreq: Make cpufreq_online() call driver->offline() on errors cpufreq: loongson2: Remove unused linux/sched.h headers cpufreq: sh: Remove unused linux/sched.h headers cpufreq: stats: Clean up local variable in cpufreq_stats_create_table() cpufreq: intel_pstate: hybrid: Fix build with CONFIG_ACPI unset cpufreq: sc520_freq: add 'fallthrough' to one case cpufreq: intel_pstate: Add Cometlake support in no-HWP mode cpufreq: intel_pstate: Add Icelake servers support in no-HWP mode cpufreq: intel_pstate: hybrid: CPU-specific scaling factor cpufreq: intel_pstate: hybrid: Avoid exposing two global attributes * pm-cpuidle: cpuidle: teo: remove unneeded semicolon in teo_select() cpuidle: teo: Use kerneldoc documentation in admin-guide cpuidle: teo: Rework most recent idle duration values treatment cpuidle: teo: Change the main idle state selection logic cpuidle: teo: Cosmetic modification of teo_select() cpuidle: teo: Cosmetic modifications of teo_update() intel_idle: Adjust the SKX C6 parameters if PC6 is disabled
3 parents afe94fb + 3b71805 + 795e0e3 commit ed562d2

File tree

10 files changed

+536
-338
lines changed

10 files changed

+536
-338
lines changed

Documentation/admin-guide/pm/cpuidle.rst

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -347,81 +347,8 @@ for tickless systems. It follows the same basic strategy as the ``menu`` `one
347347
<menu-gov_>`_: it always tries to find the deepest idle state suitable for the
348348
given conditions. However, it applies a different approach to that problem.
349349

350-
First, it does not use sleep length correction factors, but instead it attempts
351-
to correlate the observed idle duration values with the available idle states
352-
and use that information to pick up the idle state that is most likely to
353-
"match" the upcoming CPU idle interval. Second, it does not take the tasks
354-
that were running on the given CPU in the past and are waiting on some I/O
355-
operations to complete now at all (there is no guarantee that they will run on
356-
the same CPU when they become runnable again) and the pattern detection code in
357-
it avoids taking timer wakeups into account. It also only uses idle duration
358-
values less than the current time till the closest timer (with the scheduler
359-
tick excluded) for that purpose.
360-
361-
Like in the ``menu`` governor `case <menu-gov_>`_, the first step is to obtain
362-
the *sleep length*, which is the time until the closest timer event with the
363-
assumption that the scheduler tick will be stopped (that also is the upper bound
364-
on the time until the next CPU wakeup). That value is then used to preselect an
365-
idle state on the basis of three metrics maintained for each idle state provided
366-
by the ``CPUIdle`` driver: ``hits``, ``misses`` and ``early_hits``.
367-
368-
The ``hits`` and ``misses`` metrics measure the likelihood that a given idle
369-
state will "match" the observed (post-wakeup) idle duration if it "matches" the
370-
sleep length. They both are subject to decay (after a CPU wakeup) every time
371-
the target residency of the idle state corresponding to them is less than or
372-
equal to the sleep length and the target residency of the next idle state is
373-
greater than the sleep length (that is, when the idle state corresponding to
374-
them "matches" the sleep length). The ``hits`` metric is increased if the
375-
former condition is satisfied and the target residency of the given idle state
376-
is less than or equal to the observed idle duration and the target residency of
377-
the next idle state is greater than the observed idle duration at the same time
378-
(that is, it is increased when the given idle state "matches" both the sleep
379-
length and the observed idle duration). In turn, the ``misses`` metric is
380-
increased when the given idle state "matches" the sleep length only and the
381-
observed idle duration is too short for its target residency.
382-
383-
The ``early_hits`` metric measures the likelihood that a given idle state will
384-
"match" the observed (post-wakeup) idle duration if it does not "match" the
385-
sleep length. It is subject to decay on every CPU wakeup and it is increased
386-
when the idle state corresponding to it "matches" the observed (post-wakeup)
387-
idle duration and the target residency of the next idle state is less than or
388-
equal to the sleep length (i.e. the idle state "matching" the sleep length is
389-
deeper than the given one).
390-
391-
The governor walks the list of idle states provided by the ``CPUIdle`` driver
392-
and finds the last (deepest) one with the target residency less than or equal
393-
to the sleep length. Then, the ``hits`` and ``misses`` metrics of that idle
394-
state are compared with each other and it is preselected if the ``hits`` one is
395-
greater (which means that that idle state is likely to "match" the observed idle
396-
duration after CPU wakeup). If the ``misses`` one is greater, the governor
397-
preselects the shallower idle state with the maximum ``early_hits`` metric
398-
(or if there are multiple shallower idle states with equal ``early_hits``
399-
metric which also is the maximum, the shallowest of them will be preselected).
400-
[If there is a wakeup latency constraint coming from the `PM QoS framework
401-
<cpu-pm-qos_>`_ which is hit before reaching the deepest idle state with the
402-
target residency within the sleep length, the deepest idle state with the exit
403-
latency within the constraint is preselected without consulting the ``hits``,
404-
``misses`` and ``early_hits`` metrics.]
405-
406-
Next, the governor takes several idle duration values observed most recently
407-
into consideration and if at least a half of them are greater than or equal to
408-
the target residency of the preselected idle state, that idle state becomes the
409-
final candidate to ask for. Otherwise, the average of the most recent idle
410-
duration values below the target residency of the preselected idle state is
411-
computed and the governor walks the idle states shallower than the preselected
412-
one and finds the deepest of them with the target residency within that average.
413-
That idle state is then taken as the final candidate to ask for.
414-
415-
Still, at this point the governor may need to refine the idle state selection if
416-
it has not decided to `stop the scheduler tick <idle-cpus-and-tick_>`_. That
417-
generally happens if the target residency of the idle state selected so far is
418-
less than the tick period and the tick has not been stopped already (in a
419-
previous iteration of the idle loop). Then, like in the ``menu`` governor
420-
`case <menu-gov_>`_, the sleep length used in the previous computations may not
421-
reflect the real time until the closest timer event and if it really is greater
422-
than that time, a shallower state with a suitable target residency may need to
423-
be selected.
424-
350+
.. kernel-doc:: drivers/cpuidle/governors/teo.c
351+
:doc: teo-description
425352

426353
.. _idle-states-representation:
427354

Documentation/admin-guide/pm/intel_pstate.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ argument is passed to the kernel in the command line.
365365
inclusive) including both turbo and non-turbo P-states (see
366366
`Turbo P-states Support`_).
367367

368+
This attribute is present only if the value exposed by it is the same
369+
for all of the CPUs in the system.
370+
368371
The value of this attribute is not affected by the ``no_turbo``
369372
setting described `below <no_turbo_attr_>`_.
370373

@@ -374,6 +377,9 @@ argument is passed to the kernel in the command line.
374377
Ratio of the `turbo range <turbo_>`_ size to the size of the entire
375378
range of supported P-states, in percent.
376379

380+
This attribute is present only if the value exposed by it is the same
381+
for all of the CPUs in the system.
382+
377383
This attribute is read-only.
378384

379385
.. _no_turbo_attr:

drivers/cpufreq/cpufreq.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,9 +1367,14 @@ static int cpufreq_online(unsigned int cpu)
13671367
goto out_free_policy;
13681368
}
13691369

1370+
/*
1371+
* The initialization has succeeded and the policy is online.
1372+
* If there is a problem with its frequency table, take it
1373+
* offline and drop it.
1374+
*/
13701375
ret = cpufreq_table_validate_and_sort(policy);
13711376
if (ret)
1372-
goto out_exit_policy;
1377+
goto out_offline_policy;
13731378

13741379
/* related_cpus should at least include policy->cpus. */
13751380
cpumask_copy(policy->related_cpus, policy->cpus);
@@ -1515,6 +1520,10 @@ static int cpufreq_online(unsigned int cpu)
15151520

15161521
up_write(&policy->rwsem);
15171522

1523+
out_offline_policy:
1524+
if (cpufreq_driver->offline)
1525+
cpufreq_driver->offline(policy);
1526+
15181527
out_exit_policy:
15191528
if (cpufreq_driver->exit)
15201529
cpufreq_driver->exit(policy);

drivers/cpufreq/cpufreq_stats.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void cpufreq_stats_free_table(struct cpufreq_policy *policy)
211211

212212
void cpufreq_stats_create_table(struct cpufreq_policy *policy)
213213
{
214-
unsigned int i = 0, count = 0, ret = -ENOMEM;
214+
unsigned int i = 0, count;
215215
struct cpufreq_stats *stats;
216216
unsigned int alloc_size;
217217
struct cpufreq_frequency_table *pos;
@@ -253,8 +253,7 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy)
253253
stats->last_index = freq_table_get_index(stats, policy->cur);
254254

255255
policy->stats = stats;
256-
ret = sysfs_create_group(&policy->kobj, &stats_attr_group);
257-
if (!ret)
256+
if (!sysfs_create_group(&policy->kobj, &stats_attr_group))
258257
return;
259258

260259
/* We failed, release resources */

0 commit comments

Comments
 (0)