Saturday, June 27, 2009

CPU Speed and performance on a Notebook with Linux.

After installed Fedora on my notebook, CPU Frequency was always on 50% of the nominated CPU frequency in my case 1.87 GHz but my CPU can go up to 3.2 GHz, that changed on demand as controlled by the kernel, and it did work fine for me how ever sometime launching programs like Eclipse it took to long to load even when the CPU speed when up to 100%, and notebooks are set this way to save energy when using the battery, but what if we want to have the CPU running at 100% when corrected to the electrical outlet and not using battery can we set it up, well this is Linux so there must be a way of doing this, and of course it can be done here goes how.

First we need to install this packages:

cpufrequtils
cpuspeed

also recomend to install

lm_sensors

To install those packages you can simple do:

yum install cpufrequtils cpuspeed lm_sensors

after installing those packages you will have some information about your CPU by typing cpufreq-info


Report errors and bugs to cpufreq@vger.kernel.org, please.

analyzing CPU 0:

driver: acpi-cpufreq

CPUs which need to switch frequency at the same time: 0

hardware limits: 1.87 GHz - 3.20 GHz

available frequency steps: 3.20 GHz, 2.93 GHz, 2.67 GHz, 2.40 GHz, 2.13 GHz, 1.87 GHz

available cpufreq governors: userspace, performance
,ondemand
current policy: frequency should be within 1.87 GHz and 3.20 GHz.

The governor "ondemand" may decide which speed to use

within this range.

current CPU frequency is 1.87 GHz.



This will show you what driver control your CPU frequency and the policy is set and the frequency it is working at the moment you run the command.

cpufreq-set -c 0 -f 3.20 GHz -g performance

where C is the CPU number
f is the frequency you want
g is the governor you are setting
Let check the change

cpufreq-info

Report errors and bugs to cpufreq@vger.kernel.org, please.

analyzing CPU 0:

driver: acpi-cpufreq

CPUs which need to switch frequency at the same time: 0

hardware limits: 1.87 GHz - 3.20 GHz

available frequency steps: 3.20 GHz, 2.93 GHz, 2.67 GHz, 2.40 GHz, 2.13 GHz, 1.87 GHz

available cpufreq governors: userspace, performance

current policy: frequency should be within 1.87 GHz and 3.20 GHz.

The governor "performance" may decide which speed to use

within this range.

current CPU frequency is 3.20 GHz.



Remember you need to do this set for each CPU if you have more that one CPU.

Of course this will set your CPU frequency for this session but what if you want to set your CPU to a 100% frequency every time you boot your notebook, then you need to use the cpuspeed service.

First we need to edit the cpuspeed configuration file that is at /etc/sysconfig/ , you can edit this file with vi or your favorite editor, you will need to change this line


GOVERNOR=

to

GOVERNOR=performance

this will set you CPU to full speed all the time, to change the way it behave when it is working with the battery look at the en of the file and uncommend the line


OPTS="$OPTS -a /proc/acpi/ac_adapter/*/state "

you can also uncomment this

# uncomment and modify this to check the state of the AC adapter

OPTS="$OPTS -a /proc/acpi/ac_adapter/*/state "



you may need to change this line to the location of your temperature file normally at acpi but it may vary depending on you system
# uncomment and modify this to check the system temperature

OPTS="$OPTS -t /proc/acpi/thermal_zone/temperature 65"


if you restart you system you will see your CPU frequency changes. Also if you added the CPU performance applet on you desktop you can see your changes.

You may need to read more on the way cpuspeed there are more settings there. Please use this information with care your and at your risk.

1 comment:

Aubrey Jaffer said...

Thanks for posting this. Hulu and YouTube were slide shows on my aging Fedora-11 Pentium-4 notebook (ZD7000).

A tweak, "if you restart you system you will see your CPU frequency changes." should be stronger:

You must restart your system to see the effects.