Commit 7de962c0 authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki

cpufreq: Documentation: Updates based on current code

The cpufreq core has gone though lots of updates in recent times, but on
many occasions the documentation wasn't updated along with the code.
This patch tries to catchup the documentation with the code.

Also add Rafael and Viresh as the contributors to the documentation.

Based on a patch from Claudio Scordino.
Signed-off-by: default avatarClaudio Scordino <claudio@evidence.eu.com>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 4e660759
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
Dominik Brodowski <linux@brodo.de> Dominik Brodowski <linux@brodo.de>
David Kimdon <dwhedon@debian.org> David Kimdon <dwhedon@debian.org>
Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Viresh Kumar <viresh.kumar@linaro.org>
...@@ -36,10 +38,11 @@ speed limits (like LCD drivers on ARM architecture). Additionally, the ...@@ -36,10 +38,11 @@ speed limits (like LCD drivers on ARM architecture). Additionally, the
kernel "constant" loops_per_jiffy is updated on frequency changes kernel "constant" loops_per_jiffy is updated on frequency changes
here. here.
Reference counting is done by cpufreq_get_cpu and cpufreq_put_cpu, Reference counting of the cpufreq policies is done by cpufreq_cpu_get
which make sure that the cpufreq processor driver is correctly and cpufreq_cpu_put, which make sure that the cpufreq driver is
registered with the core, and will not be unloaded until correctly registered with the core, and will not be unloaded until
cpufreq_put_cpu is called. cpufreq_put_cpu is called. That also ensures that the respective cpufreq
policy doesn't get freed while being used.
2. CPUFreq notifiers 2. CPUFreq notifiers
==================== ====================
...@@ -69,18 +72,16 @@ CPUFreq policy notifier is called twice for a policy transition: ...@@ -69,18 +72,16 @@ CPUFreq policy notifier is called twice for a policy transition:
The phase is specified in the second argument to the notifier. The phase is specified in the second argument to the notifier.
The third argument, a void *pointer, points to a struct cpufreq_policy The third argument, a void *pointer, points to a struct cpufreq_policy
consisting of five values: cpu, min, max, policy and max_cpu_freq. min consisting of several values, including min, max (the lower and upper
and max are the lower and upper frequencies (in kHz) of the new frequencies (in kHz) of the new policy).
policy, policy the new policy, cpu the number of the affected CPU; and
max_cpu_freq the maximum supported CPU frequency. This value is given
for informational purposes only.
2.2 CPUFreq transition notifiers 2.2 CPUFreq transition notifiers
-------------------------------- --------------------------------
These are notified twice when the CPUfreq driver switches the CPU core These are notified twice for each online CPU in the policy, when the
frequency and this change has any external implications. CPUfreq driver switches the CPU core frequency and this change has no
any external implications.
The second argument specifies the phase - CPUFREQ_PRECHANGE or The second argument specifies the phase - CPUFREQ_PRECHANGE or
CPUFREQ_POSTCHANGE. CPUFREQ_POSTCHANGE.
...@@ -90,6 +91,7 @@ values: ...@@ -90,6 +91,7 @@ values:
cpu - number of the affected CPU cpu - number of the affected CPU
old - old frequency old - old frequency
new - new frequency new - new frequency
flags - flags of the cpufreq driver
3. CPUFreq Table Generation with Operating Performance Point (OPP) 3. CPUFreq Table Generation with Operating Performance Point (OPP)
================================================================== ==================================================================
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
Dominik Brodowski <linux@brodo.de> Dominik Brodowski <linux@brodo.de>
Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Viresh Kumar <viresh.kumar@linaro.org>
...@@ -49,49 +51,65 @@ using cpufreq_register_driver() ...@@ -49,49 +51,65 @@ using cpufreq_register_driver()
What shall this struct cpufreq_driver contain? What shall this struct cpufreq_driver contain?
cpufreq_driver.name - The name of this driver. .name - The name of this driver.
cpufreq_driver.init - A pointer to the per-CPU initialization .init - A pointer to the per-policy initialization function.
function.
cpufreq_driver.verify - A pointer to a "verification" function. .verify - A pointer to a "verification" function.
cpufreq_driver.setpolicy _or_ .setpolicy _or_ .fast_switch _or_ .target _or_ .target_index - See
cpufreq_driver.target/ below on the differences.
target_index - See below on the differences.
And optionally And optionally
cpufreq_driver.exit - A pointer to a per-CPU cleanup .flags - Hints for the cpufreq core.
function called during CPU_POST_DEAD
phase of cpu hotplug process.
cpufreq_driver.stop_cpu - A pointer to a per-CPU stop function .driver_data - cpufreq driver specific data.
called during CPU_DOWN_PREPARE phase of
cpu hotplug process.
cpufreq_driver.resume - A pointer to a per-CPU resume function .resolve_freq - Returns the most appropriate frequency for a target
which is called with interrupts disabled frequency. Doesn't change the frequency though.
and _before_ the pre-suspend frequency
and/or policy is restored by a call to
->target/target_index or ->setpolicy.
cpufreq_driver.attr - A pointer to a NULL-terminated list of .get_intermediate and target_intermediate - Used to switch to stable
"struct freq_attr" which allow to frequency while changing CPU frequency.
export values to sysfs.
cpufreq_driver.get_intermediate .get - Returns current frequency of the CPU.
and target_intermediate Used to switch to stable frequency while
changing CPU frequency. .bios_limit - Returns HW/BIOS max frequency limitations for the CPU.
.exit - A pointer to a per-policy cleanup function called during
CPU_POST_DEAD phase of cpu hotplug process.
.stop_cpu - A pointer to a per-policy stop function called during
CPU_DOWN_PREPARE phase of cpu hotplug process.
.suspend - A pointer to a per-policy suspend function which is called
with interrupts disabled and _after_ the governor is stopped for the
policy.
.resume - A pointer to a per-policy resume function which is called
with interrupts disabled and _before_ the governor is started again.
.ready - A pointer to a per-policy ready function which is called after
the policy is fully initialized.
.attr - A pointer to a NULL-terminated list of "struct freq_attr" which
allow to export values to sysfs.
.boost_enabled - If set, boost frequencies are enabled.
.set_boost - A pointer to a per-policy function to enable/disable boost
frequencies.
1.2 Per-CPU Initialization 1.2 Per-CPU Initialization
-------------------------- --------------------------
Whenever a new CPU is registered with the device model, or after the Whenever a new CPU is registered with the device model, or after the
cpufreq driver registers itself, the per-CPU initialization function cpufreq driver registers itself, the per-policy initialization function
cpufreq_driver.init is called. It takes a struct cpufreq_policy cpufreq_driver.init is called if no cpufreq policy existed for the CPU.
*policy as argument. What to do now? Note that the .init() and .exit() routines are called only once for the
policy and not for each CPU managed by the policy. It takes a struct
cpufreq_policy *policy as argument. What to do now?
If necessary, activate the CPUfreq support on your CPU. If necessary, activate the CPUfreq support on your CPU.
...@@ -117,47 +135,45 @@ policy->governor must contain the "default policy" for ...@@ -117,47 +135,45 @@ policy->governor must contain the "default policy" for
cpufreq_driver.setpolicy or cpufreq_driver.setpolicy or
cpufreq_driver.target/target_index is called cpufreq_driver.target/target_index is called
with these values. with these values.
policy->cpus Update this with the masks of the
(online + offline) CPUs that do DVFS
along with this CPU (i.e. that share
clock/voltage rails with it).
For setting some of these values (cpuinfo.min[max]_freq, policy->min[max]), the For setting some of these values (cpuinfo.min[max]_freq, policy->min[max]), the
frequency table helpers might be helpful. See the section 2 for more information frequency table helpers might be helpful. See the section 2 for more information
on them. on them.
SMP systems normally have same clock source for a group of cpus. For these the
.init() would be called only once for the first online cpu. Here the .init()
routine must initialize policy->cpus with mask of all possible cpus (Online +
Offline) that share the clock. Then the core would copy this mask onto
policy->related_cpus and will reset policy->cpus to carry only online cpus.
1.3 verify 1.3 verify
------------ ----------
When the user decides a new policy (consisting of When the user decides a new policy (consisting of
"policy,governor,min,max") shall be set, this policy must be validated "policy,governor,min,max") shall be set, this policy must be validated
so that incompatible values can be corrected. For verifying these so that incompatible values can be corrected. For verifying these
values, a frequency table helper and/or the values cpufreq_verify_within_limits(struct cpufreq_policy *policy,
cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned unsigned int min_freq, unsigned int max_freq) function might be helpful.
int min_freq, unsigned int max_freq) function might be helpful. See See section 2 for details on frequency table helpers.
section 2 for details on frequency table helpers.
You need to make sure that at least one valid frequency (or operating You need to make sure that at least one valid frequency (or operating
range) is within policy->min and policy->max. If necessary, increase range) is within policy->min and policy->max. If necessary, increase
policy->max first, and only if this is no solution, decrease policy->min. policy->max first, and only if this is no solution, decrease policy->min.
1.4 target/target_index or setpolicy? 1.4 target or target_index or setpolicy or fast_switch?
---------------------------- -------------------------------------------------------
Most cpufreq drivers or even most cpu frequency scaling algorithms Most cpufreq drivers or even most cpu frequency scaling algorithms
only allow the CPU to be set to one frequency. For these, you use the only allow the CPU frequency to be set to predefined fixed values. For
->target/target_index call. these, you use the ->target(), ->target_index() or ->fast_switch()
callbacks.
Some cpufreq-capable processors switch the frequency between certain Some cpufreq capable processors switch the frequency between certain
limits on their own. These shall use the ->setpolicy call limits on their own. These shall use the ->setpolicy() callback.
1.5. target/target_index 1.5. target/target_index
------------- ------------------------
The target_index call has two arguments: struct cpufreq_policy *policy, The target_index call has two arguments: struct cpufreq_policy *policy,
and unsigned int index (into the exposed frequency table). and unsigned int index (into the exposed frequency table).
...@@ -186,9 +202,20 @@ actual frequency must be determined using the following rules: ...@@ -186,9 +202,20 @@ actual frequency must be determined using the following rules:
Here again the frequency table helper might assist you - see section 2 Here again the frequency table helper might assist you - see section 2
for details. for details.
1.6. fast_switch
----------------
1.6 setpolicy This function is used for frequency switching from scheduler's context.
--------------- Not all drivers are expected to implement it, as sleeping from within
this callback isn't allowed. This callback must be highly optimized to
do switching as fast as possible.
This function has two arguments: struct cpufreq_policy *policy and
unsigned int target_frequency.
1.7 setpolicy
-------------
The setpolicy call only takes a struct cpufreq_policy *policy as The setpolicy call only takes a struct cpufreq_policy *policy as
argument. You need to set the lower limit of the in-processor or argument. You need to set the lower limit of the in-processor or
...@@ -198,7 +225,7 @@ setting when policy->policy is CPUFREQ_POLICY_PERFORMANCE, and a ...@@ -198,7 +225,7 @@ setting when policy->policy is CPUFREQ_POLICY_PERFORMANCE, and a
powersaving-oriented setting when CPUFREQ_POLICY_POWERSAVE. Also check powersaving-oriented setting when CPUFREQ_POLICY_POWERSAVE. Also check
the reference implementation in drivers/cpufreq/longrun.c the reference implementation in drivers/cpufreq/longrun.c
1.7 get_intermediate and target_intermediate 1.8 get_intermediate and target_intermediate
-------------------------------------------- --------------------------------------------
Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION unset. Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION unset.
...@@ -222,42 +249,36 @@ failures as core would send notifications for that. ...@@ -222,42 +249,36 @@ failures as core would send notifications for that.
As most cpufreq processors only allow for being set to a few specific As most cpufreq processors only allow for being set to a few specific
frequencies, a "frequency table" with some functions might assist in frequencies, a "frequency table" with some functions might assist in
some work of the processor driver. Such a "frequency table" consists some work of the processor driver. Such a "frequency table" consists of
of an array of struct cpufreq_frequency_table entries, with any value in an array of struct cpufreq_frequency_table entries, with driver specific
"driver_data" you want to use, and the corresponding frequency in values in "driver_data", the corresponding frequency in "frequency" and
"frequency". At the end of the table, you need to add a flags set. At the end of the table, you need to add a
cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END. And cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END.
if you want to skip one entry in the table, set the frequency to And if you want to skip one entry in the table, set the frequency to
CPUFREQ_ENTRY_INVALID. The entries don't need to be in ascending CPUFREQ_ENTRY_INVALID. The entries don't need to be in sorted in any
order. particular order, but if they are cpufreq core will do DVFS a bit
quickly for them as search for best match is faster.
By calling cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table); By calling cpufreq_table_validate_and_show(), the cpuinfo.min_freq and
the cpuinfo.min_freq and cpuinfo.max_freq values are detected, and cpuinfo.max_freq values are detected, and policy->min and policy->max
policy->min and policy->max are set to the same values. This is are set to the same values. This is helpful for the per-CPU
helpful for the per-CPU initialization stage. initialization stage.
int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, cpufreq_frequency_table_verify() assures that at least one valid
struct cpufreq_frequency_table *table); frequency is within policy->min and policy->max, and all other criteria
assures that at least one valid frequency is within policy->min and are met. This is helpful for the ->verify call.
policy->max, and all other criteria are met. This is helpful for the
->verify call. cpufreq_frequency_table_target() is the corresponding frequency table
helper for the ->target stage. Just pass the values to this function,
int cpufreq_frequency_table_target(struct cpufreq_policy *policy, and this function returns the of the frequency table entry which
unsigned int target_freq, contains the frequency the CPU shall be set to.
unsigned int relation);
is the corresponding frequency table helper for the ->target
stage. Just pass the values to this function, and this function
returns the number of the frequency table entry which contains
the frequency the CPU shall be set to.
The following macros can be used as iterators over cpufreq_frequency_table: The following macros can be used as iterators over cpufreq_frequency_table:
cpufreq_for_each_entry(pos, table) - iterates over all entries of frequency cpufreq_for_each_entry(pos, table) - iterates over all entries of frequency
table. table.
cpufreq-for_each_valid_entry(pos, table) - iterates over all entries, cpufreq_for_each_valid_entry(pos, table) - iterates over all entries,
excluding CPUFREQ_ENTRY_INVALID frequencies. excluding CPUFREQ_ENTRY_INVALID frequencies.
Use arguments "pos" - a cpufreq_frequency_table * as a loop cursor and Use arguments "pos" - a cpufreq_frequency_table * as a loop cursor and
"table" - the cpufreq_frequency_table * you want to iterate over. "table" - the cpufreq_frequency_table * you want to iterate over.
......
...@@ -34,10 +34,10 @@ cpufreq stats provides following statistics (explained in detail below). ...@@ -34,10 +34,10 @@ cpufreq stats provides following statistics (explained in detail below).
- total_trans - total_trans
- trans_table - trans_table
All the statistics will be from the time the stats driver has been inserted All the statistics will be from the time the stats driver has been inserted
to the time when a read of a particular statistic is done. Obviously, stats (or the time the stats were reset) to the time when a read of a particular
driver will not have any information about the frequency transitions before statistic is done. Obviously, stats driver will not have any information
the stats driver insertion. about the frequency transitions before the stats driver insertion.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
...@@ -110,25 +110,13 @@ Config Main Menu ...@@ -110,25 +110,13 @@ Config Main Menu
CPU Frequency scaling ---> CPU Frequency scaling --->
[*] CPU Frequency scaling [*] CPU Frequency scaling
[*] CPU frequency translation statistics [*] CPU frequency translation statistics
[*] CPU frequency translation statistics details
"CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure "CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
cpufreq-stats. cpufreq-stats.
"CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the "CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the
basic statistics which includes time_in_state and total_trans. statistics which includes time_in_state, total_trans and trans_table.
"CPU frequency translation statistics details" (CONFIG_CPU_FREQ_STAT_DETAILS) Once this option is enabled and your CPU supports cpufrequency, you
provides fine grained cpufreq stats by trans_table. The reason for having a
separate config option for trans_table is:
- trans_table goes against the traditional /sysfs rule of one value per
interface. It provides a whole bunch of value in a 2 dimensional matrix
form.
Once these two options are enabled and your CPU supports cpufrequency, you
will be able to see the CPU frequency statistics in /sysfs. will be able to see the CPU frequency statistics in /sysfs.
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
Dominik Brodowski <linux@brodo.de> Dominik Brodowski <linux@brodo.de>
some additions and corrections by Nico Golde <nico@ngolde.de> some additions and corrections by Nico Golde <nico@ngolde.de>
Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Viresh Kumar <viresh.kumar@linaro.org>
...@@ -28,32 +30,27 @@ Contents: ...@@ -28,32 +30,27 @@ Contents:
2.3 Userspace 2.3 Userspace
2.4 Ondemand 2.4 Ondemand
2.5 Conservative 2.5 Conservative
2.6 Schedutil
3. The Governor Interface in the CPUfreq Core 3. The Governor Interface in the CPUfreq Core
4. References
1. What Is A CPUFreq Governor? 1. What Is A CPUFreq Governor?
============================== ==============================
Most cpufreq drivers (except the intel_pstate and longrun) or even most Most cpufreq drivers (except the intel_pstate and longrun) or even most
cpu frequency scaling algorithms only offer the CPU to be set to one cpu frequency scaling algorithms only allow the CPU frequency to be set
frequency. In order to offer dynamic frequency scaling, the cpufreq to predefined fixed values. In order to offer dynamic frequency
core must be able to tell these drivers of a "target frequency". So scaling, the cpufreq core must be able to tell these drivers of a
these specific drivers will be transformed to offer a "->target/target_index" "target frequency". So these specific drivers will be transformed to
call instead of the existing "->setpolicy" call. For "longrun", all offer a "->target/target_index/fast_switch()" call instead of the
stays the same, though. "->setpolicy()" call. For set_policy drivers, all stays the same,
though.
How to decide what frequency within the CPUfreq policy should be used? How to decide what frequency within the CPUfreq policy should be used?
That's done using "cpufreq governors". Two are already in this patch That's done using "cpufreq governors".
-- they're the already existing "powersave" and "performance" which
set the frequency statically to the lowest or highest frequency,
respectively. At least two more such governors will be ready for
addition in the near future, but likely many more as there are various
different theories and models about dynamic frequency scaling
around. Using such a generic interface as cpufreq offers to scaling
governors, these can be tested extensively, and the best one can be
selected for each specific use.
Basically, it's the following flow graph: Basically, it's the following flow graph:
...@@ -71,7 +68,7 @@ CPU can be set to switch independently | CPU can only be set ...@@ -71,7 +68,7 @@ CPU can be set to switch independently | CPU can only be set
/ the limits of policy->{min,max} / the limits of policy->{min,max}
/ \ / \
/ \ / \
Using the ->setpolicy call, Using the ->target/target_index call, Using the ->setpolicy call, Using the ->target/target_index/fast_switch call,
the limits and the the frequency closest the limits and the the frequency closest
"policy" is set. to target_freq is set. "policy" is set. to target_freq is set.
It is assured that it It is assured that it
...@@ -109,9 +106,12 @@ directory. ...@@ -109,9 +106,12 @@ directory.
2.4 Ondemand 2.4 Ondemand
------------ ------------
The CPUfreq governor "ondemand" sets the CPU depending on the The CPUfreq governor "ondemand" sets the CPU frequency depending on the
current usage. To do this the CPU must have the capability to current system load. Load estimation is triggered by the scheduler
switch the frequency very quickly. through the update_util_data->func hook; when triggered, cpufreq checks
the CPU-usage statistics over the last period and the governor sets the
CPU accordingly. The CPU must have the capability to switch the
frequency very quickly.
Sysfs files: Sysfs files:
...@@ -207,12 +207,12 @@ Sysfs files: ...@@ -207,12 +207,12 @@ Sysfs files:
---------------- ----------------
The CPUfreq governor "conservative", much like the "ondemand" The CPUfreq governor "conservative", much like the "ondemand"
governor, sets the CPU depending on the current usage. It differs in governor, sets the CPU frequency depending on the current usage. It
behaviour in that it gracefully increases and decreases the CPU speed differs in behaviour in that it gracefully increases and decreases the
rather than jumping to max speed the moment there is any load on the CPU speed rather than jumping to max speed the moment there is any load
CPU. This behaviour more suitable in a battery powered environment. on the CPU. This behaviour is more suitable in a battery powered
The governor is tweaked in the same manner as the "ondemand" governor environment. The governor is tweaked in the same manner as the
through sysfs with the addition of: "ondemand" governor through sysfs with the addition of:
* freq_step: * freq_step:
...@@ -237,6 +237,29 @@ through sysfs with the addition of: ...@@ -237,6 +237,29 @@ through sysfs with the addition of:
decision on when to decrease the frequency while running in any speed. decision on when to decrease the frequency while running in any speed.
Load for frequency increase is still evaluated every sampling rate. Load for frequency increase is still evaluated every sampling rate.
2.6 Schedutil
-------------
The "schedutil" governor aims at better integration with the Linux
kernel scheduler. Load estimation is achieved through the scheduler's
Per-Entity Load Tracking (PELT) mechanism, which also provides
information about the recent load [1]. This governor currently does
load based DVFS only for tasks managed by CFS. RT and DL scheduler tasks
are always run at the highest frequency. Unlike all the other
governors, the code is located under the kernel/sched/ directory.
Sysfs files:
* rate_limit_us:
This contains a value in microseconds. The governor waits for
rate_limit_us time before reevaluating the load again, after it has
evaluated the load once.
For an in-depth comparison with the other governors refer to [2].
3. The Governor Interface in the CPUfreq Core 3. The Governor Interface in the CPUfreq Core
============================================= =============================================
...@@ -244,26 +267,10 @@ A new governor must register itself with the CPUfreq core using ...@@ -244,26 +267,10 @@ A new governor must register itself with the CPUfreq core using
"cpufreq_register_governor". The struct cpufreq_governor, which has to "cpufreq_register_governor". The struct cpufreq_governor, which has to
be passed to that function, must contain the following values: be passed to that function, must contain the following values:
governor->name - A unique name for this governor governor->name - A unique name for this governor.
governor->governor - The governor callback function governor->owner - .THIS_MODULE for the governor module (if appropriate).
governor->owner - .THIS_MODULE for the governor module (if
appropriate)
The governor->governor callback is called with the current (or to-be-set)
cpufreq_policy struct for that CPU, and an unsigned int event. The
following events are currently defined:
CPUFREQ_GOV_START: This governor shall start its duty for the CPU
policy->cpu
CPUFREQ_GOV_STOP: This governor shall end its duty for the CPU
policy->cpu
CPUFREQ_GOV_LIMITS: The limits for CPU policy->cpu have changed to
policy->min and policy->max.
If you need other "events" externally of your driver, _only_ use the
cpufreq_governor_l(unsigned int cpu, unsigned int event) call to the
CPUfreq core to ensure proper locking.
plus a set of hooks to the functions implementing the governor's logic.
The CPUfreq governor may call the CPU processor driver using one of The CPUfreq governor may call the CPU processor driver using one of
these two functions: these two functions:
...@@ -277,12 +284,18 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, ...@@ -277,12 +284,18 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
unsigned int relation); unsigned int relation);
target_freq must be within policy->min and policy->max, of course. target_freq must be within policy->min and policy->max, of course.
What's the difference between these two functions? When your governor What's the difference between these two functions? When your governor is
still is in a direct code path of a call to governor->governor, the in a direct code path of a call to governor callbacks, like
per-CPU cpufreq lock is still held in the cpufreq core, and there's governor->start(), the policy->rwsem is still held in the cpufreq core,
no need to lock it again (in fact, this would cause a deadlock). So and there's no need to lock it again (in fact, this would cause a
use __cpufreq_driver_target only in these cases. In all other cases deadlock). So use __cpufreq_driver_target only in these cases. In all
(for example, when there's a "daemonized" function that wakes up other cases (for example, when there's a "daemonized" function that
every second), use cpufreq_driver_target to lock the cpufreq per-CPU wakes up every second), use cpufreq_driver_target to take policy->rwsem
lock before the command is passed to the cpufreq processor driver. before the command is passed to the cpufreq driver.
4. References
=============
[1] Per-entity load tracking: https://lwn.net/Articles/531853/
[2] Improvements in CPU frequency management: https://lwn.net/Articles/682391/
...@@ -18,16 +18,29 @@ ...@@ -18,16 +18,29 @@
Documents in this directory: Documents in this directory:
---------------------------- ----------------------------
amd-powernow.txt - AMD powernow driver specific file.
boost.txt - Frequency boosting support.
core.txt - General description of the CPUFreq core and core.txt - General description of the CPUFreq core and
of CPUFreq notifiers of CPUFreq notifiers.
cpu-drivers.txt - How to implement a new cpufreq processor driver.
cpu-drivers.txt - How to implement a new cpufreq processor driver cpufreq-nforce2.txt - nVidia nForce2 platform specific file.
cpufreq-stats.txt - General description of sysfs cpufreq stats.
governors.txt - What are cpufreq governors and how to governors.txt - What are cpufreq governors and how to
implement them? implement them?
index.txt - File index, Mailing list and Links (this document) index.txt - File index, Mailing list and Links (this document)
intel-pstate.txt - Intel pstate cpufreq driver specific file.
pcc-cpufreq.txt - PCC cpufreq driver specific file.
user-guide.txt - User Guide to CPUFreq user-guide.txt - User Guide to CPUFreq
...@@ -35,9 +48,7 @@ Mailing List ...@@ -35,9 +48,7 @@ Mailing List
------------ ------------
There is a CPU frequency changing CVS commit and general list where There is a CPU frequency changing CVS commit and general list where
you can report bugs, problems or submit patches. To post a message, you can report bugs, problems or submit patches. To post a message,
send an email to linux-pm@vger.kernel.org, to subscribe go to send an email to linux-pm@vger.kernel.org.
http://vger.kernel.org/vger-lists.html#linux-pm and follow the
instructions there.
Links Links
----- -----
...@@ -48,7 +59,7 @@ how to access the CVS repository: ...@@ -48,7 +59,7 @@ how to access the CVS repository:
* http://cvs.arm.linux.org.uk/ * http://cvs.arm.linux.org.uk/
the CPUFreq Mailing list: the CPUFreq Mailing list:
* http://vger.kernel.org/vger-lists.html#cpufreq * http://vger.kernel.org/vger-lists.html#linux-pm
Clock and voltage scaling for the SA-1100: Clock and voltage scaling for the SA-1100:
* http://www.lartmaker.nl/projects/scaling * http://www.lartmaker.nl/projects/scaling
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
Contents: Contents:
--------- ---------
1. Supported Architectures and Processors 1. Supported Architectures and Processors
1.1 ARM 1.1 ARM and ARM64
1.2 x86 1.2 x86
1.3 sparc64 1.3 sparc64
1.4 ppc 1.4 ppc
...@@ -37,16 +37,10 @@ Contents: ...@@ -37,16 +37,10 @@ Contents:
1. Supported Architectures and Processors 1. Supported Architectures and Processors
========================================= =========================================
1.1 ARM 1.1 ARM and ARM64
------- -----------------
The following ARM processors are supported by cpufreq:
ARM Integrator
ARM-SA1100
ARM-SA1110
Intel PXA
Almost all ARM and ARM64 platforms support CPU frequency scaling.
1.2 x86 1.2 x86
------- -------
...@@ -69,6 +63,7 @@ Transmeta Crusoe ...@@ -69,6 +63,7 @@ Transmeta Crusoe
Transmeta Efficeon Transmeta Efficeon
VIA Cyrix 3 / C3 VIA Cyrix 3 / C3
various processors on some ACPI 2.0-compatible systems [*] various processors on some ACPI 2.0-compatible systems [*]
And many more
[*] Only if "ACPI Processor Performance States" are available [*] Only if "ACPI Processor Performance States" are available
to the ACPI<->BIOS interface. to the ACPI<->BIOS interface.
...@@ -147,10 +142,19 @@ mounted it at /sys, the cpufreq interface is located in a subdirectory ...@@ -147,10 +142,19 @@ mounted it at /sys, the cpufreq interface is located in a subdirectory
"cpufreq" within the cpu-device directory "cpufreq" within the cpu-device directory
(e.g. /sys/devices/system/cpu/cpu0/cpufreq/ for the first CPU). (e.g. /sys/devices/system/cpu/cpu0/cpufreq/ for the first CPU).
affected_cpus : List of Online CPUs that require software
coordination of frequency.
cpuinfo_cur_freq : Current frequency of the CPU as obtained from
the hardware, in KHz. This is the frequency
the CPU actually runs at.
cpuinfo_min_freq : this file shows the minimum operating cpuinfo_min_freq : this file shows the minimum operating
frequency the processor can run at(in kHz) frequency the processor can run at(in kHz)
cpuinfo_max_freq : this file shows the maximum operating cpuinfo_max_freq : this file shows the maximum operating
frequency the processor can run at(in kHz) frequency the processor can run at(in kHz)
cpuinfo_transition_latency The time it takes on this CPU to cpuinfo_transition_latency The time it takes on this CPU to
switch between two frequencies in nano switch between two frequencies in nano
seconds. If unknown or known to be seconds. If unknown or known to be
...@@ -163,25 +167,30 @@ cpuinfo_transition_latency The time it takes on this CPU to ...@@ -163,25 +167,30 @@ cpuinfo_transition_latency The time it takes on this CPU to
userspace daemon. Make sure to not userspace daemon. Make sure to not
switch the frequency too often switch the frequency too often
resulting in performance loss. resulting in performance loss.
scaling_driver : this file shows what cpufreq driver is
used to set the frequency on this CPU related_cpus : List of Online + Offline CPUs that need software
coordination of frequency.
scaling_available_frequencies : List of available frequencies, in KHz.
scaling_available_governors : this file shows the CPUfreq governors scaling_available_governors : this file shows the CPUfreq governors
available in this kernel. You can see the available in this kernel. You can see the
currently activated governor in currently activated governor in
scaling_cur_freq : Current frequency of the CPU as determined by
the governor and cpufreq core, in KHz. This is
the frequency the kernel thinks the CPU runs
at.
scaling_driver : this file shows what cpufreq driver is
used to set the frequency on this CPU
scaling_governor, and by "echoing" the name of another scaling_governor, and by "echoing" the name of another
governor you can change it. Please note governor you can change it. Please note
that some governors won't load - they only that some governors won't load - they only
work on some specific architectures or work on some specific architectures or
processors. processors.
cpuinfo_cur_freq : Current frequency of the CPU as obtained from
the hardware, in KHz. This is the frequency
the CPU actually runs at.
scaling_available_frequencies : List of available frequencies, in KHz.
scaling_min_freq and scaling_min_freq and
scaling_max_freq show the current "policy limits" (in scaling_max_freq show the current "policy limits" (in
kHz). By echoing new values into these kHz). By echoing new values into these
...@@ -190,16 +199,11 @@ scaling_max_freq show the current "policy limits" (in ...@@ -190,16 +199,11 @@ scaling_max_freq show the current "policy limits" (in
first set scaling_max_freq, then first set scaling_max_freq, then
scaling_min_freq. scaling_min_freq.
affected_cpus : List of Online CPUs that require software scaling_setspeed This can be read to get the currently programmed
coordination of frequency. value by the governor. This can be written to
change the current frequency for a group of
related_cpus : List of Online + Offline CPUs that need software CPUs, represented by a policy. This is supported
coordination of frequency. currently only by the userspace governor.
scaling_cur_freq : Current frequency of the CPU as determined by
the governor and cpufreq core, in KHz. This is
the frequency the kernel thinks the CPU runs
at.
bios_limit : If the BIOS tells the OS to limit a CPU to bios_limit : If the BIOS tells the OS to limit a CPU to
lower frequencies, the user can read out the lower frequencies, the user can read out the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment