You are not logged in.

#1 2011-08-09 09:10:09

Calamulus
Member
Registered: 2011-08-07
Posts: 6

[Solved]How does the ondemand governor work?

Greetings!

This question comes mainly from the information on the wiki. It has stated for as long as I can remember the following:

cpufreq_ondemand: Dynamically switches between the CPU(s) available clock speeds based on system load

It would appear to indicate that the CPU scales through all of the frequencies available one at a time, however, on my Core2Duo T7300 it will only cycle between the lowest setting 800Mhz, and the highest of 2Ghz when using ondemand. It will never spend any considerable time in the intermediate frequencies. In fact, after running powertop (and conky, and watch(ing) cpuinfo_cur_freq) for a period of regular use, it reports that the middle frequencies are collectively used less than 1% of the time, which would indicate that it only uses them as "stepping stones" when upscaling to it's maximum frequency. So, intrigued I tried the conservative governor and googled for documentation.

Every online doc I found about the kernel cpufreq governors states that ondemand uses only the lowest frequency while Idle, and cycles up to the highest speed when up_threshold is breached, for example (double check on the "conservative" sections which clarify the differences between the two):
http://www.kernel.org/doc/Documentation … ernors.txt
http://docs.redhat.com/docs/en-US/Red_H … rnors.html
http://en.gentoo-wiki.com/wiki/CPU_Frequency_Scaling

I'd assume Arch's governor works as stated there as the kernel is vanilla, but I'm looking for clarification/confirmation since after my experiments and googling for docs I updated the wiki in an effort to improve it, but the change was unmade due to wrong information and I wouldn't want to start some kind of edit war. Would it be enough to cite the above docs in the wiki's summary for the edit as reference?

Thanks in advance and apologies if this is in the wrong place.

Last edited by Calamulus (2011-08-09 19:00:21)

Offline

#2 2011-08-09 09:21:29

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [Solved]How does the ondemand governor work?

Most of the time the workload on your system is either very low/negligible, or high (when you actually want to get stuff done, even if it's for very brief moments in time), so it would seem logical that the two extremes are used the most. I think the other positions are more interesting for manually setting the threshold, since i can't think of many scenarios in which a dynamic governor would choose to run at 50% for a prolonged period?


ᶘ ᵒᴥᵒᶅ

Offline

#3 2011-08-09 09:58:15

Calamulus
Member
Registered: 2011-08-07
Posts: 6

Re: [Solved]How does the ondemand governor work?

litemotiv wrote:

Most of the time the workload on your system is either very low/negligible, or high (when you actually want to get stuff done, even if it's for very brief moments in time), so it would seem logical that the two extremes are used the most. I think the other positions are more interesting for manually setting the threshold, since i can't think of many scenarios in which a dynamic governor would choose to run at 50% for a prolonged period?

I completely agree; my confusion arises from the fact that the wiki has forever stated that the ondemand governor works like the conservative one by adjusting the frequency between all speeds available, when experimentation and docs point to it simply jumping back and forth between lowest and highest, ignoring those in between completely.

This can mislead users into thinking (like I did for about 3 years, if it turns out the wiki is mistaken) that by selecting ondemand they get the functionality that is actually offered by conservative instead.

Offline

#4 2011-08-09 10:02:39

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [Solved]How does the ondemand governor work?

I have seen my system use in-between frequencies, such as 1.2Ghz or 1.6Ghz, but usually only shortly. So i would think it does work as advertised, but there is simply little need for ondemand to stay at those frequencies for a longer timespan.


ᶘ ᵒᴥᵒᶅ

Offline

#5 2011-08-09 10:12:00

Gusar
Member
Registered: 2009-08-25
Posts: 3,606

Re: [Solved]How does the ondemand governor work?

Calamulus wrote:

I completely agree; my confusion arises from the fact that the wiki has forever stated that the ondemand governor works like the conservative one by adjusting the frequency between all speeds available

It does. But like litemotiv says, it only does so for brief moments. Because most of the time it's more beneficial to switch to highest freq, so the job is done as fast as possible, allowing to cpu to go to idle as soon as possible.

Calamulus wrote:

This can mislead users into thinking (like I did for about 3 years, if it turns out the wiki is mistaken) that by selecting ondemand they get the functionality that is actually offered by conservative instead.

It is the same functionality. It's just that ondemand is better at it. Conservative was only created for some buggy amd processors which had trouble with fast switching, so it shouldn't be used. Unless you have one of those old amd processors of course.

Offline

#6 2011-08-09 10:18:02

Calamulus
Member
Registered: 2011-08-07
Posts: 6

Re: [Solved]How does the ondemand governor work?

Uhm, so this paragraph in the Kernel docs is then incorrect?

2.5 Conservative
----------------

The CPUfreq governor "conservative", much like the "ondemand"
governor, sets the CPU depending on the current usage.  It differs in
behaviour in that it gracefully increases and decreases the CPU speed
rather than jumping to max speed the moment there is any load on the
CPU.

Offline

#7 2011-08-09 12:07:30

lukaszan
Member
Registered: 2011-05-05
Posts: 117

Re: [Solved]How does the ondemand governor work?

Calamulus wrote:

Uhm, so this paragraph in the Kernel docs is then incorrect?

2.5 Conservative
----------------

The CPUfreq governor "conservative", much like the "ondemand"
governor, sets the CPU depending on the current usage.  It differs in
behaviour in that it gracefully increases and decreases the CPU speed
rather than jumping to max speed the moment there is any load on the
CPU.

It's exactly as it says.

Ondemand will immediately increase the frequency to the required one. It doesn't necessarily have to be the highest, hence the intermediate steps are also used. As litemotiv said though, your pc usually is either idle or on load, so extremes will be used mostly.

Conservative will gradually increase frequency, even if the highest is required. Again, as Gusar said, this was due to first 64bit processors having massive switching delay.

Offline

#8 2011-08-09 12:41:00

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: [Solved]How does the ondemand governor work?

I monitor the speed steps in conky and it happens quite often, that the cpu uses steps between the lowest and the highest frequency, although, as said before, only for short moments. Don't worry, ondemand works! wink

Offline

#9 2011-08-09 16:47:40

Gusar
Member
Registered: 2009-08-25
Posts: 3,606

Re: [Solved]How does the ondemand governor work?

Monitoring with conky won't tell you much. Ondemand probably switches a lot to middle frequencies, but for such small periods of time that conky doesn't register it. We're talking about miliseconds here. Look instead into /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state.

Offline

#10 2011-08-09 19:00:03

Calamulus
Member
Registered: 2011-08-07
Posts: 6

Re: [Solved]How does the ondemand governor work?

Thanks for clarifying this. All the docs seemed as "max speed" referred to the maximum available on the CPU rather than the "maximum needed".

Offline

Board footer

Powered by FluxBB