Skip to content

Give PipeWire realtime with rtkit and stop the silent app kills - #16824

Merged
emirb merged 16 commits into
quattrofrom
rtkit-session-repair
Oct 28, 2026
Merged

emirb merged 16 commits into
quattrofrom
rtkit-session-repair

Conversation

@emirb

@emirb emirb commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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:

Dell XPS 16 laptop Desktop (i5-12600K)
Processes holding a zero budget 24 → 0 11 → 0
Apps killed by the upgrade 0 (15 Chromium processes survived) 0
PipeWire, pipewire-pulse, WirePlumber SCHED_OTHER → SCHED_RR 20 SCHED_OTHER → SCHED_RR 20
Sound-card xruns under load, quantum 128 111 → 0 92 → 0 (S/PDIF)
Worst audio-thread wakeup under load 12.2 ms → 22 µs 12.5 ms → 10 µs

What users see

Two problems with one cause, on every x86 install:

Why

rtkit is the system service that grants realtime scheduling to user programs that ask for it. Omarchy lists it in omarchy-aarch64.packages only, and on Arch only pulseaudio requires it. Without it:

  1. PipeWire never gets realtime. Its audio threads run at SCHED_OTHER and queue behind everything else, so under load they miss the sound card's deadline.
  2. Clients get a zero budget. xdg-desktop-portal reports a realtime budget of 0, and PipeWire's client module-rt turns it into a hard RLIMIT_RTTIME of 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

Piece What it does
install/omarchy-base.packages Installs rtkit on every platform; the aarch64 entry moves here.
etc/pipewire/{client,jack}.conf.d/50-omarchy-rtkit.conf Sets rtportal.enabled = false, as stock pipewire.conf and pipewire-pulse.conf do 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-repair Does the repair, in two parts, below. Never prompts; when it can't repair or inspect something, it fails and the migration stays pending.
migrations/1789747667.sh Runs omarchy-realtime-repair. A second run changes nothing.
bin/omarchy-upgrade-to-quattro The 3.x → 4 upgrade installs the base list in the running 3.x session, so it runs omarchy-realtime-repair as root first, right after the new omarchy package is in. The repair installs rtkit itself, and a failed repair stops the upgrade before any other package.

omarchy-realtime-repair runs in two parts:

  • Once per machine, as root, while rtkit is missing, an earlier run stopped after installing it, or whenever root runs it:
    1. raise every logged-in user's hard zero to rtkit's default 200 ms;
    2. mask rtkit-daemon for the runtime, install rtkit, and raise again;
    3. unmask it and wait until rtkit answers;
    4. raise the zeros to rtkit's live budget;
    5. restart each user's portal that still reports 0;
    6. raise once more.
      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 update locks only its own runtime directory, so it takes a lock on a root-owned file in /run that every user can open, and a second run waits, then finds rtkit installed.
  • Every run, for the caller only: raise the caller's own zeros, restart the caller's portal if it reports 0, raise again, and restart the caller's audio units if the PipeWire server (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 the rtkit user, 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 update has 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: omarchy and omarchy-settings built from the version it already ran with only this branch on top, installed with pacman, and the migration run by omarchy-migrate on a pty, as omarchy update runs it.

Dell XPS 16, Core Ultra X7 358H, on battery Desktop, i5-12600K
Starting point 4.5.0rc1, Chromium open omarchy-dev at this branch's base
rtkit installed by the migration installed by the migration
Processes holding a hard 0 24 of 67 → 0 of 72 11 of 104 → 0 of 103
What held them Chromium (15), the shell, WirePlumber, … the shell, inotifywait, wl-paste, …
Those processes afterwards 23 running with 200000 µs; WirePlumber restarted by the migration, as intended all 11 running
PipeWire, pipewire-pulse, WirePlumber SCHED_RR 20, 200000/200000 SCHED_RR 20, 200000/200000
Kernel RT watchdog kills, traced SIGKILLs with code 128 0, 0 0, 0
Failed units, coredumps 0, 0 0, 0
Migration done; a second run changed nothing done; a second run changed nothing

On 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-ng loads the machine from app.slice with 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:

Output, quantum Card xruns, before → after Worst audio-thread wakeup, before → after
Speakers, 128 111 → 0 12.2 ms → 22 µs
Speakers, 1024 1 → 0 26.9 ms → 20 µs
Speaker tuning, 128 3 → 0 15.3 ms → 280 µs
Speaker tuning, 1024 1 → 0 11.4 ms → 25 µs
Either output, idle 0 → 0 ≤ 140 µs both

Before and after the migration on the desktop, its own session, where omarchy-dev at this branch's base was brought to this branch's head:

Output, quantum Card xruns, before → after Worst audio-thread wakeup, before → after Waits over 1 ms, before → after
S/PDIF, 128 92 → 0 12.5 ms → 10 µs 138 → 0 of 7,440
Rear 3.5 mm, 128 97 → 0 14.6 ms → 113 µs 234 → 0 of 7,300
Front 3.5 mm, 128 177 → 0 11.7 ms → 14 µs 57 → 0 of 7,465
S/PDIF, 1024 0 → 0 18.1 ms → 10 µs 39 → 0 of 937
Rear 3.5 mm, 1024 0 → 0 10.6 ms → 29 µs 10 → 0 of 937
Front 3.5 mm, 1024 0 → 0 13.0 ms → 19 µs 23 → 0 of 937
Any output, idle 0 → 0 ≤ 167 µs both 0 → 0

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), which module-rt never makes realtime. On the XPS 16, changing only the server's policy:

Speakers, quantum 128 Server SCHED_OTHER Server SCHED_RR 20
pw-play: card xruns / its own stream's xruns 90 / 53 0 / 536
A PulseAudio client through pipewire-pulse, as browsers and games play: card / stream 2 / 25 0 / 0
The PulseAudio client: worst server wakeup 12.6 ms 20 µs

A clean install is right from the first boot

An rc ISO was built from omarchy-iso quattro with this branch as the Omarchy source (bin/omarchy-iso-make --rc --local-source …, sha256 015c04b2…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.

After first login 4.5.0rc1 ISO ISO with this branch
rtkit, portal budget not installed, 0 0.14-2, 200000 µs
PipeWire, pipewire-pulse, WirePlumber SCHED_OTHER SCHED_RR 20
Shell's RLIMIT_RTTIME 0 / 0 200000 / 200000
Processes holding a hard 0 6 of 47 0 of 49
mod.rt: RTKit error lines this boot 12 0
A Chromium-like client that opens its own PipeWire context 0/0; 6 of 6 children killed 200000; 0 of 8 killed
RT kills, failed units, coredumps, pending migrations not recorded, 0, 0, none 0, 0, 0, none

Upgrading 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 at 4294aa75, whose code for those paths is unchanged.

"Kills" counts every kernel RT Watchdog Timeout from 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 of SIGKILL with code 128.

Case #12428 as it stands (058843c) #16353 This branch
1. omarchy update 59–68 kills; 10–11 processes left at 0; second user's portal still 0; marked done 23–36 kills; PipeWire stays SCHED_OTHER; 10–12 left at 0; marked done 0–1 kill ¹; none left at 0; RR 20; done
2. Second run on the fixed machine — — no portal restart, no limit change, 0 kills
3. Second user, no sudo, after the first user's run — — done without sudo; no zeros; portal 200000
4. The user's own portal restart fails 56–64 kills; 13–16 left at 0; marked done 27–31 kills; 12–16 left at 0; marked done 0–1 kill ¹; none left at 0; stays pending
5. Retry after the portal is fixed 53–69 kills; 15–17 left at 0 23–40 kills; 14–15 left at 0 0 kills; both portals 200000; RR 20; done
6. rtkit already installed by hand, portals stale 46–59 kills; 9–10 left at 0 54–103 kills; 12–15 left at 0; the user's portal stays 0 0, 5 and 8 kills ²; 1 left at 0 (the second user's, raised by that user's own run); RR 20; done
7. /proc mounted hidepid=2 18 kills; 9–12 left at 0 18 kills; 9–10 left at 0 0–1 kill ¹; none left at 0; done ³
8. /proc mounted hidepid=1 18–19 kills; 10–13 left at 0 18–19 kills; 9–10 left at 0 0–1 kill ¹; none left at 0; done ³
9. omarchy-migrate by hand, without sudo prompts for sudo and waits about 300 s, then fails; rtkit not installed; 17–18 kills in the first 60 s ⁴ prompts for sudo and waits about 300 s, then fails; rtkit not installed; 17–18 kills in the first 60 s ⁴ fails at once without prompting and changes nothing; stays pending; 17–18 kills in the next 60 s ⁴
10. Portal made stale again after the fix, WirePlumber restarted WirePlumber 0/0 at RR 1; a new client 0/0 WirePlumber 0/0 at RR 1; a new client 0/0 WirePlumber 0/0 at RR 1 (see "Not in this PR"); a new client 200000/200000; 0 kills in 60 s
11. A portal client started every 250 ms through the update, as a Flatpak app would not run not run 310–370 portal clients, every one handed 0/0 by the still-stale portal; the repair cannot get ahead of them, so it installs nothing and stays pending. No portal client was killed, because rtkit never arrived; the moment between rtkit's install and the portal restart was therefore not reached in any run

¹ 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_OTHER under hidepid, 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 rtkit user 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-quattro installs the base list, which now carries rtkit, into the running 3.x session before any migration runs, so it runs omarchy-realtime-repair as 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.

Run Upgrade rtkit installed by Kills from upgrade start After the repair Zeros left Portals (own / second user) PipeWire after
As the user, 2 runs exit 0, nothing pending the repair, masked through its install, before the base list 34 and 32, all renderers ¹ 0 kills 0 200000 / 200000 RR 20
As root from /tmp, 2 runs ⁵ exit 0, nothing pending the repair 30 and 30, all renderers ¹ 0 kills 0 200000 / 200000 RR 20
Control: the repair step removed exit 0, nothing pending the base list, unmasked 104: 71 renderers ¹ and 33 processes holding a zero, made realtime and killed — 1 200000 / 0 RR 20

In 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 quattro today, independent of this PR: it runs the user's migrations without the user's session environment, so migration 1785608166 fails at systemctl --user show-environment while the user is logged in, and run from /root the user-transition step fails earlier on root's working directory. These two runs passed XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS in run_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.sh runs omarchy-realtime-repair against a fake /proc with 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.sh runs 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/cli passes, and the branch merges cleanly onto current quattro.

How other systems do it

System How audio threads get realtime Source
Fedora the pipewire package itself has Requires: rtkit pipewire.spec
Debian pipewire-bin Recommends rtkit, and apt installs Recommends by default debian/control
Ubuntu not seeded, but pulled in by pipewire-bin's Recommends: rtkit is on the 24.04.3 and 25.10 desktop ISOs 25.10 ISO manifest
CachyOS the desktop ISO ships rtkit and realtime-privileges ISO package list
NixOS opt-in: security.rtkit.enable defaults to false; the wiki recommends turning it on with PipeWire rtkit.nix
Arch, and Omarchy x86 until now an optional dependency of pipewire; only pulseaudio requires it rtkit
macOS Core Audio's IO thread is a realtime thread, and the audio frameworks join client render threads to the device's workgroup so the scheduler knows they share its deadline. A realtime thread that runs past 100 quanta without blocking is demoted to normal priority, then restored after twice that time. It is never killed. WWDC20 Audio Workgroups, XNU sched_prim.c (MAX_UNSAFE_RT_QUANTA), priority.c (TH_SFLAG_FAILSAFE)
Windows MMCSS raises threads that register for a task such as "Audio" or "Pro Audio": the High category runs at priority 23-26 and is "designed for Pro Audio tasks", Medium at 16-22. SystemResponsiveness sets the share of CPU kept for everything else, and threads that use up their share drop to 1-7. MMCSS

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

  • WirePlumber still asks through the portal. It creates its PipeWire context with no config of its own and passes PipeWire only its context.modules list (lib/wp/core.c, lib/wp/conf.c), so a wireplumber.conf.d drop-in cannot reach module-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.
  • Flatpak apps still use the portal. During the update, one that starts in the moment between rtkit's unmask and its portal's restart, typically under a second, can still take the stale zero and be made realtime: a portal restarted while rtkit is masked would read 0 again, so that order cannot change from here. Beyond the update they depend on upstream: the open fix realtime: skip export when rtkit cannot provide its properties flatpak/xdg-desktop-portal#2139, which stops the portal exporting a zero, and the open PipeWire report pipewire#5429, which asks module-rt to stop applying one. PipeWire configs other than client and JACK, such as filter-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 /proc mounted hidepid, rtkit itself cannot see user processes, so PipeWire stays at SCHED_OTHER there. The kills are still fixed.
  • kernel.sched_rt_runtime_us stays at 1000000, the upstream default since torvalds/linux@c2e390197ad1. SCHED_FIFO and SCHED_RR throttling now comes from the fair server (50 ms per second per CPU), so 950000 would only change SCHED_DEADLINE admission.
  • CPU weights: session.slice over app.slice (Give session.slice CPU weight over app.slice so builds cannot stall input #7651) is a separate question; cpu.weight does not apply to realtime threads.
  • Hybrid CPUs: with sched_util_clamp_min_rt_default at 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 on cpu2 for 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

zacksiri and others added 4 commits September 18, 2026 23:08
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>
@emirb emirb added this to the 4.5 milestone Oct 27, 2026
@emirb emirb added the bug Something isn't working label Oct 27, 2026
emirb added 3 commits October 27, 2026 23:11
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
emirb marked this pull request as ready for review October 27, 2026 23:17
@emirb
emirb force-pushed the rtkit-session-repair branch from bb777b6 to 4294aa7 Compare October 27, 2026 23:19
@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Adds rtkit on every platform and repairs running sessions before enabling realtime scheduling.

  • The update repairs zero realtime limits before it installs rtkit.
  • Each user's audio session restarts after its portal and limits are repaired.
  • Host PipeWire clients ask rtkit directly instead of relying on the portal.
  • Every platform now installs rtkit from the shared package list.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Machine repair needed] --> B[Take shared lock]
  B --> C[Raise zero budgets]
  C --> D[Mask rtkit and install it]
  D --> E[Raise budgets again]
  E --> F[Unmask rtkit and read its budget]
  F --> G[Raise budgets and repair portals]
  G --> H[Run final budget pass]
  H --> I[Clear pending marker on success]
  I --> J[Repair caller's session and audio]
Loading

Reviews (10) · Last reviewed commit: "Indent the rtkit PipeWire drop-ins with ..." · Reviewed by Greptile

Comment thread install/omarchy-base.packages Resolved
Comment thread bin/omarchy-realtime-repair Resolved
Comment thread test/shell.d/realtime-repair-test.sh Resolved
emirb added 4 commits October 28, 2026 00:45
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
Comment thread bin/omarchy-realtime-repair Resolved
emirb added 4 commits October 28, 2026 01:18
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.
@emirb
emirb merged commit b58e5b9 into quattro Oct 28, 2026
2 checks passed
@emirb
emirb deleted the rtkit-session-repair branch October 29, 2026 09:19
@emirb emirb modified the milestones: 4.5, 4.5.1 Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment