You are viewing hughsient

Technical Blog of Richard Hughes - CPU Frequency Scaling (post 2-16)

Richard Hughes
Date: 2006-08-20 22:32
Subject: CPU Frequency Scaling (post 2-16)
Security: Public
Today I've released 2.15.92 which is the last test release before 2.16.0 is released. I'm amazed at the work people have done in the last few weeks to make gnome-power-manager ready for the 2.16.0 release.
Now I've been banned (thanks to the string freeze) making large changes and adding functionality, I've been thinking about functionality to add post 2-16.
I get an email or bugzilla every few weeks asking about CPU frequency scaling, and how to add support into g-p-m. Traditionally the CPU frequency has been changed by system daemons such as cpufreqd (there are a lot more to choose from) which require editing odd files in /etc and are not new-user friendly. Holger Macht has written a addon to control this using HAL, so system and session software can control CPU frequency scaling in an easy, and architecture neutral way.

Maybe this is too much detail for the average user, but the feedback I've been getting is that users are screaming for cpufreq support in g-p-m.
The question is how to expose the options, given that there is are a large number of permutations of governers and working options for any given laptop.
My initial reaction was to hide the "use low power mode" checkbox to do scaling, but some computers scale better than others, and some just dont work in some modes, but do others. So it's got to be exposed in the UI.

So far, all the possible options (assuming you have all the governers installed) are:

#define CPUFREQ_ONDEMAND_TEXT           _("Based on processor load")
#define CPUFREQ_CONSERVATIVE_TEXT       _("Automatic power saving")
#define CPUFREQ_POWERSAVE_TEXT          _("Maximum power saving")
#define CPUFREQ_USERSPACE_TEXT          _("Custom")
#define CPUFREQ_PERFORMANCE_TEXT        _("Maximum performance")
#define CPUFREQ_NOTHING_TEXT            _("Do nothing")

With "Computer processor policy:" as the prefix. New names and descriptions
welcome.

Tell me what you think.
Post A Comment | 24 Comments | Add to Memories | Share | Link



User: (Anonymous)
Date: 2006-08-20 22:18 (UTC)
Subject: ONDEMAND and CONSERVATIVE
The user friendly descriptions of "Based on processor load" and "Automatic power saving" are a bit ambiguous to me. They read like they are almost the same thing to me, not sure how I'd pick a policy based on it. After reading the descriptions of on demand and conservative, I'm not sure how I'd condense them down to a few words.
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 07:48 (UTC)
Subject: Re: ONDEMAND and CONSERVATIVE
They are basically the same. I've patched the help file with long descriptions of how they differ (basically the latency), but the reason we have to include both is that conservative is only on very recent kernels, and ondemand makes some laptops very sluggish.
Richard.
Reply | Parent | Thread | Link



aigarius
User: aigarius
Date: 2006-08-20 22:22 (UTC)
Subject: (no subject)
I think that controlling processor frequency from g-p-m is a very nice idea. I would also love to see some another policy configurable for lid-closed mode. Defaults to: powersave on battery, ondemand for ac and conservative for lid-closed mode.
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-20 22:28 (UTC)
Subject: Clarification
Just to clarify, is cpufreq support post-2-16 material or not?
cpufreq support seems very nice and it's definitely within the scope of a power manager. Thanks for working on this :-)
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 07:47 (UTC)
Subject: Re: Clarification
Ohh yes, this is post 2-16 due to all the feature and string freezes. Nothing is in CVS yet.
Richard.
Reply | Parent | Thread | Link



User: (Anonymous)
Date: 2006-08-20 23:04 (UTC)
Subject: (no subject)
What does the "prefer power savings over performance" checkbox do? It looks to me as if it offers the same choice as choosing the CPU frequency policy between maximum power savings and maximum performance.
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 07:50 (UTC)
Subject: (no subject)
I need to reword this. The checkbox enables and disables the HAL low power mode, that currently just enables and disables laptop mode (and potentially other stuff too) using pm-utils. It doesn't do much yet.
Richard.
Reply | Parent | Thread | Link



User: (Anonymous)
Date: 2006-08-20 23:09 (UTC)
Subject: Confusing option
I'm confused by two options that look like the same thing: "Maximum performance" (in a popup menu) and "Prefer power savings over performance" (in a checkbox).

At first, I was going to say that the latter was confusing: instead of checkboxes of the form "Prefer A over B", why not use two radio buttons, or a popup menu? And then I noticed what appears to be a popup menu with exactly that. :-)

Other than that, looks pretty good.
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 02:20 (UTC)
Subject: CPUFreq_Applet?
How will this relate to the existing CPUFreq_Applet in gnome-applets? (Quick overview: it displays and lets you choose frequency and governor, but doesn't react to events.)

Sometimes you want to kick the CPU up to full power even when running on battery (playing a game, say), or underclock it to make it cooler and shut the fan up (though, that could be a setting in g-p-m: keep fan speed below ####RPM and it underclocks the CPU etc. to try for that target...)

I guess it relates to the brightness, but you can *see* the screen brightness, and laptops have brightness controls; not so for CPU scaling. Some sort of display/control would be useful, even if it's just to integrate the CPUFreq_Applet better.
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 07:55 (UTC)
Subject: Re: CPUFreq_Applet?
To be honest, I'm not sure. I'm not sure how a setuid applet poking in sysfs and a HAL addon, also poking in sysfs are going to co-exist (*should* be okay, unless the applet does crazy things). I'm guessing the applet will have to be changed so it uses the HAL DBUS interface, in which case the the applet and g-p-m should happily coexist.

>Some sort of display/control would be useful
What about a mention in the tooltip of g-p-m:

"Processor running at 50% performance"

But, again probably the solution is to patch the cpu-freq-applet to use HAL and then stuff should "just work".
Richard.
Reply | Parent | Thread | Link



User: (Anonymous)
Date: 2006-08-21 02:23 (UTC)
Subject: language
It would be nicer to use some less jargon-ish language too, for example "Processor performance" or "Processor speed" rather than "frequency" which many people may not grasp ("Huh? I don't know how frequent my processor is?").

The label "Computer processor policy" confuses me more than it clarifies, I'd say leave it out and just use the header as the label.

cheers and well done!

-matt
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 03:40 (UTC)
Subject: I love it!
That looks perfect! The brightness and governor controlled in an easy way and integrated into HAL :D
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 07:58 (UTC)
Subject: Re: I love it!
Thanks! I was hesitant to add support for cpu frequency scaling, but given that it can reduce the power consumption of a laptop by about half, that gave me reason enough! With a HAL addon written for me, I only had to add a couple of hundred lines of C to g-p-m.
Richard.
Reply | Parent | Thread | Link



User: (Anonymous)
Date: 2006-08-21 06:39 (UTC)
Subject: Think of hardcore users too
A really nice thing you've got there!

But I don't really understand the "translated strings" on the right side. Please at least add the module name at the end of that string so we who are doing this daily from the command line understand too what does what (ondemand, conservative, userspace). I think it's important because I for one have been testing all of these modules to death, and after long comparsions, I found that none of these make sense for my laptop except conservative (it's the fastest, best, coolest, fanlessest etc). Ondemant and userspace are doing some scaling as they wish, pushing the CPU up without no obvious reason. Stating again: for this laptop. So saving us the time to run those tests again and needing to remember which user-friendly-string means which module, just append it's name like: "Automatic (conservative)" or something.

Thanks and keep the cool stuff coming in :)
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 08:02 (UTC)
Subject: Re: Think of hardcore users too
>But I don't really understand the "translated strings" on the right side

There's the kernel names in the help file, with also a full explanation of how they differ and any special notes that I saw fit.

I don't think kernel names like userspace and ondemand belong in the UI, as they would likely be translated and confuse people still further.

And, you are right, if you have a modern enough computer (with enhanced speedstep) conservative rocks. :-)
Richard.
Reply | Parent | Thread | Link



User: (Anonymous)
Date: 2006-08-24 09:38 (UTC)
Subject: Re: Think of hardcore users too
The help file is really too far away, can it be a tooltip? Please? :)
Okay if not then we should upgrade those strings:

For me the strings are really confusing:

-Based on CPU load
-Automatic power saving

Not much difference there. The 1st one seems pretty automatic for me too. I really could not decide there.

-custom

Where do I change the freq afterwards? Does a new dropdown appear to choose the speed from? Or did I miss something?

One more thing:

The caption says: Processor Freq
Then there's a label "computer processor freq:"
For me the word "computer" doesn't fit in there. We are configuring the computer so it's clear I think. Less words are more when you make users choose things they are not familiar with anyway.

I'd advise the following:
caption: "Processor (CPU)" /* maybe one day you will add GPU as a new caption too */
label1: "Policy" or "Scaling Policy" /* You don't need more right there, you are already inside the CPU configuration under the caption */
label2: "Custom speed: " /* This is the dropdown that appeares only when you select the custom-policy */

Hope you get my point, have fun hacking on it anyway!
Reply | Parent | Thread | Link



User: (Anonymous)
Date: 2006-08-24 12:06 (UTC)
Subject: Re: Think of hardcore users too
>Not much difference there.

Agreed, I'm thinking of hiding ondemand if conservative is available.

>Where do I change the freq afterwards? Does a new dropdown appear

Yes, a new slider appears. Try CVS head for g-p-m and HAL and you'll get a sneak preview.

Richard.
Reply | Parent | Thread | Link



User: (Anonymous)
Date: 2006-08-24 12:24 (UTC)
Subject: Re: Think of hardcore users too
>Agreed, I'm thinking of hiding ondemand if conservative is available.

That would be hiding a feature from a user which he has the hardware for. Not sure that's the best we can do.

Didn't think a lot about it but, maybe we could just call it "automatic" in the dropdown, then have radiobuttons next to it so user can choose from "ondemand" or "conservative", whichever he _wants_ to use/try/whatever. If there's no choice, then only 1 radiobutton should be there. Just an idea.

Let's not hide something that could be of use to someone (even if conservative is all I need, it gives me instant freq changes anytime)

rock on
Reply | Parent | Thread | Link



Richard
User: fluffyrichard
Date: 2006-08-21 08:27 (UTC)
Subject: (no subject)
It may just be me, but I find "maximum performance" ambiguous. Does it mean "maximum speed", or "maximum power efficiency"? I'm guessing from the context that it means "maximum speed", but I'm really not certain. If it does just mean maximum speed, it would be better to say that.
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 09:12 (UTC)
Subject: (no subject)
Agreed, thanks for the feedback.
Richard
Reply | Parent | Thread | Link



User: (Anonymous)
Date: 2006-08-21 10:14 (UTC)
Subject: GNOME user
Thanks Richard, this will totally rock...
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 10:38 (UTC)
Subject: Most of those alternatives are superfluous
I know how tempting it is to include all the possible alternatives, but I have yet to see a convincing argument for most of them.

Basically, ever since Ondemand governor got introduced to the kernel, it's very difficult to see the point of any other system, except for combinations where it doesn't work (it's not compatible with all CPU architectures - I have an Athlon XP where it refuses to register). Conservative is just a lower-response-rate version of ondemand, and thus should really be eliminated by the kernel people by tuning ondemand - I don't really understand why it was introduced (yes, I know what the technical between them difference is)

Performance makes sense in those limited circumstances where a) ondemand doesn't work at all or b) sub-second performance fluctuations are undesirable (near-realtime processing of video and audio, gaming to a small degree (most high performance games would keep the CPU at full speed all the time even under ondemand governor, though).

Powersave is not -- in circumstances where ondemand would hike up CPU frequency, that is the power saving policy because it permits the CPU-hungry job to finish faster. The CPU is not the only energy sink in the system - a laptop backlight is just as significant. It's possible to create contrived examples of how heat management might make the powersave policy the best one under some circumstances, but even then it should be automatically chosen by the system, not a static user-set policy.

Userspace is a hold-out from the era of no kernel-side ondemand governors, and Nothing is from the user's standpoint equal to Performance (or to Powersave for some particularly dumb computers). These are thus compatibility options for bad hard/firmware, and should be under advanced settings.

The way to keep the UI simple is thus to have only two choices: "Conserve power when system is idle" and "Run at maximum speed at the cost of power and heat".

This post shows how ondemand is practically equivalent to performance for a typical desktop task: http://martin.ankerl.org/2006/08/16/how-to-make-firefox-40-percent-faster/

-- osma http://www.fishpool.org/osma/
Reply | Thread | Link



User: (Anonymous)
Date: 2006-08-21 12:02 (UTC)
Subject: Re: Most of those alternatives are superfluous
>Conservative is just a lower-response-rate version of ondemand

Yes, but it keeps the CPU high for longer and "works better" for some type of usage. (My own included)

>a laptop backlight is just as significant

Hence why we also let the user change this in the UI. I know lots of preferences is generally a bad thing in GNOME, but we do need to give the users some room to move. 20% brightness to me is nearly dark on my Toshiba, but quite bright on my iBook.

>Userspace is a hold-out from the era of no kernel-side ondemand governors

Agreed, but I have a machine that only supports userspace, and I'm guessing quite a few other people will have the same.

>The way to keep the UI simple is thus to have only two choices: "Conserve power when system is idle" and "Run at maximum speed at the cost of power and heat".

I agree, in an ideal world this could be done. Unfortunatly, due to the range of user-visible bugs we have to work around, I don't think we can generalise as much as this. MacOSX has something similar, but the hardware is made by them, to some sort of specification (which is quite unlike ACPI).

>Nothing is from the user's standpoint equal to Performance

Not when you have another daemon controlling cpu scaling, as some users *will* want to do. "Do Nothing" means "Completely ignore anything that happens with cpufreq, something else is handling what should happen" :-)

Thanks for your feedback, feel free to comment again to what I've said here as I think this is the best way to get the best solution.

Thanks, Richard.
Reply | Parent | Thread | Link



User: (Anonymous)
Date: 2006-08-21 22:11 (UTC)
Subject: Makes Sense
As CPU frequency scaling directly affects power management, integrating it into GPM just makes sense. Your mockup above looks good, and I think it meets the spirit of the HIG just fine. Go for it!
Reply | Thread | Link



browse
my journal
April 2008