Skip to content

Commit 56098a4

Browse files
committed
cpuidle: menu: Update documentation after previous changes
After commit 38f8309 ("cpuidle: menu: Remove iowait influence") and other previous changes, the description of the menu governor in the documentation does not match the code any more, so update it as appropriate. Fixes: 38f8309 ("cpuidle: menu: Remove iowait influence") Fixes: 5484e31 ("cpuidle: menu: Skip tick_nohz_get_sleep_length() call in some cases") Reported-by: Artem Bityutskiy <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Christian Loehle <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 5bc55a3 commit 56098a4

File tree

1 file changed

+31
-41
lines changed

1 file changed

+31
-41
lines changed

Documentation/admin-guide/pm/cpuidle.rst

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -269,27 +269,7 @@ Namely, when invoked to select an idle state for a CPU (i.e. an idle state that
269269
the CPU will ask the processor hardware to enter), it attempts to predict the
270270
idle duration and uses the predicted value for idle state selection.
271271

272-
It first obtains the time until the closest timer event with the assumption
273-
that the scheduler tick will be stopped. That time, referred to as the *sleep
274-
length* in what follows, is the upper bound on the time before the next CPU
275-
wakeup. It is used to determine the sleep length range, which in turn is needed
276-
to get the sleep length correction factor.
277-
278-
The ``menu`` governor maintains two arrays of sleep length correction factors.
279-
One of them is used when tasks previously running on the given CPU are waiting
280-
for some I/O operations to complete and the other one is used when that is not
281-
the case. Each array contains several correction factor values that correspond
282-
to different sleep length ranges organized so that each range represented in the
283-
array is approximately 10 times wider than the previous one.
284-
285-
The correction factor for the given sleep length range (determined before
286-
selecting the idle state for the CPU) is updated after the CPU has been woken
287-
up and the closer the sleep length is to the observed idle duration, the closer
288-
to 1 the correction factor becomes (it must fall between 0 and 1 inclusive).
289-
The sleep length is multiplied by the correction factor for the range that it
290-
falls into to obtain the first approximation of the predicted idle duration.
291-
292-
Next, the governor uses a simple pattern recognition algorithm to refine its
272+
It first uses a simple pattern recognition algorithm to obtain a preliminary
293273
idle duration prediction. Namely, it saves the last 8 observed idle duration
294274
values and, when predicting the idle duration next time, it computes the average
295275
and variance of them. If the variance is small (smaller than 400 square
@@ -301,29 +281,39 @@ Again, if the variance of them is small (in the above sense), the average is
301281
taken as the "typical interval" value and so on, until either the "typical
302282
interval" is determined or too many data points are disregarded, in which case
303283
the "typical interval" is assumed to equal "infinity" (the maximum unsigned
304-
integer value). The "typical interval" computed this way is compared with the
305-
sleep length multiplied by the correction factor and the minimum of the two is
306-
taken as the predicted idle duration.
307-
308-
Then, the governor computes an extra latency limit to help "interactive"
309-
workloads. It uses the observation that if the exit latency of the selected
310-
idle state is comparable with the predicted idle duration, the total time spent
311-
in that state probably will be very short and the amount of energy to save by
312-
entering it will be relatively small, so likely it is better to avoid the
313-
overhead related to entering that state and exiting it. Thus selecting a
314-
shallower state is likely to be a better option then. The first approximation
315-
of the extra latency limit is the predicted idle duration itself which
316-
additionally is divided by a value depending on the number of tasks that
317-
previously ran on the given CPU and now they are waiting for I/O operations to
318-
complete. The result of that division is compared with the latency limit coming
319-
from the power management quality of service, or `PM QoS <cpu-pm-qos_>`_,
320-
framework and the minimum of the two is taken as the limit for the idle states'
321-
exit latency.
284+
integer value).
285+
286+
If the "typical interval" computed this way is long enough, the governor obtains
287+
the time until the closest timer event with the assumption that the scheduler
288+
tick will be stopped. That time, referred to as the *sleep length* in what follows,
289+
is the upper bound on the time before the next CPU wakeup. It is used to determine
290+
the sleep length range, which in turn is needed to get the sleep length correction
291+
factor.
292+
293+
The ``menu`` governor maintains an array containing several correction factor
294+
values that correspond to different sleep length ranges organized so that each
295+
range represented in the array is approximately 10 times wider than the previous
296+
one.
297+
298+
The correction factor for the given sleep length range (determined before
299+
selecting the idle state for the CPU) is updated after the CPU has been woken
300+
up and the closer the sleep length is to the observed idle duration, the closer
301+
to 1 the correction factor becomes (it must fall between 0 and 1 inclusive).
302+
The sleep length is multiplied by the correction factor for the range that it
303+
falls into to obtain an approximation of the predicted idle duration that is
304+
compared to the "typical interval" determined previously and the minimum of
305+
the two is taken as the idle duration prediction.
306+
307+
If the "typical interval" value is small, which means that the CPU is likely
308+
to be woken up soon enough, the sleep length computation is skipped as it may
309+
be costly and the idle duration is simply predicted to equal the "typical
310+
interval" value.
322311

323312
Now, the governor is ready to walk the list of idle states and choose one of
324313
them. For this purpose, it compares the target residency of each state with
325-
the predicted idle duration and the exit latency of it with the computed latency
326-
limit. It selects the state with the target residency closest to the predicted
314+
the predicted idle duration and the exit latency of it with the with the latency
315+
limit coming from the power management quality of service, or `PM QoS <cpu-pm-qos_>`_,
316+
framework. It selects the state with the target residency closest to the predicted
327317
idle duration, but still below it, and exit latency that does not exceed the
328318
limit.
329319

0 commit comments

Comments
 (0)