CPUFreq & P-State Go Through A Redesign With Linux 4.6

Rafael Wysocki sent in the power management and ACPI updates for Linux 4.6 on Monday and they contain some big changes particularly for the CPUFreq/P-State CPU frequency scaling code. Wysocki explained it as:
First off, the way CPU frequency updates are triggered is different now. Instead of having to set up and manage a deferrable timer for each CPU in the system to evaluate and possibly change its frequency periodically, cpufreq governors set up callbacks to be invoked by the scheduler on a regular basis (basically on utilization updates). The "old" governors, "ondemand" and "conservative", still do all of their work in process context (although that is triggered by the scheduler now), but intel_pstate does it all in the callback invoked by the scheduler with no need for any additional asynchronous processing.
Of course, this eliminates the overhead related to the management of all those timers, but also it allows the cpufreq governor code to be simplified quite a bit. On top of that, the common code and data structures used by the "ondemand" and "conservative" governors are cleaned up and made more straightforward and some long-standing and quite annoying problems are addressed. In particular, the handling of governor sysfs attributes is modified and the related locking becomes more fine grained which allows some concurrency problems to be avoided (particularly deadlocks with the core cpufreq code).
In principle, the new mechanism for triggering frequency updates allows utilization information to be passed from the scheduler to cpufreq. Although the current code doesn't make use of it, in the works is a new cpufreq governor that will make decisions based on the scheduler's utilization data. That should allow the scheduler and cpufreq to work more closely together in the long run.
Beyond this reworking of P-State and CPUFreq governors to use callbacks invoked by the scheduler rather than deferrable timers, there are also various bug fixes and optimizations to P-State, clean-ups to CPUFreq core, ACPICA updates, Intel RAPL driver fixes, TurboStat utility fixes, and other changes.
More details on this ACPI/PM update for the Linux 4.6 merge window can be found via this pull request.
3 Comments