diff --git a/Containerfile b/Containerfile index 2add06f7..3f6a70b6 100644 --- a/Containerfile +++ b/Containerfile @@ -140,11 +140,6 @@ RUN rpm-ostree override replace --experimental --from repo=copr:copr.fedorainfra mesa-libglapi \ mesa-vulkan-drivers -# Remove system76-scheduler -RUN rpm-ostree override remove system76-scheduler -RUN rm -f /etc/systemd/user/com.system76.Scheduler.dbusproxy.service -RUN rm -f /usr/bin/system76-scheduler-dbus-proxy - # Remove steamdeck-kde-presets-desktop RUN rpm-ostree override remove steamdeck-kde-presets-desktop @@ -202,10 +197,8 @@ RUN sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/_copr_ublue-os-akmods.repo systemctl enable jupiter-fan-control.service && \ systemctl enable vpower.service && \ systemctl enable ds-inhibit.service && \ - systemctl enable set-cfs-tweaks.service && \ systemctl disable input-remapper.service && \ systemctl --global disable ublue-update.timer && \ - setcap cap_sys_nice=+ep /usr/bin/gamescope && \ rm -f /usr/etc/sddm.conf && \ rm -rf \ /tmp/* \ diff --git a/README.md b/README.md index 90f2f964..6e3640c0 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Bazzite is built from [ublue-os/main](https://github.com/ublue-os/main) and [ubl - Support for [Wallpaper Engine](https://www.wallpaperengine.io/en) on KDE. - [Distrobox](https://github.com/89luca89/distrobox) preinstalled with automatic updates for created containers. - Automated duperemove services for reducing the disk space used by wine prefix contents. +- [System76-Scheduler](https://github.com/pop-os/system76-scheduler) preinstalled, providing automatic process priority tweaks to your focused application and keeping CPU time for background processes to a minimum. +- Customized System76-Scheduler config with additional rules and CFS parameters from [Linux-TKG](https://github.com/Frogging-Family/linux-tkg). - Uses [Google's BBR TCP congestion control](https://github.com/google/bbr) by default. - [Input Remapper](https://github.com/sezanzeb/input-remapper) preinsalled and enabled (Available but default-disabled on the Deck variant) - Helpful first-start installer provides an easy way to install numerous applications and tweaks, including installing [CoreCtrl](https://gitlab.com/corectrl/corectrl) and [GreenWithEnvy](https://gitlab.com/leinardi/gwe). @@ -34,8 +36,6 @@ Bazzite is built from [ublue-os/main](https://github.com/ublue-os/main) and [ubl Common variant available as `bazzite` and suitable for desktops and HTPCs. - Runs Steam and Lutris in a [custom Arch Linux OCI](https://github.com/ublue-os/bazzite-arch/) via Distrobox. -- Ships with a ported version of [System76-Scheduler](https://github.com/pop-os/system76-scheduler), providing automatic process priority tweaks to your focused application and keeping CPU time for background processes to a minimum. -- Customized System76-Scheduler config with additional rules and CFS parameters from [Linux-TKG](https://github.com/Frogging-Family/linux-tkg). - Option to automatically launch Steam in Big Picture Mode on boot for HTPCs. To rebase an existing system to this image: @@ -63,8 +63,7 @@ Variant designed for usage as an alternative to SteamOS on the Steam Deck, avail - Comes with a default-disabled service for low-risk undervolting of the Steam Deck via [RyzenAdj](https://github.com/FlyGoat/RyzenAdj). - Exclusively uses ZRAM by default with the option to switch back to a swap file and set a custom size if desired (1GB by default). - BFQ I/O scheduler to prevent I/O starvation when installing games or during background duperemove processes. -- CFS scheduler parameters from [Linux-TKG](https://github.com/Frogging-Family/linux-tkg) for increased performance. -- TLS/SSL secured DNS and NTP by default. This is a handheld PC you're likely to use on random public networks after all. +- TLS/SSL secured DNS and NTP by default (This is a handheld PC you're likely to use on random public networks after all). - Applies SteamOS's kernel parameters and enables amd-pstate by default. To rebase an existing system to this image: diff --git a/system_files/deck/etc/system76-scheduler/config.kdl b/system_files/deck/etc/system76-scheduler/config.kdl new file mode 100644 index 00000000..1ea4afd2 --- /dev/null +++ b/system_files/deck/etc/system76-scheduler/config.kdl @@ -0,0 +1,88 @@ +// Version of the configuration file +version "2.0" + +// Autogrouping nullifies nice priorities +autogroup-enabled false + +// Latency profiles the kernel's Completely Fair Scheduler +cfs-profiles enable=true { + // The kernel-default values which are ideal for battery life and servers + default latency=6 nr-latency=8 wakeup-granularity=1.0 bandwidth-size=5 preempt="voluntary" + + // TKG CFS parameters that make the desktop more responsive + responsive latency=3 nr-latency=10 wakeup-granularity=0.5 bandwidth-size=3 preempt="full" +} + +// Monitors and applies process priority adjustments +process-scheduler enable=true { + // How often to reload process assignments. 0 to disable + refresh-rate 60 + + // Enable realtime process priority adjustment with execsnoop + execsnoop true + + // Preset process assignment profiles + assignments { + // Prevent crackling and distortion from the sound server + sound-server nice=-15 sched=(fifo)49 io=(realtime)0 { + "/usr/bin/pipewire" + "/usr/bin/pipewire-pulse" + "/usr/bin/jackd" + } + + // Applications with realtime audio processing needs + recording nice=-9 io=(best-effort)0 + + // Enables pipewire process monitoring and assignments + pipewire nice=-6 io=(best-effort)0 + + // Video games + games nice=-5 io=(best-effort)0 + + // Desktop environments + desktop-environment nice=-10 io=(best-effort)0 + + // Foreground process profile + foreground nice=0 io=(best-effort)0 + + // Background process profile + background nice=6 io="idle" + + // Session services belonging to the user + session-services nice=9 io="idle" { + include cgroup="/user.slice/*.service" parent="systemd" + include cgroup="/user.slice/*/session.slice/*" parent="systemd" + exclude cgroup="/user.slice/*app-dbus*" + } + + // System services belonging to root + system-services nice=12 io="idle" { + include cgroup="/system.slice/*" + } + + // Package management processes + package-manager nice=15 sched="batch" io="idle" + + // CPU-intense background tasks + batch nice=19 sched="idle" io="idle" + } + + exceptions { + include descends="chrt" + include descends="gamemoderun" + include descends="ionice" + include descends="nice" + include descends="taskset" + include descends="schedtool" + chrt + dbus + dbus-broker + gamemoderun + ionice + nice + rtkit-daemon + systemd + taskset + schedtool + } +} diff --git a/system_files/deck/etc/systemd/system/set-cfs-tweaks.service b/system_files/deck/etc/systemd/system/set-cfs-tweaks.service deleted file mode 100644 index 6cb8e971..00000000 --- a/system_files/deck/etc/systemd/system/set-cfs-tweaks.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Set CFS tweaks -After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target - -[Service] -ExecStart=/usr/bin/set-cfs-tkg-tweaks -Type=oneshot - -[Install] -WantedBy=multi-user.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target diff --git a/system_files/deck/usr/bin/set-cfs-tkg-tweaks b/system_files/deck/usr/bin/set-cfs-tkg-tweaks deleted file mode 100755 index 0ea00782..00000000 --- a/system_files/deck/usr/bin/set-cfs-tkg-tweaks +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-2.0-only -# Copyright (C) 2021 igo95862 - -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation, version 2. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -set -eu - -LATENCY_MS=3 -MIN_GRANULARITY_MS=0.3 -WAKEUP_GRANULARITY_MS=0.5 -MIGRATION_COST_MS=0.25 -BANDWIDTH_SIZE_MS=3 -NR_MIGRATE=64 - -echo "Targeted preemption latency for CPU-bound tasks: ${LATENCY_MS}ms" -echo "Minimal preemption granularity for CPU-bound tasks: ${MIN_GRANULARITY_MS}ms" -echo "Wake-up granularity: ${WAKEUP_GRANULARITY_MS}ms" -echo "Task migration cost: ${MIGRATION_COST_MS}ms" -echo "Amount of runtime to allocate from global to local pool: ${BANDWIDTH_SIZE_MS}ms" -echo "Number of tasks to iterate in a single balance run: ${NR_MIGRATE}" - -call_gawk() { - printf '%s' "$(gawk 'BEGIN {print '"${1}"'}')" -} - -NPROC="$(nproc)" -# Linux uses this algorithm to multiply miliseconds -MODIFIER="$( call_gawk "10 ** 6 * (1 + int(log(${NPROC}) / log(2)))" )" - -LATENCY_NS_FILE="/sys/kernel/debug/sched/latency_ns" -MIN_GRANULARITY_NS_FILE="/sys/kernel/debug/sched/min_granularity_ns" -WAKEUP_GRANULARITY_NS_FILE="/sys/kernel/debug/sched/wakeup_granularity_ns" -MIGRATION_COST_NS_FILE="/sys/kernel/debug/sched/migration_cost_ns" -BANDWIDTH_SIZE_US_FILE="/proc/sys/kernel/sched_cfs_bandwidth_slice_us" -NR_MIGRATE_FILE="/sys/kernel/debug/sched/nr_migrate" - -if [ ! -f "$LATENCY_NS_FILE" ]; then - echo "Detected kernel <5.13. Using legacy locations." - LATENCY_NS_FILE="/proc/sys/kernel/sched_latency_ns" - MIN_GRANULARITY_NS_FILE="/proc/sys/kernel/sched_min_granularity_ns" - WAKEUP_GRANULARITY_NS_FILE="/proc/sys/kernel/sched_wakeup_granularity_ns" - MIGRATION_COST_NS_FILE="/proc/sys/kernel/sched_migration_cost_ns" - NR_MIGRATE_FILE="/proc/sys/kernel/sched_nr_migrate" -fi - -printf '%s' "$( call_gawk "int(${LATENCY_MS} * ${MODIFIER})" )" > "$LATENCY_NS_FILE" -printf '%s' "$( call_gawk "int(${MIN_GRANULARITY_MS} * ${MODIFIER})" )" > "$MIN_GRANULARITY_NS_FILE" -printf '%s' "$( call_gawk "int(${WAKEUP_GRANULARITY_MS} * ${MODIFIER})" )" > "$WAKEUP_GRANULARITY_NS_FILE" -printf '%s' "$( call_gawk "int(${MIGRATION_COST_MS} * ${MODIFIER})" )" > "$MIGRATION_COST_NS_FILE" -printf '%s' "$( call_gawk "int(${BANDWIDTH_SIZE_MS} * 1000)" )" > "$BANDWIDTH_SIZE_US_FILE" -printf '%s' "$NR_MIGRATE" > "$NR_MIGRATE_FILE" diff --git a/system_files/deck/usr/share/ublue-os/firstboot/yafti.yml b/system_files/deck/usr/share/ublue-os/firstboot/yafti.yml index 20bc4cf0..85b734bd 100644 --- a/system_files/deck/usr/share/ublue-os/firstboot/yafti.yml +++ b/system_files/deck/usr/share/ublue-os/firstboot/yafti.yml @@ -99,6 +99,11 @@ screens: default: false packages: - Switch SteamOS-BTRFS config to EXT4: sudo -A just --unstable switch-to-ext4 + System76 Scheduler: + description: Enables System76 scheduler + default: true + packages: + - Enable System76 Scheduler: just --unstable enable-system76-scheduler Wallpaper Engine: description: Enables Wallpaper Engine default: true diff --git a/system_files/deck/usr/share/ublue-os/just/custom.just b/system_files/deck/usr/share/ublue-os/just/custom.just index f3200176..35c3c55c 100644 --- a/system_files/deck/usr/share/ublue-os/just/custom.just +++ b/system_files/deck/usr/share/ublue-os/just/custom.just @@ -30,6 +30,14 @@ get-steamcmd: tar -xvzf steamcmd.tar.gz -C ~/.steam rm /tmp/steamcmd.tar.gz +enable-system76-scheduler: + git clone https://github.com/maxiberta/kwin-system76-scheduler-integration.git --depth 1 /tmp/kwin-system76-scheduler-integration + kpackagetool5 --type=KWin/Script -i /tmp/kwin-system76-scheduler-integration + systemctl --user enable --now com.system76.Scheduler.dbusproxy.service + systemctl enable --now com.system76.Scheduler.service + kcmshell5 kcm_kwin_scripts + rm -rf /tmp/kwin-system76-scheduler-integration + install-nix: curl -s https://raw.githubusercontent.com/dnkmmr69420/nix-installer-scripts/main/installer-scripts/silverblue-nix-installer.sh | bash