2014年3月27日木曜日

CPU frequency scaling

Raspbian fixes cpu frequency to 700MHz by default.
It would not be reasonable to keep max cpu freq for the usage which doesn't requires full cpu power at all times.

Following instruction explains how to custermize your raspberry pi to be lower cpu freq at idle.
@The effect seems to be less. So, please read this article with some technical interest:)
 

GPU setting
 

/boot/config.txt is read by GPU for hardware configuration before CPU is up. That includes the setting of cpu freq.
Please add following lines in the text.

# Meaningful word.. This means 'enable cpu freq scaling'
force_turbo=0
# Set lowest cpu freq. By default, it's 700.
arm_freq_min=100


Reboot is required to reflect them.

@Refer following page for more detailed information about config.txt.
http://elinux.org/RPiconfig

Linux kernel configuration
 

By GPU setting, cpu gets capability for freq scaling.
But, Linux kernel has its own mechanism to control it and default would fix cpu freq to 100MHz.

To check current/min/max cpu freq please use following commands on shell.

- Current cpu freq
# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
- Max cpu freq
# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_man_freq
- Min cpu freq
# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_mix_freq

Linux kernel has driver which manages cpu freq policy.
Following option is available for that. Rasbian set powersave by default.

performance  - always use max cpu freq
powersave    - always use min cpu freq
ondemand     - change cpu freq depending on cpu load (On rasbian, it just switches min and max)
conservative - smoothly change cpu freq depending on cpu load
uesrspace    - allow user space daemon to control cpufreq

We can change the setting from shell at runtime via sysfs.

# echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

To keep this setting over reboot, There are 2 options.

1st option - Put command in /etc/rc.local.
The command execution is after kernel boot. So, it slows bootup down.

2nd option - Enable kernel configration.
Enable either kernel config.

CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND
CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE

Though 2nd way requires kernel build, we can use full cpu power during boot.


After all, you can see cpu freq change depending on cpu load.
Enjoy:)

0 件のコメント:

コメントを投稿