Subject: Raspberry Pi default CPU scaling governor

From: John Miner <[email-masked]>
Date: Sat, 17 Jul 2021 20:19:15 +0200

The default Alpine kernel for the Raspberry Pi images has the CPU scaling governor set to "powersave" which limits the maximum CPU frequency to 600MHz (the value at /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq) as the default config has CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE enabled.

Other common RPI distributions have taken the approach to set the governor to "ondemand" which allows scaling of the frequency based on current load (including Arch Linux ARM and Rasbian). Arch Arm sets "ondemand" as the default in the config (CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y in https://github.com/archlinuxarm/PKGBUILDs/blob/master/core/linux-raspberrypi/config) and Raspberry Pi OS (f.k.a Raspbian) sets the default governor to "ondemand" when raspi-config is enabled (see logic at https://github.com/RPi-Distro/raspi-config/blob/master/debian/raspi-config.init where /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor is set to "ondemand").

For example, for the RPI3, setting the scaling_governor to "ondemand" allows the CPU to scale up to 1,200MHz based on load (the value at /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq) rather than limited to 600MHz in "powersave" mode.

Has Alpine taken a position on what default CPU scaling governor should be in place for the images or is it simply using the upstream default config? It seems that users of the Alpine RPI images should be aware that the CPU frequency will be throttled at the minimum frequency and will not achieve the stated frequency as per the SBC specs in the default state.

Two potential options if folks agree this is an issue: 1) take a position on which default scaling governor should be used (whether it is "ondemand" or other) and make that change to config-changes-rpi.armhf if it's not "powersave" or 2) update the Wiki so folks are aware of the CPU throttle and offer them an alternative (e.g., one can place the following command in /etc/local.d to set the governor to "ondemand")

echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

The list of available governors: ondemand userspace powersave performance schedutil (at /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)

One can see the time at the various frequencies by issuing "cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state" in shell. For example, in "powersave" for RPI3, all the time is at 600MHz even under load:

600000 4812998
700000 0
800000 0
900000 0
1000000 0
1100000 0
1200000 0

---

From: Timo Teras <[email-masked]>
Date: Wed, 21 Jul 2021 14:24:31 +0300

Hi,

On Sat, 17 Jul 2021 20:19:15 +0200
John Miner <[email-masked]> wrote:

> The default Alpine kernel for the Raspberry Pi images has the CPU
> scaling governor set to "powersave" which limits the maximum CPU
> frequency to 600MHz (the value at
> /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq) as the default
> config has CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE enabled.

It used to be this way in Alpine too. This likely got changed by
accident in commit ff478c74b2ec904371253c4977a16fe0643ec4d8 which made
the config base on upstream default config.

I personally would welcome this change. Would you be willing to submit
a patch / Merge Request about this?

Timo

---

From: John Miner <[email-masked]>
Date: Sat, 14 Aug 2021 21:31:15 +0200

> a patch / Merge Request about this?

Yes, see below:

https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/24236