cpufreq是内核针对cpu调频设计的统一驱动框架,这在网上有大量资料,就不再赘述。
在此,主要关心
1) intel cpu 调频驱动的参数 配置和cpufreq的参数的关系。
scaling_max_freq max_perf_pct 在设置max_perf_pct后,max_freq是受影响的,例如CPU最高频率为4GHZ,设置perf为 30%,则max_freq的值会变为 1.2,如果此时也设置max_freq呢,那它的值是怎么样的?两者有先后覆盖关系吗?
scaling_min_freq min_perf_pct 对于下限区间,存在同样的问题。
2) 对于scaling_max_freq ,scaling_min_freq,这个不能理解为CPU的最大最小频率,而是cpufreq对CPU进行调频的范围,可以和CPU支持的范围相同,也可以不同。
3)scaling_governor。 相当于调频的策略。
对于intel_pstate支持两个值,performance 和powersave。网上大量资料都说performace是固定在最高频率;powersave是固定在最低频率。实际则不然。
根据实际测试,当配置为performance时,用i7z工具查看cpu频率,的确在最高频率。
然而配置为powersave时,通过i7z查看,频率是动态变化的。
查阅内核文档 : intel_pstate CPU Performance Scaling Driver — The Linux Kernel documentation
可以知晓: powersave 是根据当前cpu 利用率选择合适的p态,并非固定在最低频率。
performance
Without HWP, this P-state selection algorithm is always the same regardless of the processor model and platform configuration.
It selects the maximum P-state it is allowed to use, subject to limits set via sysfs, every time the driver configuration for the given CPU is updated (e.g. via sysfs).
This is the default P-state selection algorithm if the CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE kernel configuration option is set.
powersave
Without HWP, this P-state selection algorithm is similar to the algorithm implemented by the generic schedutil scaling governor except that the utilization metric used by it is based on numbers coming from feedback registers of the CPU. It generally selects P-states proportional to the current CPU utilization.
This algorithm is run by the driver’s utilization update callback for the given CPU when it is invoked by the CPU scheduler, but not more often than every 10 ms. Like in the performance case, the hardware configuration is not touched if the new P-state turns out to be the same as the current one.