android 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

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章