From 3fa9a6933eb98e9d5de488741024eef5a2d6ab27 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Sat, 13 Sep 2025 10:37:51 -0600 Subject: [PATCH] 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 --- mkosi.extra/usr/bin/_kde-linux-rebuild-efi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mkosi.extra/usr/bin/_kde-linux-rebuild-efi b/mkosi.extra/usr/bin/_kde-linux-rebuild-efi index b1021e9..7255cd3 100755 --- a/mkosi.extra/usr/bin/_kde-linux-rebuild-efi +++ b/mkosi.extra/usr/bin/_kde-linux-rebuild-efi @@ -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 \