SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-12-08 02:41:45

Vicophine
#! Member
From: Detroit, MI
Registered: 2009-11-02
Posts: 98
Website

HOW-TO: CPU Scaling Debian

I was having an enormous amount of trouble with CPU scaling and governors in Linux until I read, and followed this guide: "http://technowizah.com/2007/01/debian-h … ement.html"

Think this will help some people out smile

Here it is:
CPU frequency management is one of the keys to power preservation.

The Linux kernel now provides all the necessary tools to properly manage CPU frequency : no need to use a daemon (like cpufreqd or powernowd) to take care of your CPU.

Of course the benefits of such power management are obvious for a laptop, but most desktop users should also consider this.

In this tutorial, I use sudo to get root privileges.


    Prerequisites



Debian Etch (and Sid) should automatically configure CPU frequency management on most processors that supports it, so it might very well be already enabled. You can verify if that is the case using this command :

cpufreq-info



and analyze the output regarding the current policy.

If CPU frequency management is off (or the command is not found), then you can go on with this tutorial.

In order to make this work, you need to install the required packages:

sudo apt-get install cpufrequtils sysfsutils



Next, verify your exact CPU model :

cat /proc/cpuinfo | grep "model name"



Which should output something like that :

model name      : Intel(R) Pentium(R) M processor 1.73GHz



Once you know your exact CPU type, the next step is to load the proper modules : the CPU frequency driver and the CPU frequency policy governor.


    CPU frequency driver



As you may guess the CPU frequency driver will differ depending on your type of CPU. For example, my laptop is equipped with a Pentium M, so I type :

sudo modprobe speedstep_centrino



to load the proper driver.

Some of the other common drivers (or modules) are :

AMD K6 processors : powernow_k6
AMD K7 processors (Athlon, Duron, Sempron 32 bits) : powernow_k7
AMD K8 processors (Athlon 64, Turion 64, Sempron 64, Opteron 64) : powernow_k8

Pentium 4, Celeron D, Pentium D, Celeron M : p4_clockmod
Pentium M, Core Duo, Core 2 Duo : speedstep_centrino

There are of course other CPU frequency drivers. In doubt, you can use the generic driver : acpi_cpufreq


    CPU policy governor



Once the proper driver is loaded, you need to choose the desired CPU policy governor. This policy governor will manage the actual behavior of your CPU. Here is some policy governors and their module names :

performance, which sets the CPU statically to the highest possible frequency : cpufreq_performance
powersave, which is the opposite, clocks the CPU statically to the lowest frequency : cpufreq_powersave
ondemand, which sets the CPU speed dynamically depending on the work load (ideal for desktops) : cpufreq_ondemand
conservative, which also sets the CPU dynamically, but less aggressively then the ondemand governor (ideal for laptops) : cpufreq_conservative

For example, my machine has a Pentium M processor, so I type :

sudo modprobe speedstep_centrino
sudo modprobe cpufreq_ondemand



to load both the CPU frequency driver and the CPU policy governor.


    CPU configuration



Once the modules are loaded, you need to configure the policy governor. For example, I use the ondemand governor, so :

echo ondemand | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor



will enable it.

You can verify that everything went well with this command :

cpufreq-info



It should output your actual frequency, as well as the governor presently in use.


    System configuration



If everything is good, then you can make this configuration permanent. First make sure the proper modules are loaded at startup (in /etc/modules).

So in my case :


echo speedstep_centrino | sudo tee -a /etc/modules
echo cpufreq_ondemand | sudo tee -a /etc/modules



Finally, ensure that the CPU uses your policy governor of choice by default. Simply edit the file /etc/sysfs.conf with a line like this one :

devices/system/cpu/cpu0/cpufreq/scaling_governor = ondemand



That's it !


Thinkpad x120e 8GB DDR3, 1.6Ghz X2 - Laptop/Netbook
AMD Athlon X2 OC'ed to 3.33GHz, 4GB DDR2 2TBx2 - Desktop/Seedbox

Offline

Be excellent to each other!

#2 2011-01-21 20:24:18

ej64
#! Member
From: somewhere in Germany
Registered: 2010-09-24
Posts: 64

Re: HOW-TO: CPU Scaling Debian

Thanks a lot for this tutorial.

After installing cpufrequtils and sysfsutils frequency scaling worked immediately with the ondemand governor. I changed it to conservative.

Just one remark for completeness:
if you have a multiprocessor system (dualcore, quadcore ...) like me, you don't have a single cpu device "cpu0" but also "cpu1" and so on. So, in this case there are some more lines to edit ...

Again, thank you
EJ


Thinkpad X220 with 1.gen Samsung SSD on #! Statler XFCE (unstable repos)

Offline

#3 2011-01-30 14:26:02

thissideup
Member
Registered: 2010-12-24
Posts: 15

Re: HOW-TO: CPU Scaling Debian

heya.

just wanted to add, that i had the same problem: cpu was running on highest freq.

but what helped me, wasnt quite that nice tutorial but simply running sensors-detect. once run, my cpu went down to the lowest possible freq. (which is, naively spoken, not much different to the manual steps of the tutorial, afaik..)

so i guess, running sensors-detect would be first advised to the tutorial, right?

in any case,
greetings, alex.

Offline

#4 2011-01-30 14:57:26

olembe
#! Junkie
From: Salisbury, England
Registered: 2009-04-29
Posts: 259

Re: HOW-TO: CPU Scaling Debian

Thank you - this was really useful for me.

Offline

#5 2011-01-30 16:35:59

iann
#! CrunchBanger
Registered: 2010-09-10
Posts: 225

Re: HOW-TO: CPU Scaling Debian

The speedstep-centrino module is deprecated (as of 2.6.30, I think) and its functionality is included in module acpi_cpufreq.  Despite being deprecated, speedstep-centrino.ko is still available in the latest kernel 2.6.37, subject to the build configuration.  I've seen comments that acpi_cpufreq doesn't work on some speedstep-capable processors but when it works it should work better.  It supports both enhanced speedstep and processor p-states.

There is an additional governer not mentioned so far: userspace.  It doesn't do anything for itself but does let you control the speedstep setting manually, using a daemon, or using another program.

The p4_clockmod module is not especially useful, which is why speedstep was invented I guess.  Details depend on your processor but most can't scale back the clock very much and just skipping clock cycles to save power is no different from what the CPU does anyway when it is idle.  Try it but examine carefully what you're actually getting.

Offline

#6 2012-02-04 15:43:22

lightning_underscore
Member
Registered: 2012-02-04
Posts: 13

Re: HOW-TO: CPU Scaling Debian

ej64 wrote:

Thanks a lot for this tutorial.

After installing cpufrequtils and sysfsutils frequency scaling worked immediately with the ondemand governor. I changed it to conservative.

Just one remark for completeness:
if you have a multiprocessor system (dualcore, quadcore ...) like me, you don't have a single cpu device "cpu0" but also "cpu1" and so on. So, in this case there are some more lines to edit ...

Again, thank you
EJ

Hello. I have the same situation.

I followed the tutorial, and it helped. The processor is more stable, less noise, usage remains below 50%, but I need some tips on enabling the second core. I'd like to use all the system has to offer. #! Is the best O-system I've found yet. Good f/s encryption, simple login, reasonably customizable, lots of software support. I just stopped using ubuntu-like distrobutions. (What you get in a painless install results in a sloppy/bloated OS *usually.)

nproc

tells me I've only one processor core, but I know from running full installation OS's like Ubuntu that nproc should output 2.

cat /proc/cpuinfo | grep "model name"
model name    : Intel(R) Pentium(R) 4 CPU 3.00GHz

another output for processor information

:/etc# cat /proc/cpuinfo
processor    : 0
vendor_id    : GenuineIntel
cpu family    : 15
model        : 2
model name    : Intel(R) Pentium(R) 4 CPU 3.00GHz
stepping    : 9
microcode    : 0x11
cpu MHz        : 3000.000
cache size    : 512 KB
fdiv_bug    : no
hlt_bug        : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 2
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs bts cid xtpr
bogomips    : 5939.65
clflush size    : 64
cache_alignment    : 128
address sizes    : 36 bits physical, 32 bits virtual
power management:

Any suggestions would be great. I will try to enable my second core like you said, but I'm unsure it will work.

Maybe it's cooked, who knows.

Offline

#7 2012-02-04 18:06:26

lightning_underscore
Member
Registered: 2012-02-04
Posts: 13

Re: HOW-TO: CPU Scaling Debian

Maybe it's to early, but I really hope to fix this so......

BUMP

Offline

#8 2012-02-04 19:14:38

xaos52
The Good Doctor
From: Planet of the @s
Registered: 2011-06-24
Posts: 4,275

Re: HOW-TO: CPU Scaling Debian

You have not mentioned what kernel version you are running, nor what architecture.
I guess it is 32-bit. #! installs a -486 kernel by default. You will have to upgrade your kernel to -686.
hth

Offline

#9 2012-02-04 19:48:33

lightning_underscore
Member
Registered: 2012-02-04
Posts: 13

Re: HOW-TO: CPU Scaling Debian

xaos52 wrote:

You have not mentioned what kernel version you are running, nor what architecture.
I guess it is 32-bit. #! installs a -486 kernel by default. You will have to upgrade your kernel to -686.
hth

Here is the output for

 uname -a

I am guessing you were right?

/proc# uname -a
Linux localhost 3.2.0-0.bpo.1-486 #1 Thu Jan 26 00:51:35 UTC 2012 i686 GNU/Linux

If I need to upgrade my architecture support, could you suggest how that is to be done.

Thanks a lot.

Last edited by lightning_underscore (2012-02-04 19:53:43)

Offline

#10 2012-02-04 19:54:35

lightning_underscore
Member
Registered: 2012-02-04
Posts: 13

Re: HOW-TO: CPU Scaling Debian

Impatience is my problem... (I find someone who can help, they go offline.)

BUMP

Offline

#11 2012-02-04 20:00:17

Unia
#! Die Hard
From: The Netherlands
Registered: 2010-07-17
Posts: 3,094

Re: HOW-TO: CPU Scaling Debian

Please, don't bump so much. Someone who knows the answer will come across this post wink


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
      Github || Deviantart

Offline

#12 2012-02-04 20:02:15

el_koraco
#!/loony/bun
From: inside Ed
Registered: 2011-07-25
Posts: 4,643

Re: HOW-TO: CPU Scaling Debian

Open Synaptic, find the package called linux-image-3.2.0-0.bpo.1-686-pae and linux-headers-3.2.0-0.bpo.1-686-pae. install, reboot, you're done.

Offline

#13 2012-02-04 20:30:16

lightning_underscore
Member
Registered: 2012-02-04
Posts: 13

Re: HOW-TO: CPU Scaling Debian

el_koraco wrote:

Open Synaptic, find the package called linux-image-3.2.0-0.bpo.1-686-pae and linux-headers-3.2.0-0.bpo.1-686-pae. install, reboot, you're done.

Hey thanks, but I figured it out..

I AM A MORON. JK tongue

Thanks for those who helped me figure that out.

Special thanks to eL Koraco

Last edited by lightning_underscore (2012-02-04 20:41:38)

Offline

#14 2013-01-22 01:41:48

ldapmonkey
New Member
From: Woodbridge, VA
Registered: 2013-01-20
Posts: 3

Re: HOW-TO: CPU Scaling Debian

Thanks for the tips and link. My I7 was chewing up power and making a whole lot of racket in the process. Since it's a multi-core I had to rinse-repeat and that got old so I did what any geek would do... bashed it.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo