feat(deck): Enable System76-Scheduler

Eliminates the need to have CAP_SYS_NICE on gamescope
This commit is contained in:
Kyle Gospodnetich 2023-07-26 09:44:41 -07:00
parent ce3ad68dae
commit 50e98238da
7 changed files with 104 additions and 84 deletions

View File

@ -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/* \

View File

@ -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 <sup><sub>(This is a handheld PC you're likely to use on random public networks after all)</sub></sup>.
- Applies SteamOS's kernel parameters and enables amd-pstate by default.
To rebase an existing system to this image:

View File

@ -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
}
}

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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