aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/cpu-freq/governors.txt
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /Documentation/cpu-freq/governors.txt
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'Documentation/cpu-freq/governors.txt')
-rw-r--r--Documentation/cpu-freq/governors.txt155
1 files changed, 155 insertions, 0 deletions
diff --git a/Documentation/cpu-freq/governors.txt b/Documentation/cpu-freq/governors.txt
new file mode 100644
index 000000000000..b85481acd0ca
--- /dev/null
+++ b/Documentation/cpu-freq/governors.txt
@@ -0,0 +1,155 @@
1 CPU frequency and voltage scaling code in the Linux(TM) kernel
2
3
4 L i n u x C P U F r e q
5
6 C P U F r e q G o v e r n o r s
7
8 - information for users and developers -
9
10
11 Dominik Brodowski <linux@brodo.de>
12
13
14
15 Clock scaling allows you to change the clock speed of the CPUs on the
16 fly. This is a nice method to save battery power, because the lower
17 the clock speed, the less power the CPU consumes.
18
19
20Contents:
21---------
221. What is a CPUFreq Governor?
23
242. Governors In the Linux Kernel
252.1 Performance
262.2 Powersave
272.3 Userspace
28
293. The Governor Interface in the CPUfreq Core
30
31
32
331. What Is A CPUFreq Governor?
34==============================
35
36Most cpufreq drivers (in fact, all except one, longrun) or even most
37cpu frequency scaling algorithms only offer the CPU to be set to one
38frequency. In order to offer dynamic frequency scaling, the cpufreq
39core must be able to tell these drivers of a "target frequency". So
40these specific drivers will be transformed to offer a "->target"
41call instead of the existing "->setpolicy" call. For "longrun", all
42stays the same, though.
43
44How to decide what frequency within the CPUfreq policy should be used?
45That's done using "cpufreq governors". Two are already in this patch
46-- they're the already existing "powersave" and "performance" which
47set the frequency statically to the lowest or highest frequency,
48respectively. At least two more such governors will be ready for
49addition in the near future, but likely many more as there are various
50different theories and models about dynamic frequency scaling
51around. Using such a generic interface as cpufreq offers to scaling
52governors, these can be tested extensively, and the best one can be
53selected for each specific use.
54
55Basically, it's the following flow graph:
56
57CPU can be set to switch independetly | CPU can only be set
58 within specific "limits" | to specific frequencies
59
60 "CPUfreq policy"
61 consists of frequency limits (policy->{min,max})
62 and CPUfreq governor to be used
63 / \
64 / \
65 / the cpufreq governor decides
66 / (dynamically or statically)
67 / what target_freq to set within
68 / the limits of policy->{min,max}
69 / \
70 / \
71 Using the ->setpolicy call, Using the ->target call,
72 the limits and the the frequency closest
73 "policy" is set. to target_freq is set.
74 It is assured that it
75 is within policy->{min,max}
76
77
782. Governors In the Linux Kernel
79================================
80
812.1 Performance
82---------------
83
84The CPUfreq governor "performance" sets the CPU statically to the
85highest frequency within the borders of scaling_min_freq and
86scaling_max_freq.
87
88
892.1 Powersave
90-------------
91
92The CPUfreq governor "powersave" sets the CPU statically to the
93lowest frequency within the borders of scaling_min_freq and
94scaling_max_freq.
95
96
972.2 Userspace
98-------------
99
100The CPUfreq governor "userspace" allows the user, or any userspace
101program running with UID "root", to set the CPU to a specific frequency
102by making a sysfs file "scaling_setspeed" available in the CPU-device
103directory.
104
105
106
1073. The Governor Interface in the CPUfreq Core
108=============================================
109
110A new governor must register itself with the CPUfreq core using
111"cpufreq_register_governor". The struct cpufreq_governor, which has to
112be passed to that function, must contain the following values:
113
114governor->name - A unique name for this governor
115governor->governor - The governor callback function
116governor->owner - .THIS_MODULE for the governor module (if
117 appropriate)
118
119The governor->governor callback is called with the current (or to-be-set)
120cpufreq_policy struct for that CPU, and an unsigned int event. The
121following events are currently defined:
122
123CPUFREQ_GOV_START: This governor shall start its duty for the CPU
124 policy->cpu
125CPUFREQ_GOV_STOP: This governor shall end its duty for the CPU
126 policy->cpu
127CPUFREQ_GOV_LIMITS: The limits for CPU policy->cpu have changed to
128 policy->min and policy->max.
129
130If you need other "events" externally of your driver, _only_ use the
131cpufreq_governor_l(unsigned int cpu, unsigned int event) call to the
132CPUfreq core to ensure proper locking.
133
134
135The CPUfreq governor may call the CPU processor driver using one of
136these two functions:
137
138int cpufreq_driver_target(struct cpufreq_policy *policy,
139 unsigned int target_freq,
140 unsigned int relation);
141
142int __cpufreq_driver_target(struct cpufreq_policy *policy,
143 unsigned int target_freq,
144 unsigned int relation);
145
146target_freq must be within policy->min and policy->max, of course.
147What's the difference between these two functions? When your governor
148still is in a direct code path of a call to governor->governor, the
149per-CPU cpufreq lock is still held in the cpufreq core, and there's
150no need to lock it again (in fact, this would cause a deadlock). So
151use __cpufreq_driver_target only in these cases. In all other cases
152(for example, when there's a "daemonized" function that wakes up
153every second), use cpufreq_driver_target to lock the cpufreq per-CPU
154lock before the command is passed to the cpufreq processor driver.
155