# Toggling CPU throttling on running laptop

## srunni

Hi,

Does anyone know how I can manually toggle the CPU throttling on a laptop? Right now, it autothrottles to 800 MHz when AC power is not available, which is fine for the most part. However, there are cases where I'd rather it be running at the normal clock speed, even though it will drain the batteries faster. Is there a way to do this?

Also, is there a way to automatically toggle throttling when AC power is {dis,}connected? Right now, it won't change without a reboot.

Thanks in advance for the help!

----------

## Sadako

Are you using the kernel governors to control the cpu frequency (ie ondemand or conservative), or some userspace deamon?

If it's the former, then you can change the governor via echoing it to /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor, for example I have the following in my /root/.bash_profile;

```
alias ondemand="echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"

alias performance="echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"

alias powersave="echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
```

As for changing when AC power status changes, this is what you use acpid  for, it's easily doable with that, but I don't know how you'd do it if you're using hal instead...

----------

## srunni

 *Hopeless wrote:*   

> Are you using the kernel governors to control the cpu frequency (ie ondemand or conservative), or some userspace deamon?

 

```
# CPU Frequency scaling

#

CONFIG_CPU_FREQ=y

CONFIG_CPU_FREQ_TABLE=y

CONFIG_CPU_FREQ_DEBUG=y

# CONFIG_CPU_FREQ_STAT is not set

# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set

# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set

CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y

# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set

# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set

CONFIG_CPU_FREQ_GOV_PERFORMANCE=y

# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set

CONFIG_CPU_FREQ_GOV_USERSPACE=y

CONFIG_CPU_FREQ_GOV_ONDEMAND=y

# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
```

From my kernel .config, it appears that I'm using ``ONDEMAND''. Is the ``PERFORMANCE'' setting relevant as well?

 *Hopeless wrote:*   

> If it's the former, then you can change the governor via echoing it to /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor, for example I have the following in my /root/.bash_profile;
> 
> ```
> alias ondemand="echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
> 
> ...

 

```
nalyubuites ~ # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

userspace
```

Is this normal behavior?

Also, when I attempt to use your echo command, I get

```
bash: echo: write error: Invalid argument
```

When I edit the file with vi and try to save it, I get

```
"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" E667: Fsync failed
```

I don't have KLaptopDaemon running as far as I can tell (it's not in the KDE system tray), so it's probably not controlling the frequency (I'm running KDE 3.5). Is there some process I can look for to see if it's running? I checked for ``klaptopdaemon'', and that's not it.

Perhaps there are some other userspace daemons that could have been autoconfigured (i.e., without me knowing it happened)?

 *Hopeless wrote:*   

> As for changing when AC power status changes, this is what you use acpid  for, it's easily doable with that, but I don't know how you'd do it if you're using hal instead...

 I have acpid running by default (according to pgrep). Is that the program that reads settings from /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ?

----------

## Sadako

If the value of "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" is currently user, that means a userspace daemon is doing the work (or the cpu freq is static).

Such a daemon may even be what's preventing you from switching manually.

What does `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors` return?

As for acpid, open up /etc/acpi/default.sh and take a look at the ac_adapter section, you can just stick the relevant echo statements in there (once you get them working).

----------

## srunni

 *Hopeless wrote:*   

> What does `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors` return?

 

```
ondemand userspace performance
```

 *Hopeless wrote:*   

> As for acpid, open up /etc/acpi/default.sh and take a look at the ac_adapter section, you can just stick the relevant echo statements in there (once you get them working).

 I thought you placed them in /root/.bash_profile ?

----------

## Sadako

 *srunni wrote:*   

>  *Hopeless wrote:*   What does `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors` return? 
> 
> ```
> ondemand userspace performance
> ```
> ...

 Yes, I placed the aliases there, to manually change the governor on the cli, but in order to have the governor change automatically upon ac adapter status changes you should add the relevant echo statements to /etc/acpi/default.sh.

----------

## cwr

On my Thinkpad T23 I use "echo performance /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"

for high speed and and "echo powersave ... " for low speed.  You can do the same thing with ACPI if

you can work out how it's configured - I had it set up at one stage, and then lost it in an update.

Will

----------

