Repository navigation
Give PipeWire realtime with rtkit and stop the silent app kills - #16824
Merged
Merged
Conversation
PipeWire requests realtime scheduling from RealtimeKit at startup, but rtkit is not a dependency of Arch's pipewire packages and no rlimits fallback is configured either. On a stock install every data-loop thread runs at SCHED_OTHER nice 0, so audio produces xruns and crackling under sustained CPU/GPU load (gaming, GPU inference, compilation). Ship rtkit in the base package list, and repair existing installs with a migration that installs it and restarts the running audio units so the priority request succeeds without a reboot. Fixes #9390
omarchy-other.packages only seeds the ISO's offline mirror; the installer pacstraps omarchy-base.packages, so rtkit listed only in the other list never reaches a fresh install, and fresh installs mark this migration done. xdg-desktop-portal reads rtkit's RTTimeUSecMax once, at startup. Restarting the audio units while it still reports 0 gave WirePlumber, and the shell as it reconnected, a hard RLIMIT_RTTIME of 0 with SCHED_RR data loops. Restarting the portal first gives them 200000 us like the daemon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quattro now lists rtkit for aarch64 alone; bringing it in lets the base-list entry replace that one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
omarchy-pkg-defaults composes the base list first and de-duplicates, so the entry is redundant, and its comment saying nothing pulls rtkit in on aarch64 would mislead the next reader. Co-Authored-By: Sam Diaz <265920095+szaidi-code@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PipeWire's client.conf and jack.conf load module-rt with the realtime portal enabled. A portal started before rtkit was installed, or one whose single read of rtkit at startup failed (flatpak/xdg-desktop-portal#2110), reports a realtime budget of zero, and module-rt applies it as a hard RLIMIT_RTTIME of 0 to the process, which rtkit then accepts: the process's thread runs realtime and the kernel kills it at its first RT watchdog check. On a 4.0.6 VM where rtkit was installed and the portal could not be restarted, 4 of 17 new clients died that way. Set rtportal.enabled = false through module.rt.args, which module-rt reads from the client's own config, as the stock pipewire.conf and pipewire-pulse.conf do for the servers and Omarchy's speaker tuning host does since #12958. Clients then ask rtkit itself and take its real budget. Without rtkit they get no zero limit. On a VM with the portal made stale, a new client got 200000/200000. WirePlumber is not covered: it creates its PipeWire context with no config of its own and passes PipeWire only its context.modules list, so a top-level module.rt.args in wireplumber.conf.d never reaches module-rt. A drop-in there was tried and left WirePlumber at a hard 0 with realtime threads. Reaching it would mean replacing WirePlumber's whole module list. Flatpak apps read their runtime's own PipeWire config and are not affected either. omarchy-settings copies etc/ wholesale, so these ship with no packaging change.
Without rtkit, xdg-desktop-portal reports a realtime budget of 0 and PipeWire's client module-rt applies it as a hard RLIMIT_RTTIME of 0. The shell is such a client, so everything it launches inherits the zero. Once rtkit is installed it accepts any hard limit at or below its own budget, 0 included, so a thread of such a process becomes realtime and the kernel kills the process at its first RT watchdog check. A 4.0.6 VM showed 44 such kills in the minute after #12428's migration, from a terminal opened before the update. Raising the zeros has to come before the install. dbus-broker watches its service directories and reloads when they change, so rtkit can be activated as soon as pacman extracts it, before any install script or ALPM hook runs. That rules out a dependency or a scriptlet. omarchy-realtime-repair runs in two parts: - Once per machine, as root, while rtkit is missing or an earlier run stopped after installing it: raise every logged-in regular user's hard zero (UID 1000 and up, so never root's or a system account's services) to rtkit's default 200 ms, install rtkit, raise the zeros to its live budget, restart each logged-in user's portal that still reports zero, and raise the zeros that appeared meanwhile. A root-owned marker under /var/lib/omarchy, written before the install and removed at the end, makes an interrupted run repeat this. A machine that got rtkit any other way, a fresh install included, has no marker. - Every run, for the caller only: raise the caller's own zeros, restart the caller's portal if it reports zero, raise again, and restart the caller's audio units if the PipeWire server is not realtime yet, since PipeWire asks rtkit only at startup. The server is pipewire.service's main process: the speaker tuning host is also named pipewire and can be realtime while the server is not. Without zeros this needs no sudo, so a second user, or a non-admin one, finishes without it. Each pass repeats until it finds no zero, so children forked meanwhile are covered. Each target is checked again just before prlimit, by start time, owner and limit, so a reused PID or a limit someone else has just set is left alone. The machine-wide scan runs as root: with /proc mounted hidepid a user cannot read other users' processes, so their zeros would be missed (hidepid=2) or every run would fail on them (hidepid=1). A user's own scan skips processes it does not own. It never prompts. Under omarchy update sudo is already cached; without it the command stops before changing anything and says the next update finishes it. Anything it cannot inspect, the user list, a portal's state, a live process's start time, owner or limits, PipeWire's main process, is a failure rather than nothing to do. The start time is read from /proc/<pid>/stat after the last ") ", so a command name with spaces, parentheses or a newline cannot shift it. The test runs the command against a fake proc tree with only the system boundary stubbed.
The migration installed rtkit while processes started without it still carried a hard RLIMIT_RTTIME of 0, and it marked itself done when the portal restart failed. Run omarchy-realtime-repair instead, which raises the zeros before rtkit can be activated and fails, keeping the migration pending, while anything is left that it could not repair or inspect. A second run changes nothing.
emirb
marked this pull request as ready for review
October 27, 2026 23:17
emirb
force-pushed
the
rtkit-session-repair
branch
from
October 27, 2026 23:19
bb777b6 to
4294aa7
Compare
Contributor
[High impact] The PR appears safe to merge; no new actionable issues were found. SummaryAdds
|
A client can read a portal's old zero budget just before the portal restarts. The repair raised such zeros in a final pass, but a later portal that failed to restart exited the command before that pass, and the client kept a zero with rtkit already installed. The same held for the caller's own portal. Restart each portal in a subshell, always run the final pass, and only then fail, so the migration still stays pending. Run as root, the command now does the machine-wide part alone: root has no desktop session of its own, and omarchy-upgrade-to-quattro runs it as root. The test stubs id, so the caller is a regular user whoever runs the suite; as root, the caller and root's own services were the same account and a case failed. It passes as a regular user and as root, and each new case fails with its fix removed.
omarchy-upgrade-to-quattro installs the base package list in the running 3.x session, and the list now carries rtkit. rtkit can make an app that took a zero realtime budget without it realtime, and the kernel kills it, before the upgrade reaches its migrations. Those migrations would also find rtkit installed and skip the machine-wide repair. Run omarchy-realtime-repair as root once the new omarchy package is in and before any other package install: it raises the zero budgets, installs rtkit itself, and repairs every logged-in user's portal. The base list then finds rtkit installed, and the migration needs no sudo, so an upgrade run as root does not stop on it. A failed repair stops the upgrade before the base list, like a failed migration does.
dbus-broker reloads its service directories as soon as pacman extracts rtkit, so a client's realtime request can activate rtkit-daemon in the middle of the transaction, before the sysusers hook has created the rtkit user. It then fails "Failed to find user 'rtkit'" into systemd's start limit, the repair's budget read failed and it exited before restarting the portals, and rtkit came back about 10 s later with the portals still handing out zeros. In VMs under load this hit 4 of 18 upgrade runs; in one, 79 portal clients holding a zero were made realtime and killed. Mask rtkit-daemon at runtime before the install, so no client can activate it until the transaction is done, raise the zeros once more, unmask it, reset a failed start, and wait for rtkit to answer before restarting the portals. A trap unmasks it if anything fails, and a runtime mask does not survive a reboot. A client that asked while it was masked stays at normal priority rather than taking a grant. The repair also: - skips an empty logged-in user list instead of repairing user ""; - installs rtkit with sudo -n pacman rather than omarchy-pkg-add, which runs plain sudo and could prompt; - always does the machine-wide part when run as root, so a user's own run after a root-run 4.0 upgrade needs no sudo even where rtkit was installed by hand; - finds the caller's session bus under /run/user when its environment lacks it, as omarchy-upgrade-to-quattro's migrations run, and repairs no portal or audio units for a caller that has no session; - skips /proc entries a user's own sweep cannot read, which hidepid=1 shows but hides, instead of staying pending on every run.
# Conflicts: # test/shell.d/upgrade-to-quattro-test.sh
AGENTS.md asks for unquoted variables and quoted string literals inside [[ ]], and for full if blocks rather than an exit in one branch that leaves the following statements unreachable. Apply both to omarchy-realtime-repair and its test: the comparisons quote their literals and not their variables, and the caller's own part moves into repair_own_session, which the command runs in an if block unless it runs as root, and which returns early when the caller has no session bus. The compared values are start times, UIDs and user names, which hold no glob characters, so no comparison changes meaning. The test passes 40 of 40 as a regular user and as root.
The repair masks rtkit-daemon for its install and an EXIT trap unmasks it. When cached sudo expires while pacman runs, as it can for omarchy-migrate run by hand, the trap's sudo -n fails too and rtkit silently stays masked. That state grants nothing and kills nothing, and the pending marker makes the next run with sudo unmask it first, as a reboot does; but the user was not told. The trap now says so. The test lets sudo expire after the install, checks that rtkit stays masked, the migration stays pending and the message is printed, and that the next run with sudo releases rtkit and finishes.
Each user's omarchy update holds only its own lock, under that user's runtime directory, and omarchy-migrate takes none, so two users can run the rtkit migration at once. Both mask rtkit and start the install; the second one's pacman fails on db.lck, and its exit trap unmasks rtkit while the first one's transaction is still extracting it, which is the window the mask exists to close. The machine-wide part now takes a flock on a root-owned file in /run, which every user can open read-only, and a second run waits for the first, then finds rtkit installed and finishes. sudo applies the caller's umask, so under umask 077 the file would be root's alone and no user could open it again; the mode is set explicitly, keeping the inode the lock sits on.
An app that keeps starting PipeWire clients against a stale portal gets a fresh zero every time, and after ten passes the repair stops before installing rtkit. The error listed PIDs only; it now says to close the apps that keep starting them and run the update again.
The repository indents with two spaces, as its WirePlumber drop-ins do. PipeWire's config parser ignores the whitespace, so nothing changes at runtime.
This was referenced Oct 28, 2026
This was referenced Oct 30, 2026
This was referenced Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Omarchy on x86 ships without rtkit, so PipeWire never runs realtime and apps launched from the desktop carry a realtime budget of zero, which the kernel enforces with SIGKILL. This installs rtkit, repairs running sessions in the right order so the install itself kills nothing, and keeps PipeWire clients from ever taking a zero again.
On two real machines, each upgraded the way users upgrade:
SCHED_OTHER→SCHED_RR20SCHED_OTHER→SCHED_RR20What users see
Two problems with one cause, on every x86 install:
render process gone: killed, exitCode 9. It hits apps started from the Super+Space menu, and any app that loads PipeWire itself. (Without rtkit, apps started from omarchy-shell inherit RLIMIT_RTTIME=0 and the kernel RT watchdog SIGKILLs them (Electron/Chromium, claude-desktop) #16348, Apps started from the Super+Space menu inherit RLIMIT_RTTIME=0 (PipeWire + portal without rtkit) and are SIGKILLed once they get a real-time thread; since 4.0.4 this kills SteamVR #12443, X web app launched from the Super+Space app menu exits silently within seconds; same web app via Super+Shift+X or a terminal is fine #11862)Why
rtkit is the system service that grants realtime scheduling to user programs that ask for it. Omarchy lists it in
omarchy-aarch64.packagesonly, and on Arch onlypulseaudiorequires it. Without it:SCHED_OTHERand queue behind everything else, so under load they miss the sound card's deadline.module-rtturns it into a hardRLIMIT_RTTIMEof 0 (src/modules/module-rt.c,rtkit_finish_init). The shell is a PipeWire client, so everything it launches inherits the zero, and Chromium sets it on itself by loading libpipewire. With a hard limit of 0, the kernel's CPU-timer check (check_thread_timers→check_rlimit) sends SIGKILL even to a thread that never ran realtime.Installing rtkit alone does not fix a running machine, and can make it worse. The portal reads rtkit only once, at startup. rtkit accepts a hard limit of 0 (
verify_process_rttime), and a client that cached a zero still asks for priority 1 or more. So an app that already holds the zero can now be made realtime, and is killed.What this changes
install/omarchy-base.packagesetc/pipewire/{client,jack}.conf.d/50-omarchy-rtkit.confrtportal.enabled = false, as stockpipewire.confandpipewire-pulse.confdo for the servers and #12958 did for the speaker tuning. Host apps ask rtkit directly, so a portal stuck at 0 (flatpak/xdg-desktop-portal#2110) can't hand them a zero.bin/omarchy-realtime-repairmigrations/1789747667.shomarchy-realtime-repair. A second run changes nothing.bin/omarchy-upgrade-to-quattroomarchy-realtime-repairas root first, right after the newomarchypackage is in. The repair installs rtkit itself, and a failed repair stops the upgrade before any other package.omarchy-realtime-repairruns in two parts:rtkit-daemonfor the runtime, install rtkit, and raise again;A portal that fails to restart never skips step 6; the repair fails only after it. A trap unmasks rtkit if anything fails. If sudo has expired by then, rtkit stays masked, which grants nothing; the command says so, and the next run with sudo, or a reboot, releases it. One run at a time does this part: each user's
omarchy updatelocks only its own runtime directory, so it takes a lock on a root-owned file in/runthat every user can open, and a second run waits, then finds rtkit installed.pipewire.service's main process) isn't realtime. This needs sudo only when the caller holds zeros, so a second user, or one without sudo, finishes without it.The zeros are raised before the install, not from a package dependency or scriptlet, because dbus-broker watches its service directories and reloads when they change (
src/launch/launcher.c). Unmasked, rtkit can be activated the moment pacman extracts it, before any install script or ALPM hook runs, and even before the sysusers hook has created thertkituser, which makes it fail into systemd's start limit and come back seconds later. The mask holds it until the transaction is done; a client that asks meanwhile simply stays at normal priority.The machine-wide part uses the sudo that
omarchy updatehas already authorized. A marker under/var/lib/omarchy, written before the install and removed when that part finishes, makes an interrupted run repeat it; a fresh install never has one.Proof
Real upgrades
Each machine got exactly what users will get:
omarchyandomarchy-settingsbuilt from the version it already ran with only this branch on top, installed with pacman, and the migration run byomarchy-migrateon a pty, asomarchy updateruns it.omarchy-devat this branch's baseinotifywait,wl-paste, …SCHED_RR20, 200000/200000SCHED_RR20, 200000/200000On both machines the first attempt ran without sudo, because the timed passwordless-sudo grant used for the test is revoked by
omarchy-settings' own pre-transaction hook. The migration then changed nothing, said why, stayed pending, and caused no kills; the next run with sudo finished it.Audio under load
No listening needed: a silent stream (volume 0) plays to a real output while
stress-ngloads the machine fromapp.slicewith CPU hogs, context switching, memory pressure and disk I/O. The count is PipeWire's own xrun counter on the ALSA sink (pw-top's ERR): cycles where the card ran dry. Quantum 128 is 2.7 ms at 48 kHz, about what calls and games ask for; 1024 is the default. 3 runs of 20 s per cell.Before and after the real upgrade on the XPS 16:
Before and after the migration on the desktop, its own session, where
omarchy-devat this branch's base was brought to this branch's head:At the default quantum the desktop had no xruns either way, but no margin to spare: its audio thread waited up to 18.1 ms of a 21.3 ms cycle. CPU hogs alone barely matter, because BORE keeps the audio thread near the front; the xruns come with memory and disk pressure.
What apps get. With the server on time, a client that does not run realtime itself shows its own misses instead of the card's.
pw-play, used for the silent stream, processes audio in its main loop (pw-cat.c), whichmodule-rtnever makes realtime. On the XPS 16, changing only the server's policy:SCHED_OTHERSCHED_RR20pw-play: card xruns / its own stream's xrunsA clean install is right from the first boot
An rc ISO was built from omarchy-iso
quattrowith this branch as the Omarchy source (bin/omarchy-iso-make --rc --local-source …, sha256015c04b2…44c1). It and the published 4.5.0rc1 ISO were each installed with omarchy-iso's own test harness: encrypted, booted through UEFI firmware and Limine, passphrase typed on the graphical Plymouth prompt.SCHED_OTHERSCHED_RR20RLIMIT_RTTIMEmod.rt: RTKit errorlines this bootUpgrading a deliberately poisoned 4.0.6 session in VMs
Each case starts from the 4.0.6 image with a session poisoned before the update: the shell, a terminal holding a hard 0, reconnecting PipeWire clients, a client spawned every 2 s through the whole update, a Chromium-like process that sets the zero on itself and forks renderers, and a second logged-in user. Each cell is 3 runs (ranges shown) at
5fcb59e4, the code in this PR; rows 8 and 10 ran at4294aa75, whose code for those paths is unchanged."Kills" counts every kernel
RT Watchdog Timeoutfrom the moment the migration starts, whatever its cause. For this branch, every kill was traced through the rtkit journal, pacman's log and a kernel trace ofSIGKILLwith code 128.058843c)omarchy updateSCHED_OTHER; 10–12 left at 0; marked doneRR20; doneRR20; doneRR20; done/procmountedhidepid=2/procmountedhidepid=1omarchy-migrateby hand, without sudoRR1; a new client 0/0RR1; a new client 0/0RR1 (see "Not in this PR"); a new client 200000/200000; 0 kills in 60 s¹ A Chromium-like renderer forked before the sweep reached its parent, inheriting the parent's zero and dying on its own CPU timer, without any realtime grant: the bug this PR fixes, finishing in the first 2.5 s.
² rtkit, installed by hand 20 s before the update, was already granting realtime to processes holding a zero. Those kills land 0.7–3 s into the migration, before the repair's first sweep at 3.7 s; none after it.
³ PipeWire stays
SCHED_OTHERunderhidepid, because rtkit itself cannot see user processes there.⁴ Every one is a renderer of the Chromium-like process, dying on its CPU timer with no rtkit present: the unrepaired bug, since nothing can raise a limit without sudo. Over the whole 300 s prompt, #12428 and #16353 reach 100–103.
Two users updating at once. Both users of a poisoned 4.0.6 VM, each with sudo that doesn't prompt, ran the repair at the same moment while a client kept asking rtkit for its budget. Before the lock (
262b7b14), the second run's install failed on pacman's lock ("unable to lock database"), its exit trap unmasked rtkit while the first run's transaction was still extracting it, and rtkit was activated four times before its user existed ("Failed to find user 'rtkit'"), twice into a failed start; that user's update failed and stayed pending. With the lock (c44938c6), the second run printed "Waiting for another realtime repair to finish...", the activation during the install was refused as masked, both runs exited 0, and nothing was left at 0, with both portals at 200000 and 0 kills.rtkit is masked through its own install. In every run, dbus-broker reloaded the moment pacman extracted rtkit, before the
rtkituser existed ("NSS returned no entry for 'rtkit'"), and activation requests in that window were refused: "Activation request for 'org.freedesktop.RealtimeKit1' failed: The systemd unit 'rtkit-daemon.service' is masked." After the unmask, rtkit answered at once. In 18 runs there was no "Failed to find user 'rtkit'" and no realtime grant to a process holding a zero; before the mask, that race hit 4 of 18 runs and killed up to 79 portal clients in one.Upgrading from 3.x
omarchy-upgrade-to-quattroinstalls the base list, which now carries rtkit, into the running 3.x session before any migration runs, so it runsomarchy-realtime-repairas root first. Each run booted a fresh copy of an encrypted Omarchy 3.8.4 install (from its release ISO, checksum verified), poisoned the session as above, and ran this branch's upgrade script with this branch's packages to the end.RR20/tmp, 2 runs ⁵RR20RR20In the control, rtkit-daemon also failed seven times with "Failed to find user 'rtkit'" as pacman extracted it. No branch run logged that or any realtime grant to a process holding a zero.
⁵ Run as root, the 3.x upgrade cannot finish on
quattrotoday, independent of this PR: it runs the user's migrations without the user's session environment, so migration1785608166fails atsystemctl --user show-environmentwhile the user is logged in, and run from/rootthe user-transition step fails earlier on root's working directory. These two runs passedXDG_RUNTIME_DIRandDBUS_SESSION_BUS_ADDRESSinrun_as_user_omarchy, a two-line test patch, to reach the end; that fix belongs in its own PR.Tests
test/shell.d/realtime-repair-test.shrunsomarchy-realtime-repairagainst a fake/procwith only the system boundary stubbed. All 44 cases pass, as a regular user and as root, and each rule was checked by removing it and watching its case go red: two runs at once, where the second waits instead of failing on pacman's lock and unmasking rtkit in the middle of the first one's install, the lock staying readable under a umask of 077, raising before installing, the marker written before the install and cleared after, rtkit masked through its install and released even when the install fails, or reported when expired sudo cannot release it, the final pass after a failed portal restart, the caller's sweeps around its own portal repair, and reaching another user's session only through sudo.test/shell.d/upgrade-to-quattro-test.shruns the upgrade's package step with pacman and sudo stubbed, and checks that the repair runs before the base list and that a failed repair stops the upgrade../test/clipasses, and the branch merges cleanly onto currentquattro.How other systems do it
pipewirepackage itself hasRequires: rtkitpipewire-binRecommends rtkit, and apt installs Recommends by defaultpipewire-bin's Recommends: rtkit is on the 24.04.3 and 25.10 desktop ISOsrtkitandrealtime-privilegessecurity.rtkit.enabledefaults to false; the wiki recommends turning it on with PipeWirepipewire; onlypulseaudiorequires itsched_prim.c(MAX_UNSAFE_RT_QUANTA),priority.c(TH_SFLAG_FAILSAFE)SystemResponsivenesssets the share of CPU kept for everything else, and threads that use up their share drop to 1-7.Linux is the only one of these where a zero budget becomes a kill. That is why this branch both installs rtkit and keeps clients from ever taking a zero.
Not in this PR
context.moduleslist (lib/wp/core.c,lib/wp/conf.c), so awireplumber.conf.ddrop-in cannot reachmodule-rt. That was tried and measured: under a stale portal WirePlumber still came up at 0/0 with realtime threads. The upgrade is covered because the audio units restart after the portals are repaired; a portal that later fails its one read of rtkit at login is the upstream bug below.module-rtto stop applying one. PipeWire configs other than client and JACK, such asfilter-chain.conf, also still default to the portal; Omarchy's speaker tuning has used rtkit directly since Ask RTKit directly for the speaker tuning's realtime priority #12958.hidepid: with/procmountedhidepid, rtkit itself cannot see user processes, so PipeWire stays atSCHED_OTHERthere. The kills are still fixed.kernel.sched_rt_runtime_usstays at 1000000, the upstream default since torvalds/linux@c2e390197ad1.SCHED_FIFOandSCHED_RRthrottling now comes from the fair server (50 ms per second per CPU), so 950000 would only changeSCHED_DEADLINEadmission.session.sliceoverapp.slice(Give session.slice CPU weight over app.slice so builds cannot stall input #7651) is a separate question;cpu.weightdoes not apply to realtime threads.sched_util_clamp_min_rt_defaultat its default of 1024, a realtime thread only fits a core of capacity 1024. On the XPS 16 that is one core: under load the realtime audio thread ran oncpu2for every one of its wakeups. Whether lowering it to 0 saves battery without new xruns is to be measured separately.Credits
Fixes #9390
Fixes #12443
Fixes #11862
Fixes #16348