调试笔记 --- CPU默认调度策略

本文转载自:https://blog.csdn.net/kris_fei/article/details/77982440

为了阅读方便直接全文复制,在此感谢原创,尊重原创!

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

调用处:
cpufreq.c

扫描二维码关注公众号,回复: 3571710 查看本文章
static int cpufreq_add_dev(...)
{
  policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
}
  • 1
  • 2
  • 3
  • 4

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

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

查看修改后的策略:
#cat sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

猜你喜欢

转载自blog.csdn.net/always_and_forever_/article/details/81451321