tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: A simple cpufreq(9)

On Fri, Sep 23, 2011 at 01:02:52PM +0300, Jukka Ruohonen wrote:
> Hello.
> The kernel needs a MI interface for CPU frequency scaling. Below is a draft
> that is deliberately as simple as possible.
> This is NOT about frequency scaling done by the kernel as a "governor"
> (although the long-term goal should point to that direction). The present
> goal is just to add a simple MI "interface" (or rather, wrapper) and abstract
> away machine- and platform-dependent code and user interfaces.
> As far as the implementation goes, this would add two simple MD callback
> functions to cpu_info. All ugly MD sysctls would be deprecated and setting
> the frequency would be done by cpuctl(8) via these callbacks.[1]
> The only interesting detail is that the term "CPU frequency" is defined as
> a percentage value: 100 % implies "full performance" and 0 % denotes the
> "lowest performance". This follows OpenBSD, being also one of the few
> possible ways to define "CPU frequency levels" independently from the
> machine. All details are left to the MD implementations, including how to
> translate the percentage to actual frequency (and/or voltage, etc.). For
> instance, for systems with only two states, all values higher than zero would
> set the "high performance mode".[2]

Don't use a percentage, the resolution is usually too high or too low
and that has bad consequences.  For example, if there are actually two
possible states, and some algorithm (or person) hunts for the one that
creates the power or heat savings they desire, there are 98 more states
for them to try than they really need to.

Instead, provide an API routine for finding out the number of states
(nstates) and a routine for selecting a state [0, nstates - 1].


David Young             OJC Technologies      Urbana, IL * (217) 344-0444 x24

Home | Main Index | Thread Index | Old Index