Tweak kernel parameters to optimize latency and power usage

See inline comments regarding what exactly these kernel options do.

But in a nutshell, we should get lower latency and power usage, at the
cost of a little bit of throughput in CPU-intensive tasks. For the kinds
of userspace desktop use cases we target in KDE Linux, this seems like
an appropriate trade-off.

Research sources included:
- https://discourse.ubuntu.com/t/enable-low-latency-features-in-the-generic-ubuntu-kernel-for-24-04/42255
- https://discourse.ubuntu.com/t/fine-tuning-the-ubuntu-24-04-kernel-for-low-latency-throughput-and-power-efficiency/44834
- https://www.kernel.org/doc/html/v6.15-rc3/timers/no_hz.html
This commit is contained in:
Nate Graham
2025-09-13 10:37:51 -06:00
parent 85cf5f0664
commit 3fa9a6933e

View File

@@ -30,6 +30,9 @@ echo "rw \
systemd.volatile=overlay systemd.firstboot=false systemd.hostname=kde-linux kde-linux.live=1 plasma.live.user=live \
lsm=landlock,lockdown,yama,integrity,apparmor,bpf \
zswap.enabled=0 \
preempt=full threadirqs \
nohz=on nohz_full=all \
rcu_nocbs=all rcutree.enable_rcu_lazy=1 \
vt.global_cursor_default=0 quiet splash loglevel=3" > cmdline
mkinitcpio --config mkinitcpio.conf --generate initrd --kernel "$kernel_version"
ukify build \
@@ -39,9 +42,25 @@ ukify build \
--output live.efi
# lsm= defaulting to apparmor from https://wiki.archlinux.org/title/AppArmor
# "preempt=full threadirqs" reduces latency especially for audio and gaming workflows.
# "nohz=on nohz_full=all" stops waking up a CPU more than once a second if it has fewer
# than 2 tasks. This reduces latency for userspace software and may also save power. The
# kernel requires at least one CPU to not be using this mode, but it will choose one for
# us. This requires nohz=on, which is the default, but we manually specify it here anyway
# because nohz_full=all needs it and we don't want that to break.
# "rcu_nocbs=all rcutree.enable_rcu_lazy=1" turns on batched/lazy RCU on all CPUs,
# reducing wake-ups and therefore power usage. rcu_nocbs=all is actually turned on
# automatically by nohz_full=all, but we manually specify it here anyway because
# rcutree.enable_rcu_lazy=1 needs it and we don't want that to break.
echo "rw rootflags=subvol=@system,compress=zstd:1 \
lsm=landlock,lockdown,yama,integrity,apparmor,bpf \
zswap.enabled=0 \
preempt=full threadirqs \
nohz=on nohz_full=all \
rcu_nocbs=all rcutree.enable_rcu_lazy=1 \
vt.global_cursor_default=0 quiet splash loglevel=3" > cmdline
mkinitcpio --config mkinitcpio.conf --generate initrd --kernel "$kernel_version"
ukify build \