March 2021: CPU frequency scaling settings configurable via
/etc/init.d/cpufreq
, applied at boot
In the last few builds, I have set the CPU frequency scaling options via a startup script, instead of patching the kernel sources like earlier. I had already earlier made the CPU scaling moderately more aggressive, but the main recent change in the last few days is the elimination of the lowest 384 MHz frequency from the CPU speed table by setting 600 MHz as the lowest speed used in the scaling.
The 384M step had visible negative impact in speed testing (with "flent").
In the charts below, I tested the default "ondemand" frequency governor with the default 384M step enabled, then 600M set as the scaling_min_freq, and finally with the performance governor (=always top frequency).
There is not much difference between "performance" (right) and the "ondemand" with 600M minimum (middle), but the 384M min (left) lets lots of bandwidth unused. SQM is used.
Eliminating the 384M CPU speed decreased latency from 33 to 27 ms, while visibly increasing the throughput. Using "performance" still improves things, but at least for my personal usage, really needing the top speeds is rare.
Current script:
--- /dev/null
+++ b/target/linux/ipq806x/base-files/etc/init.d/cpufreq
@@ -0,0 +1,16 @@
+#!/bin/sh /etc/rc.common
+
+START=15
+
+boot() {
+ # Select 'ondemand'=scaling or 'performance'=always max freq
+ echo ondemand > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
+ echo ondemand > /sys/devices/system/cpu/cpufreq/policy1/scaling_governor
+
+ # Effective only with ondemand
+ echo 600000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
+ echo 600000 > /sys/devices/system/cpu/cpufreq/policy1/scaling_min_freq
+ echo 20 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
+ echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
+}
+
After my flent testing, Ansuel gave me the idea about using the startup script in the kernel 5.10 discussion, and I tested it. Works nicely. My current script is above. Ansuel is now trying to get this elimination of the 384M into the main OpenWrt via a PR
- discussion starting from [PR] ipq806x: kernel 5.10 bump code propose - #75 by hnyman
- PR https://github.com/openwrt/openwrt/pull/4033