So before, in Ubuntu 16.04 and below, /etc/init.d/ondemand
was responsible for changing the CPU frequency to “ondemand” which caused issues while gaming with the processor downclocking. This is why Feral Interactive created Linux “GameMode” which sets the frequency governor to “performance”
Trouble is, the fix is extremely simple… Just change echo -n ondemand > $CPUFREQ
to echo -n performance > $CPUFREQ
Ubuntu 18.04 relocated this script to instead of being in /etc/init.d/ondemand
to instead be a script that is called upon by a ondemand.service
in /lib/systemd/set-cpufreq
A glance at /lib/systemd/set-cpufreq
makes it look practically identical to the previous /etc/init.d/ondemand
!
How do we set the CPU Governor to “performance?”
Make /lib/systemd/performance.patch
with this as the contents:
--- set-cpufreq 2018-11-24 06:12:29.696495541 -0800
+++ set-cpufreq_perf 2018-11-24 06:03:48.351162000 -0800
@@ -34,12 +34,12 @@
[ -n "${GOVERNOR:-}" ] || exit 0
-echo "Setting $GOVERNOR scheduler for all CPUs"
+echo "Setting performance scheduler for all CPUs"
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
do
[ -f $CPUFREQ ] || continue
- echo -n $GOVERNOR > $CPUFREQ
+ echo -n performance > $CPUFREQ
done
if [ -n "${SAMPLING:-}" ] && [ -f $DOWN_FACTOR ]; then
echo -n $SAMPLING > $DOWN_FACTOR
Patch the file with patch -N -r /dev/null < performance.patch
, then reboot.
To make the setting stick, you have to create a startup script that applies this patch every boot. Systemd updates will always overwrite the file back to default values despite file permissions you set to the file.
That’s literally it.
Once again, modify /lib/systemd/set-cpufreq
with the patch file, then patch the file each boot with a startup script to change the governor in 18.04. systemd startup service instructions in post 8. (The post marked as the solution)
If you have a symlink for /lib
, please change all references of /lib
to /usr/lib
as a precaution.