cpufreq: Add special-purpose fast-switching callback for drivers
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 14 Dec 2020 20:08:00 +0000 (21:08 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 15 Dec 2020 18:24:18 +0000 (19:24 +0100)
commitee2cc4276ba4909438f5894a218877660e1536d9
tree691fe7a3348b9a8f343d50408cf2a39645abd943
parentca6827de4b67367e73fdf43d2ea0a0064423edfb
cpufreq: Add special-purpose fast-switching callback for drivers

First off, some cpufreq drivers (eg. intel_pstate) can pass hints
beyond the current target frequency to the hardware and there are no
provisions for doing that in the cpufreq framework.  In particular,
today the driver has to assume that it should not allow the frequency
to fall below the one requested by the governor (or the required
capacity may not be provided) which may not be the case and which may
lead to excessive energy usage in some scenarios.

Second, the hints passed by these drivers to the hardware need not be
in terms of the frequency, so representing the utilization numbers
coming from the scheduler as frequency before passing them to those
drivers is not really useful.

Address the two points above by adding a special-purpose replacement
for the ->fast_switch callback, called ->adjust_perf, allowing the
governor to pass abstract performance level (rather than frequency)
values for the minimum (required) and target (desired) performance
along with the CPU capacity to compare them to.

Also update the schedutil governor to use the new callback instead
of ->fast_switch if present and if the utilization mertics are
frequency-invariant (that is requisite for the direct mapping
between the utilization and the CPU performance levels to be a
reasonable approximation).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/cpufreq/cpufreq.c
include/linux/cpufreq.h
include/linux/sched/cpufreq.h
kernel/sched/cpufreq_schedutil.c