# Cpufreqd malfunctions / any alternative program?

## ernov

When started manually cpufreqd shows following error:

```
cpufreqd -D

get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT0/current_now (No such file or directory)

acpi_battery_init        : Couldn't open BAT0 attributes

get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT0/current_now (No such file or directory)

acpi_battery_init        : Couldn't open BAT0 attributes
```

When started via init script it even causes buffer overflow:

```
/etc/init.d/cpufreqd restart

cpufreqd                  | * Caching service dependencies ...                                                     [ ok ]

cpufreqd                  | * Starting CPU Frequency Daemon ...

cpufreqd                  |*** buffer overflow detected ***: /usr/sbin/cpufreqd terminated

cpufreqd                  |======= Backtrace: =========

cpufreqd                  |/lib/libc.so.6(__fortify_fail+0x50)[0xb7822640]

cpufreqd                  |/lib/libc.so.6(+0xe35ca)[0xb78205ca]

cpufreqd                  |/lib/libc.so.6(+0xe3d38)[0xb7820d38]

cpufreqd                  |/usr/sbin/cpufreqd(main+0x844)[0x804b324]

cpufreqd                  |/lib/libc.so.6(__libc_start_main+0xe6)[0xb7753cc6]

cpufreqd                  |/usr/sbin/cpufreqd[0x804a441]

cpufreqd                  |======= Memory map: ========

cpufreqd                  |08048000-08052000 r-xp 00000000 08:01 131560     /usr/sbin/cpufreqd

cpufreqd                  |08052000-08053000 r--p 00009000 08:01 131560     /usr/sbin/cpufreqd

cpufreqd                  |08053000-08054000 rw-p 0000a000 08:01 131560     /usr/sbin/cpufreqd

cpufreqd                  |08bf3000-08c14000 rw-p 00000000 00:00 0          [heap]

cpufreqd                  |b7720000-b7739000 r-xp 00000000 08:01 269278     /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/libgcc_s.so.1

cpufreqd                  |b7739000-b773a000 r--p 00018000 08:01 269278     /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/libgcc_s.so.1

cpufreqd                  |b773a000-b773b000 rw-p 00019000 08:01 269278     /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/libgcc_s.so.1

cpufreqd                  |b773b000-b773d000 rw-p 00000000 00:00 0

cpufreqd                  |b773d000-b7895000 r-xp 00000000 08:01 74419      /lib/libc-2.12.2.so

cpufreqd                  |b7895000-b7896000 ---p 00158000 08:01 74419      /lib/libc-2.12.2.so

cpufreqd                  |b7896000-b7898000 r--p 00158000 08:01 74419      /lib/libc-2.12.2.so

cpufreqd                  |b7898000-b7899000 rw-p 0015a000 08:01 74419      /lib/libc-2.12.2.so

cpufreqd                  |b7899000-b789c000 rw-p 00000000 00:00 0

cpufreqd                  |b789c000-b78a0000 r-xp 00000000 08:01 267470     /usr/lib/libcpufreq.so.0.0.0

cpufreqd                  |b78a0000-b78a1000 r--p 00003000 08:01 267470     /usr/lib/libcpufreq.so.0.0.0

cpufreqd                  |b78a1000-b78a2000 rw-p 00004000 08:01 267470     /usr/lib/libcpufreq.so.0.0.0

cpufreqd                  |b78a2000-b78a4000 r-xp 00000000 08:01 74404      /lib/libdl-2.12.2.so

cpufreqd                  |b78a4000-b78a5000 r--p 00001000 08:01 74404      /lib/libdl-2.12.2.so

cpufreqd                  |b78a5000-b78a6000 rw-p 00002000 08:01 74404      /lib/libdl-2.12.2.so

cpufreqd                  |b78b7000-b78b8000 rw-p 00000000 00:00 0

cpufreqd                  |b78b8000-b78b9000 r-xp 00000000 00:00 0          [vdso]

cpufreqd                  |b78b9000-b78d5000 r-xp 00000000 08:01 74483      /lib/ld-2.12.2.so

cpufreqd                  |b78d5000-b78d6000 r--p 0001b000 08:01 74483      /lib/ld-2.12.2.so

cpufreqd                  |b78d6000-b78d7000 rw-p 0001c000 08:01 74483      /lib/ld-2.12.2.so

cpufreqd                  |bfeca000-bfeeb000 rw-p 00000000 00:00 0          [stack]

cpufreqd                  | * start-stop-daemon: failed to start `/usr/sbin/cpufreqd'                                    [ !! ]qd                  |

cpufreqd                  | * ERROR: cpufreqd failed to start
```

I can't understand it as it was working fine some time before.

Any clues?

Perhaps there is another deamon which could simply control CPU frequency depending on AC/DC state?

----------

## Sadako

It depends on what you want, but it should be quite possible to do with just the acpid daemon and the in-kernel cpufreq governors.

What exactly do you have cpufreqd configured to do currently?

----------

## ernov

Very simple: http://pastebin.com/0h6JKWff .

I'll check acpi scripts.

----------

## ppurka

You can use laptop-mode-tools to configure your cpu frequencies, and a lot more other stuff.

----------

## ernov

Laptop-mode-tools is what I'd like to avoid for its bloat.

I've made some simple acpi configuration and it seems to work:

```
cat /etc/acpi/events/ac_on

event=ac_adapter AC 00000080 00000001

action=/etc/acpi/actions/ac_on

cat /etc/acpi/actions/ac_on

#!/bin/bash

/usr/bin/cpufreq-set -g ondemand

cat /etc/acpi/events/ac_off

event=ac_adapter AC 00000080 00000000

action=/etc/acpi/actions/ac_off

cat /etc/acpi/actions/ac_off

#!/bin/bash

/usr/bin/cpufreq-set -g powersave
```

I'd appreciate any clues of how to improve it. In particular I'd like to know what to do with "unhandled acpi events" which appear in /var/log/messages:

```
Jan 29 11:06:14 carbo logger: ACPI event unhandled: ac_adapter AC 00000080 00000000                                      

Jan 29 11:06:14 carbo logger: ACPI event unhandled: processor CPU0 00000081 00000000                                     

Jan 29 11:06:14 carbo logger: ACPI event unhandled: processor CPU1 00000081 00000000                                     

Jan 29 11:06:14 carbo logger: ACPI event unhandled: thermal_zone THM0 00000081 00000000                                  

Jan 29 11:06:14 carbo logger: ACPI event unhandled: battery BAT0 00000080 00000001                                       

Jan 29 11:06:17 carbo logger: ACPI event unhandled: ac_adapter AC 00000080 00000001                                      

Jan 29 11:06:17 carbo logger: ACPI event unhandled: processor CPU0 00000081 00000000                                     

Jan 29 11:06:17 carbo logger: ACPI event unhandled: processor CPU1 00000081 00000000                                     

Jan 29 11:06:17 carbo logger: ACPI event unhandled: thermal_zone THM0 00000081 00000000                                  

Jan 29 11:06:17 carbo logger: ACPI event unhandled: battery BAT0 00000080 00000001
```

----------

