How to handle CPU core frequency from user space
The linux kernel is configured to expose the single CPU cores to user space via SysFS framework. There you can turn single CPU cores on and off or check the current CPU frequency.
Turn a CPU core off and on (after system start all cores are running):
# echo 0 > /sys/devices/system/cpu/cpu1/online // this turns the cpu core with id 1 off# echo 1 > /sys/devices/system/cpu/cpu1/online // this turns the core back on |
Please regard that CPU core 0 can not be turned off.
Reading the current CPU frequency:
# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq // reads the current frequency of core 0 |
Adjust maximum core frequency. You can adjust the frequency only to certain values (396000, 792000, 996000). Also regard that all cores have to run with the same frequency. This means that reducing the max frequency for one core results in a reduced frequency for all cores:
# echo 792000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq // set maximum cpu core frequency to 792 MHz# echo 996000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq // set maximum cpu core frequency to 996 MHz |