1. 程式人生 > >[RK3288][Android6.0] 除錯筆記 --- CPU預設排程策略

[RK3288][Android6.0] 除錯筆記 --- CPU預設排程策略

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