The new CPU frequency code
[Posted October 2, 2002 by corbet]
A new CPU frequency subsystem, written by Dominik Brodowski and others, was
integrated by Linus into the 2.5.40 release. This code provide user-space
control over the clock frequency of the CPU(s) in the system - at least,
for processors which provide that capability.
One might wonder why it would be desirable to run a processor at anything
below its rated speed. The reasons, of course, are power consumption and
thermal control. A faster CPU requires more power to run. If you're using
your laptop on an airplane, and you're not trying to crack any encryption
keys or set kernel build time records before you land, you might just want
to slow down the processor a little to avoid draining your battery.
Meanwhile, the processor may decide
to slow down on its own if it's getting too warm.
In fact, some modern processors can take a fairly smart approach to
frequency control. If the processor notices that it is spending a lot of
time idle, it can slow itself down. If it's constantly busy, it can turn
up the speed a bit. If a particular processor supports setting its
frequency in a "dumb" mode only, it might be nice for the operating system
to provide the automatic adjustment in software.
For this reason, a simple "set the frequency" interface was deemed to be
insufficient. The CPU frequency code merged into 2.5.40 reflects the new
understanding of the problem: it allows the user to set a range of
acceptable frequencies and the desired policy. If the user selects
"performance" as the policy, the processor will be instructed to run at the
upper end of its range; if it slows down, it does so gradually. With the
"powersave" policy, speeds will be kept lower even in the face of sustained
work to do. Overall, the new interface gives the user a great deal of
control over how the system operates. Of course, this interface is just a
cryptic /proc file (see Documentation/cpufreq in the 2.5.40 tree for
details); look for the KDE and GNOME
applications to show up in the near future.
For now, the code that has been merged into the kernel supports only the
i386 architecture. Code for a number of other processors exists and will
show up in the proper, architecture-specific trees.
(
Log in to post comments)