Linux kernel has cpufreq, a feature that changes the dynamic operating frequency and operating voltage.
There is a particular way to change the operating frequency and voltage highly for a specific CPU. This feature is highly depending on a CPU. A specific device driver is prepared for a particular CPU. cpufreq has been adapted to CPUs of x86 architecture for a while. However, the adaptation of cpufreq on the CPUs of ARM architecture highly depends on its SoC. OMAP3530 of Texas Instruments, a CPU used for bc10, is capable of using cpupfeq since its Linux is based upon 3.2 kernel.
To utilize cpufreq, measure the change of network throughput and power consumption as changing operating clock of the CPU of bc10.
To use cpufreq, let kernel driver active, Setting menuconfig as ARCH=arm, please configure as it is shown below.
-> CPU Power management -> CPU Frequency scaling [*] CPU Frequency scaling <*> CPU frequency translation statistics [*] CPU frequency translation statistics details Default CPUFreq governor (userspace) ---> <*> 'performance' governor <*> 'powersave' governor -*- 'userspace' governor for userspace frequency scaling <*> 'ondemand' cpufreq policy governor <*> 'conservative' cpufreq governor [*] Generic CPU0 cpufreq driver ARM CPU frequency scaling drivers --->Configure which governor makes active and which active governor is used as the default.
CPUfreq governor determines the rules of operating frequency change.
governors, which OMAP3530 of bc10 can use, are shown below.
performance Make CPU work at the maximum operating frequency powersave Make CPU work at the minimum operating frequency userspace Allow root user or root program to change operating frequency, dynamically ondemand To depend on CPU load, change the dynamic operating frequency. The frequency is adjusted to CPU Load at low-latency conservative To depend on CPU load, change the dynamic operating frequency. The operating frequency gradually shifts depending on the performance of battery
To let boot the kernel, which enables the previously set-up configuration, its operation is handled from the confreq interface of sysfs.
# ls /sys/devices/system/cpu/cpu0/cpufreq/ affected_cpus scaling_cur_freq cpuinfo_cur_freq scaling_driver cpuinfo_max_freq scaling_governor cpuinfo_min_freq scaling_max_freq cpuinfo_transition_latency scaling_min_freq related_cpus scaling_setspeed scaling_available_frequencies stats scaling_available_governors
To use this interface, configure the operating frequency and management policy. The definition and function of each file are shown below.
affected_cpus The list of CPUs, whose frequency should be cooperated by software cpuinfo_cur_freq The present dynamic operating frequency, which is obtained by hardware (kHz) cpuinfo_max_freq The maximum dynamic operating frequency (kHz) cpuinfo_min_freq The minimum dynamic operating frequency (kHz) cpuinfo_transition_latency The duration of time, which is required as it shifts the two different states of operating frequency (Nano-sec) related_cpus Regardless of software and hardware, the list of CPUs, which are needed to be cooperated scaling_available_frequencies the list of available operating frequencies scaling_available_governors the list of available governors scaling_cur_freq A value of dynamic operating frequency, which is obtained from a governor and cpufreq core. Kernel considers this value as the present dynamic operating frequency (kHz) scaling_driver Hardware driver for cpufreq scaling_governor Governors that currently use. Add governors that you like to use by executing echo command. scaling_max_freq The conditional maximum dynamic operating frequency, which is managed by the operation policy. To change the maximum frequency, use echo command. To change this configuration, please change this value before the value of the conditional minimum dynamic frequency. |scaling_min_freq|The conditional minimum dynamic operating frequency, which is conditioned by the operation policy. To change the minimum frequency apply echo command. To alter this configuration, please change the value of the conditional maximum dynamic frequency first.
scaling_setspeed To change dynamic operating frequency, execute echo command the dynamic operating frequency that you like to change.
stats time_in_state A list that how many hours each CPU worked at each configurable opeating frequency total_trans Total number of operating frequency changes trans_table A table that shows the configuration and how the operating frequencies are changed from one state to the other.
Since it is too tedious to operate directly this interface, there is a utility for operating. The utility is called cpufrequtils. The present setting is handled by cpufreq-info.
# cpufreq-info cpufrequtils 006: cpufreq-info (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU 0: driver: omap CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 300 us. hardware limits: 125 MHz - 600 MHz available frequency steps: 125 MHz, 250 MHz, 500 MHz, 550 MHz, 600 MHz available cpufreq governors: conservative, ondemand, powersave, userspace, performance current policy: frequency should be within 125 MHz and 600 MHz. The governor "userspace" may decide which speed to use within this range. current CPU frequency is 600 MHz (asserted by call to hardware). cpufreq stats: 125 MHz:0.00%, 250 MHz:0.00%, 500 MHz:0.00%, 550 MHz:0.00%, 600 MHz:100.00%The performance of the present setting is shown above, and it indicates that:
OMAP3530 of bc10 can operate at 125, 250, 500, 550 and 600 MHz,
the present governor is userspace, and
the CPU is currently operating at 600MHz.
cpufreq-set is used for changing the current configuration.# cpufreq-set --help cpufrequtils 006: cpufreq-set (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. Usage: cpufreq-set [options] Options: -c CPU, --cpu CPU number of CPU where cpufreq settings shall be modified -d FREQ, --min FREQ new minimum CPU frequency the governor may select -u FREQ, --max FREQ new maximum CPU frequency the governor may select -g GOV, --governor GOV new cpufreq governor -f FREQ, --freq FREQ specific frequency to be set. Requires userspace governor to be available and loaded -r, --related Switches all hardware-related CPUs -h, --help Prints out this screen Notes: 1. Omitting the -c or --cpu argument is equivalent to setting it to zero 2. The -f FREQ, --freq FREQ parameter cannot be combined with any other parameter except the -c CPU, --cpu CPU parameter 3. FREQuencies can be passed in Hz, kHz (default), MHz, GHz, or THz by postfixing the value with the wanted unit name, without any space (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).The Option “c” and “r” are only for multi-processor system, so option “d,” “u,” “g,” and “f” are actually applicable to bc10.
To make bc10 operate at 500Mz, please apply the command for changing its configuration.# cpufreq-set -f 500MH
After executing the command above, there are no indications whether the new configuration is successfully applied or not. To check the effectiveness of the new configuration, it is necessary to execute cpufreq-info again.# cpufreq-info cpufrequtils 006: cpufreq-info (C) Dominik Brodowski 2004-2009 Report errors and bugs to cpufreq@vger.kernel.org, please. analyzing CPU 0: driver: omap CPUs which run at the same hardware frequency: 0 CPUs which need to have their frequency coordinated by software: 0 maximum transition latency: 300 us. hardware limits: 125 MHz - 600 MHz available frequency steps: 125 MHz, 250 MHz, 500 MHz, 550 MHz, 600 MHz available cpufreq governors: conservative, ondemand, powersave, userspace, performance current policy: frequency should be within 125 MHz and 600 MHz. The governor "userspace" may decide which speed to use within this range. current CPU frequency is 500 MHz (asserted by call to hardware). cpufreq stats: 125 MHz:0.00%, 250 MHz:0.00%, 500 MHz:3.51%, 550 MHz:0.00%, 600 MHz:96.49% (1)To check /proc/cpuinfo, it shows changes in BogoMIPS, depending on its operating frequencies.
To use BogoMIPS, the results of a new configuration are recognized.
To boot bc10-router with the router mode, compare the level of network throughput against different operating frequencies of OMAP3530. The operating frequencies are 125, 250, 500, 550, and 600MHz. The frequencies are configured by cpufreq.
To measure network throughputs, nuttcp is used. In the network throughput testing environment, the other side of the network uses a PC, and its network configuration is the same as the one used at bc10-router/measuring network performance.
WAN Side: bc10-router nuttcp -S
LAN Side: PC nuttcp 192.168.30.1
kernel 3.3.7
- 600MHz
BogoMIPS 581.89
Table>
Table>
- 500MHz
BogoMIPS 484.74
Table>
- 250MHz
BogoMIPS 242.87
Table>
- 125MHz
BogoMIPS 121.43
Table>
Since the test load of nttcp consumes sufficient processing power of the CPU at the operating frequency of 500MHz, The difference in the throughput at the operating frequencies of 500MHz or higher is not recognized.
At less than 500MHz of operational frequencies, the relationship between operating frequency of CPU and network throughput is proportional. As the operating frequency of the CPU is lowered from 500MHz to 250MHz, its processing power is reduced to almost a half, and throughput also becomes almost a half of 500MHz's. As the operating frequency is set to 125MHz, its throughput becomes almost a half of 250MHz's and almost a quarter of 500MHz's.
As Several Wi-Fi clients are connected and communicated to bc10-router simultaneously, the maximum operating frequency could be needed. If only bc10-router is connected to only one router, the CPU will provide adequate processing power for handling this task at 500MHz of operating frequency.
As the configuration is changed from cpufreq governor to ondemand governor, the operating frequency is shifted automatically from one frequency to the other, depending on CPU load. As The CPU load gets heavier, its frequency sifts automatically higher. This feature would be highly effective for conserving the energy and reducing heat from CPU.
- 2013-08-09 This article is initially uploaded.