[RK3288][Android6.0] 调试笔记 — CPU默认调度策略

  • Post author:
  • Post category:其他


Platform: Rockchip

OS: Android 6.0

Kernel: 3.10.92

CPU的频率调节策略:

1. Performance. 不考虑耗电,只用最高频率。

2. Interactive. 直接上最高频率,然后看CPU负荷慢慢降低。

3. Powersave. 通常以最低频率运行,流畅度会受影响,一般不会用这个吧!

4. Userspace. 可以在用户空间手动调节频率。

5. Ondemand. 定期检查负载,根据负载来调节频率。

开机默认策略在 defconfig中定义:

CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE=y

当defconfig中同时定义多个时,会按照如下代码顺序覆盖前者


cpufreq.h

#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE
#define CPUFREQ_DEFAULT_GOVERNOR    (&cpufreq_gov_performance)
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE)
extern struct cpufreq_governor cpufreq_gov_powersave;
#define CPUFREQ_DEFAULT_GOVERNOR    (&cpufreq_gov_powersave)
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE)
extern struct cpufreq_governor cpufreq_gov_userspace;
#define CPUFREQ_DEFAULT_GOVERNOR    (&cpufreq_gov_userspace)
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND)
extern struct cpufreq_governor cpufreq_gov_ondemand;
#define CPUFREQ_DEFAULT_GOVERNOR    (&cpufreq_gov_ondemand)
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE)
extern struct cpufreq_governor cpufreq_gov_conservative;
#define CPUFREQ_DEFAULT_GOVERNOR    (&cpufreq_gov_conservative)
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE)
extern struct cpufreq_governor cpufreq_gov_interactive;
#define CPUFREQ_DEFAULT_GOVERNOR    (&cpufreq_gov_interactive)
#endif

调用处:


cpufreq.c

static int cpufreq_add_dev(...)
{
  policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
}

除了在defconfig可以设置外,在init_xxx.rc中也可以修改掉:

write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor interactive

查看修改后的策略:


#cat sys/devices/system/cpu/cpu0/cpufreq/scaling_governor



版权声明:本文为kris_fei原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。