power-gating.html
Android平台下使用内核模块关闭某些CPU核
1. 查下CPU支持哪些governor的模式cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
Odroid-XU3平台下的输出:userspace powersave interactive performance
注释:performance表示不降频,powersvae表示省电模式,通常是在最低频率下运行,userspace表示用户模式,在此模式下允许其他用户程序调节CPU频率。另外,也存在ondemand模式(Odroid-XU3平台下无此模式),表示使用内核提供的功能,可以动态调节频率。
2. 将模式调整为”powersvae”echo "powersvae" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
此处必须要做,否则默认是interactive,该模式下,CPU虽然也可以被关闭,但是关闭后即立刻重新开启。猜测,这应该是interactive Governor导致的。
3. cpu_up()和cpu_down()内核函数
cpu_up()和cpu_down()内核函数定义在kernel/cpu.c文件中,当在编译配置文件进行了如下配置时CONFIG_HOTPLUG_CPU=y
cpu_up()和cpu_down()内核函数会被导出到内核符号表中,如下所示:linux$ nm vmlinux | grep "cpu_up"
c061e628 T __cpu_up
c061ef1c t _cpu_up
c061f080 T cpu_up
c001efb0 T exynos5422_cpu_up
c082bf87 r __kstrtab_cpu_up
c0826adc r __ksymtab_cpu_up
c061f668 t workqueue_cpu_up_callback
c099f5dc d workqueue_cpu_up_callback_nb.26011linux$ nm vmlinux | grep "cpu_down"
c061d164 t _cpu_down
c061d3c4 T cpu_down
c001ece8 T exynos5422_cpu_down
c082bf8e r __kstrtab_cpu_down
c081fffc r __ksymtab_cpu_down
c061d10c t take_cpu_down
c061f9a8 t workqueue_cpu_down_callback
c099f5e8 d workqueue_cpu_down_callback_nb.26012
4. 使用cpu_up()和cpu_down()内核函数打开和关闭CPU核
内核模块代码如下所示:#include
#include
#include
#define cpu_up 0xc061f080