Skip to content

Install rtkit so PipeWire gets realtime priority - #12428

Closed
zacksiri wants to merge 4 commits into
omacom:quattrofrom
zacksiri:add-rtkit
Closed

zacksiri wants to merge 4 commits into
omacom:quattrofrom
zacksiri:add-rtkit

Conversation

@zacksiri

@zacksiri zacksiri commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9390

Summary

Omarchy ships the full PipeWire stack but not rtkit. PipeWire requests realtime scheduling from RealtimeKit over D-Bus at startup; with the service absent, every mod.rt request fails (RTKit error: org.freedesktop.DBus.Error.ServiceUnknown) and all data-loop threads run at SCHED_OTHER nice 0. The fallback paths are also absent on a stock install: no LimitRTPRIO in the shipped user units, no realtime-privileges group, empty limits.d. The result is audio xruns/crackling under sustained CPU/GPU load — invisible at idle, which is what makes it so hard to trace.

Changes

  • install/omarchy-other.packages: add rtkit next to the pipewire family — covers fresh installs
  • migrations/1789747667.sh: repair existing installs — install rtkit via omarchy-pkg-add and restart the running audio units so PipeWire's priority request succeeds without a reboot. Idempotent, matching the established migration patterns (cf. the kernel-headers and KEF no-suspend migrations)

Fresh ISO installs mark all shipped migrations complete during finalize-user, so the two paths don't overlap.

Verification

  • Confirmed the failure mode on Omarchy 4.0.4, NVIDIA multi-GPU desktop: pacman -Q rtkit missing, journal full of ServiceUnknown, data threads at SCHED_OTHER — reported on PipeWire runs without realtime priority on a stock install (rtkit is not included) #9390 with two further hardware confirmations there (Intel T2 MacBook, ThinkPad X1 Carbon)
  • After installing rtkit 0.14 alone and restarting pipewire/wireplumber: main PIDs get nice -11, data loops get RT scheduling, and crackling under full 3-GPU llama.cpp inference load is gone
  • bash -n clean; migration follows the sourced-script conventions in agents/skills/migrations.md

Fixes #12443

Fixes #11862

Fixes #16348

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 omacom#9390
@zacksiri

Copy link
Copy Markdown
Contributor Author

Relationship to #7971: that PR takes a different mechanism (realtime-privileges package + realtime group + pam_limits so processes can self-elevate via RLIMIT_RTPRIO, also covering Hyprland's own RT request), while this one is the minimal audio-only fix via rtkit, directly targeting #9390. PipeWire's module-rt tries rtkit first and falls back to RLIMIT_RTPRIO, so the two are compatible rather than competing — rtkit would win for PipeWire if both landed, and #7971 would still add value for the compositor. Neither blocks the other.

One packaging note in case it comes up: #7971's body states a package listed only in omarchy-other.packages "never reaches a machine". That's no longer true for the current repo — docs/file-layout.md says both omarchy-base.packages and omarchy-other.packages are ISO pacstrap lists, and pipewire-alsa/pipewire-jack/pipewire-pulse ship exclusively in omarchy-other.packages while being installed explicitly on every stock system. rtkit is therefore placed alongside the pipewire family it supports. Happy to move it if maintainers prefer it in omarchy-base.packages.

@kh4rit-bot

Copy link
Copy Markdown

This also fixes something worse than xruns, see #12443. Without rtkit, xdg-desktop-portal's Realtime interface reports RTTimeUSecMax=0, and module-rt in every PipeWire client applies that as a hard RLIMIT_RTTIME of 0 to its own process. quickshell is such a client and is also the launcher, so everything started from the menu inherits the zero and gets SIGKILLed by the kernel the moment it has a real-time thread. On linux-omarchy that kills SteamVR's compositor at startup.

One thing I measured that matters for the migration: installing rtkit was not enough on a running session.

$ pacman -S rtkit
$ busctl --user get-property org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Realtime RTTimeUSecMax
x 0                                    # still 0, new PipeWire clients still get RLIMIT_RTTIME 0/0
$ systemctl --user restart xdg-desktop-portal
x 200000                               # new PipeWire clients now get 200000/200000

So the migration probably wants xdg-desktop-portal.service in its try-restart list too. Processes that already carry the hard zero keep it, since a hard limit can't be raised: the shell, and so every menu launch, stays affected until omarchy-restart-shell or the next login.

@michaeldeby

Copy link
Copy Markdown
Contributor

Heads-up for the migration here: omarchy-speaker-tuning.service is PartOf=pipewire.service, so this migration's try-restart restarts the tuning host too while the portal still reports a zero realtime budget, and the kernel then kills the host on every playback until the next login. #12958 makes the host ask RTKit directly (as pipewire.conf does) and updates installed copies, so it is safe to land in either order.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
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>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review and removed verified Omarchy Triage has verified that this issue is ready for final review labels Oct 1, 2026
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

Adds rtkit to the shared package set so fresh installs can give PipeWire realtime priority.

  • PipeWire can request real-time priority on fresh and existing installs.

Reviews (2) · Last reviewed commit: "Drop the aarch64 rtkit entry now that th..." · Reviewed by Greptile

@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and run on a VM built from the current Omarchy ISO. The problem is real and this is the right size of fix for it, but two things kept it from working as intended, so I pushed one commit to your branch (dac602f).

What I saw before the change. rtkit was not installed, the journal showed mod.rt: RTKit error: org.freedesktop.DBus.Error.ServiceUnknown, every thread of pipewire, pipewire-pulse and wireplumber ran SCHED_OTHER, and the portal's RTTimeUSecMax was 0.

What I fixed:

  • Fresh installs never got rtkit. install/omarchy-other.packages only seeds the ISO's offline mirror. The installer pacstraps omarchy-base.packages (_runtime_package_list in omarchy-iso's phases_impl.py), and an entry in the other list is installed only when something else asks for it. Fresh installs also mark this migration as done, so they would have stayed without rtkit. It now lives in omarchy-base.packages.
  • The migration gave WirePlumber and the running shell a zero realtime budget. xdg-desktop-portal reads rtkit's limits once, when it starts. With your migration as it was, pipewire and pipewire-pulse came back at RR 20 with a 200000 µs RLIMIT_RTTIME. wireplumber, which goes through the portal, came back with SCHED_RR data loops and a hard RLIMIT_RTTIME of 0. The already-running quickshell went from unlimited to a hard 0 once it reconnected. That is 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's failure, and this migration was causing it. The migration now try-restarts xdg-desktop-portal.service before the audio units, as @kh4rit-bot measured. With that, the portal reports 200000, and pipewire, pipewire-pulse, wireplumber and quickshell all end with 200000 µs and the data loops at RR 20. Re-running the migration is a no-op. The same ordering means omarchy-speaker-tuning.service, restarted through PartOf=pipewire.service, also reads the refreshed portal. Ask RTKit directly for the speaker tuning's realtime priority #12958 remains independently useful.

A process that already carries a hard zero from before this update keeps it until it restarts. omarchy update restarts the shell at the end, which covers the launcher.

Tests: ./test/cli passes on the worker. ./test/shell has four failing files: ascii, branding-about-animation, locate and omarchy-kernel-migration. They fail identically on this branch's fork point without the change. Current quattro fails those and others on the same worker, so they are not from this PR. There are no CI checks on this PR.

Second opinion: Codex at medium effort reviewed the combined change and found no defects. It independently traced the ISO's install path to the same conclusion about the package list. Its agreement on the rest is just that, since its independence is not guaranteed.

Related: this now closes #9390 and #12443. #7971 grants realtime through realtime-privileges and the realtime group. That covers Hyprland as well, but it supplies no rtkit backend for the portal, so it does not fix #12443. The two overlap without being duplicates, and choosing between them is for the maintainer.

Waiting on the maintainer. Nothing is needed from you.

@omarchybot

Copy link
Copy Markdown
Collaborator

#12958 has merged into quattro and makes the speaker-tuning host ask RTKit directly rather than accepting a zero budget from a stale portal. This PR still has distinct work: installing rtkit and repairing the session/process-tree state behind #12443. Keep it open and rebase against the speaker-host migration; the merge does not install rtkit or repair resource limits inherited by other applications.

Scope checked by GPT-6 in Codex and Codex Medium against the reports and landed source; independence is not guaranteed. No runtime tests were rerun for this reconciliation.

@jandrusk

Copy link
Copy Markdown

Still the right fix for #12443 / #9390 after #12958 (speaker-host only). Installs rtkit + restarts portal before PipeWire so clients don't inherit RLIMIT_RTTIME=0. Clean; migration 1789747667.sh doesn't collide on quattro. Ready.

rdoupe added a commit to omarchy-asus/omarchy-asus that referenced this pull request Oct 18, 2026
…r a fresh install

Mirrors omacom/omarchy#12428 at dac602f5: after omarchy-pkg-add rtkit,
systemctl --user try-restart xdg-desktop-portal.service, then
pipewire.service pipewire-pulse.service wireplumber.service, errors
ignored. Without it the portal keeps RTTimeUSecMax=0 until the next login
and PipeWire clients get a hard RLIMIT_RTTIME of 0 (omacom/omarchy#12443).
Only when this run installed rtkit; nothing when it was already there or
the install failed (which now reports the fix as failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rdoupe added a commit to omarchy-asus/omarchy-asus that referenced this pull request Oct 18, 2026
…r a fresh install

Mirrors omacom/omarchy#12428 at dac602f5: after omarchy-pkg-add rtkit,
systemctl --user try-restart xdg-desktop-portal.service, then
pipewire.service pipewire-pulse.service wireplumber.service, errors
ignored. Without it the portal keeps RTTimeUSecMax=0 until the next login
and PipeWire clients get a hard RLIMIT_RTTIME of 0 (omacom/omarchy#12443).
Only when this run installed rtkit; nothing when it was already there or
the install failed (which now reports the fix as failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rdoupe added a commit to omarchy-asus/omarchy-asus that referenced this pull request Oct 18, 2026
…r a fresh install

Mirrors omacom/omarchy#12428 at dac602f5: after omarchy-pkg-add rtkit,
systemctl --user try-restart xdg-desktop-portal.service, then
pipewire.service pipewire-pulse.service wireplumber.service, errors
ignored. Without it the portal keeps RTTimeUSecMax=0 until the next login
and PipeWire clients get a hard RLIMIT_RTTIME of 0 (omacom/omarchy#12443).
Only when this run installed rtkit; nothing when it was already there or
the install failed (which now reports the fix as failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rdoupe added a commit to omarchy-asus/omarchy-asus that referenced this pull request Oct 18, 2026
… user config or /etc (#19)

* Add omarchy-asus-g16-apply: the G16 fixes that live in user config or /etc

A fresh stock Omarchy 4.0.5 install on a GA605KM that installs every
omarchy-asus package still lacks the fork's fixes that are applied through
an install leaf or migration rather than shipped as files. The new package
ships a user-invoked command, omarchy-asus-g16-apply, that applies them on
request with the fork's own files and commands (shipped byte-identical):

- hybrid-video: VA-API, mpv and Chromium decode on the iGPU
- hdmi-cursor: software cursor while a monitor on the RTX is connected
- audio-master: ALC285 Master at 100 % (only from Omarchy's 80 %)
- rtkit: omarchy-pkg-add rtkit
- asusd-power-profiles: the asusd hand-off drop-in, under an
  omarchy-asus basename in /etc, plus the migration's busctl calls
- winlock: enable g16-winlock.service
- opt-in: initramfs-no-nvidia, quiet-fans (disabled root service running
  the fork's helper on power-source/profile events), g16-widget

Installing the package changes nothing. --check reports every known G16
fix read-only (packages included; exits 10 when a default fix is missing),
--dry-run shows the changes, and any fix the user already has in a form of
their own is reported as "present (local)" and skipped, so a machine that
carries these fixes by hand sees no change. No file of Omarchy's is edited.

The USB-C power policy and the power-profile external owner change stock
omarchy-powerprofiles-set and are left to upstream (#15668, #15669).

README: a "Fresh G16 coverage" line under In progress and the recipe in
the repo layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* omarchy-asus-g16-apply: repair stale hybrid-video pins; follow symlinked Hyprland configs

hybrid-video now validates the pins it wrote against the current iGPU
render node. The Chromium pin is written under a marker comment; with the
vaapi-device line in the block under the fork's mpv comment, those are the
only pins the command ever touches again. A managed pin naming another node
(BIOS moved the PCI address) shows "needs repair" and applying repins it in
place; with no iGPU node (MUX switch) the managed pins are removed. Pins
the user wrote are never changed. --check exits 10 on "needs repair".

The scan for the user's own Hyprland settings uses find -L, so a
LIBVA_DRIVER_NAME or no_hardware_cursors in a symlinked hyprland.lua (or a
symlinked hypr directory) is detected and the fix stays "present (local)".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* omarchy-asus-g16-apply: hybrid-video mpv pin must exist, not just its comment

After iGPU -> RTX -> iGPU the cleanup dropped vaapi-device but kept the
fork's mpv comment, and the check took the comment alone as proof mpv was
pinned: with no Chromium flags file it reported applied and never restored
the pin. The check now needs this command's vaapi-device line, naming the
current iGPU node, inside the comment's block. Cleanup with no iGPU removes
the comment, hwdec=vaapi and vaapi-device from the block (and its blank
line when empty). A restore with the comment already present writes the
options right under it, so later cleanup recognizes them. The fork's
hybrid-video-decode.sh is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* omarchy-asus-g16-apply: README no longer names the setup script

The setup-script hook that offers this command lands separately, after
the keyring/setup PR (#3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* omarchy-asus-g16-apply README: runnable asusd undo commands

Name the three properties instead of a <property> placeholder that a shell
reads as redirections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* omarchy-asus-g16-apply rtkit: restart the portal, then PipeWire, after a fresh install

Mirrors omacom/omarchy#12428 at dac602f5: after omarchy-pkg-add rtkit,
systemctl --user try-restart xdg-desktop-portal.service, then
pipewire.service pipewire-pulse.service wireplumber.service, errors
ignored. Without it the portal keeps RTTimeUSecMax=0 until the next login
and PipeWire clients get a hard RLIMIT_RTTIME of 0 (omacom/omarchy#12443).
Only when this run installed rtkit; nothing when it was already there or
the install failed (which now reports the fix as failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* omarchy-asus-g16-apply initramfs-no-nvidia: stop before removing nvidia.conf if the backup fails

An unchecked mktemp or cp fell through to the removal, and a failed rebuild
would then restore an empty or partial copy. Verify the backup with cmp
first; on any failure warn and change nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* omarchy-asus-setup: offer the G16 fix packages and omarchy-asus-g16-apply

Optional last step on a fully upgraded system: install omarchy-asus-g16,
asus-rog-nkey-winlock and omarchy-asus-g16-apply (only those already in
the repo), show omarchy-asus-g16-apply --check and apply the missing
default fixes if the user says yes. Fixes the user already has in a form
of their own are left alone. Needs #3 (this script) and #19 (the
command); harmless before #19 publishes, since a package that isn't in
the repo is skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* omarchy-asus-g16-apply initramfs-no-nvidia: no rebuild or marker unless nvidia.conf is gone

A failed sudo rm fell through to limine-mkinitcpio and wrote the fork's
rebuild marker with nvidia still early-loaded, so a later fork migration
would skip it. Stop and change nothing if the removal fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* omarchy-asus-setup: offer the G16 fixes only on a GA605KM, or with --force

The setup accepts any GA605, but omarchy-asus-g16-apply stops unless DMI
says GA605KM, so on another GA605 the offered apply always failed. Skip the
offer there, and pass --force through when setup itself runs with --force.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* omarchy-asus-g16-apply: mark LOCAL_ONLY

No upstream build to track; plain pkgrel. Without the marker
bin/check-upstream reports bad-pkgrel and the auto-update pipeline would
treat it as an upstream package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: rdoupe <1207041+rdoupe@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
omarchybot and others added 2 commits October 23, 2026 03:20
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>
@omarchybot

Copy link
Copy Markdown
Collaborator

I brought quattro into this branch and folded in one change from #16353, then ran it again on a VM built from the current Omarchy ISO. Two commits are pushed to your branch, 058843c on top of a merge of quattro:

  • Merge of quattro (bf75248). The branch was 749 commits behind, and quattro has since given aarch64 its own rtkit entry in install/omarchy-aarch64.packages. The merge was clean.
  • Dropped that aarch64 entry (058843c). With rtkit in install/omarchy-base.packages, omarchy-pkg-defaults already gives it to every platform, so the aarch64 line and its comment that nothing pulls rtkit in there were redundant. @szaidi-code proposed this in Install rtkit on all platforms to prevent RLIMIT_RTTIME=0 kills (#16348) #16353 and is credited as co-author. omarchy-pkg-defaults lists rtkit exactly once for x86, aarch64, aarch64-apple and aarch64-n1x.

What it did on quattro 967bbdd. Before: no rtkit, the portal's RTTimeUSecMax 0, every thread of pipewire, pipewire-pulse and wireplumber SCHED_OTHER, and the shell at RLIMIT_RTTIME 0/0. After omarchy-migrate ran this migration (the only one pending): rtkit installed, the portal at 200000, all three audio daemons at 200000 µs with their data loops at RR 20. The running shell kept its hard 0 until omarchy-restart-shell, which omarchy update runs after migrations, and then also had 200000. That is the limit #16348, #12443 and #11862 trace their killed apps back to, so this PR now also closes #16348.

A user who applies the migration from the login notifier rather than omarchy update keeps the zero in the running shell until they next log in. Omarchy's migration guide rules out restarting the shell from a migration, so that is left as it is.

Tests: ./test/cli passes on the worker. ./test/shell fails in 8 files: ascii, background-instant-reload, background-intro-clone, branding-about-animation, hyprland-startup-cursor-cold, omarchy-kernel, runtime-smoke and screenshot-sanity. Each fails the same way on quattro 967bbdd without this change, on the same worker, so they come from quattro, not from this PR. The only check on this PR is Greptile's review, still running on the new head when this was posted; there is no CI test run.

Second opinion: Codex at medium effort and muse-spark-1.3 (via pi, thinking high) reviewed the combined change and found no defects. That covered the migration's ordering against the already-shipped 1790114905.sh and 1790984500.sh, its rerun and no-session-bus paths, and the package composition on every platform. Codex also traced the cached budget to xdg-desktop-portal's and PipeWire's sources. Their agreement is only that: their independence is not guaranteed.

One thing in the description: under Changes it still says rtkit goes in install/omarchy-other.packages. It now goes in install/omarchy-base.packages, because the installer pacstraps that list and the other one only seeds the ISO's offline mirror.

#16353 fixes the same bug and stays open; #7971 grants realtime through realtime-privileges but gives the portal no rtkit backend, so it does not fix this one. Waiting on the maintainer.

@Shadows-In-The-Space

Copy link
Copy Markdown

Thanks for taking this on — the audio half is the same root cause. One
addition from measurements on a second machine (Omarchy 4.0.6-1, kernel
7.2.8-9-omarchy, pipewire 1.6.9-1, xdg-desktop-portal 1.22.1-2): for the
RLIMIT_RTTIME = 0 class of kills, the migration as proposed is not quite
complete, because two components cache the old value and keep the zero alive
after the package is installed.

What we measured. Without rtkit installed, the portal reports
RTTimeUSecMax = 0, module-rt clamps its own RLIMIT_RTTIME to {0, 0}
(src/modules/module-rt.c, rtkit_finish_init()), and the shell — a PipeWire
client — carries the zero and hands it to every application it launches.
Measured on the machine above: 144 of the user's 234 running processes carried
the zero; counted per thread, 1678 of 2178 threads had RLIMIT_RTTIME 0/0
(shell 35/35 threads, Chrome, ChatGPT, Hermes, terminals). The kernel killed
Electron/Chromium apps with SIGKILL, si_code = 128, delivered from
posix_cpu_timers_work.

Why installing rtkit alone does not fix a running system.

  1. The portal caches the budget. After pacman -S rtkit, the system bus
    answered org.freedesktop.RealtimeKit1 RTTimeUSecMax = 200000 immediately
    (the package's post-transaction hook reloads the system bus configuration,
    so the new activation file is picked up without a reboot), but the portal
    still reported 0 until systemctl --user restart xdg-desktop-portal.service
    — only then it reported 200000 as well.
  2. The shell keeps the zero. The already running shell holds RLIMIT_RTTIME 0/0 and passes it to every launcher child; it is only replaced by a
    restarted shell.

So the migration needs, next to omarchy-pkg-add rtkit:

systemctl --user restart xdg-desktop-portal.service

plus a shell restart for the running session (omarchy-restart-shell) — or, if
the session should not be disturbed, the limits can be raised in place, because
the limit is stored per thread group and one write per process covers all of
its threads:

sudo -v
for pid in $(pgrep -u "$USER" -f .); do
  sudo -n prlimit --pid "$pid" --rttime=unlimited:unlimited 2>/dev/null
done

On the machine above this fixed 1678 threads in 144 processes without
closing a single application and without a logout; the verification afterwards
showed 0 of 2214 threads with a zero limit.

Fresh installs are unaffected by (1) and (2) — the portal and the shell start
after the package is present — so both only matter in the migration path.

For completeness, the reason a budget of 0 is fatal is in PipeWire's own
source: the clamp lowers the hard limit as well, and the kernel's CPU-timer
path (check_thread_timers → check_rlimit) sends SIGKILL as soon as
"realtime runtime ≥ hard limit" holds — which is true at 0 for a thread that
was never realtime. The upstream report for that clamping already exists and
is tracked here: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/5429

emirb added a commit that referenced this pull request Oct 27, 2026
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.
emirb added a commit that referenced this pull request Oct 28, 2026
* Install rtkit so PipeWire gets realtime priority

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

* Install rtkit on fresh installs and restart the portal before PipeWire

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>

* Drop the aarch64 rtkit entry now that the base list carries it

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>

* Ask rtkit for realtime directly from PipeWire and JACK clients

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.

* Add a command that installs rtkit and repairs zero realtime budgets

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.

* Install rtkit on existing machines through omarchy-realtime-repair

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.

* Raise new zero budgets even when a portal restart fails

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.

* Repair realtime budgets before the 4.0 upgrade installs rtkit

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.

* Keep rtkit masked through its own install

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.

* Follow the repository's Bash style in the realtime repair

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.

* Say when rtkit stays masked after the repair stops

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.

* Let one realtime repair run at a time

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.

* Say how to finish the realtime repair when zeros keep coming

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.

* Indent the rtkit PipeWire drop-ins with two spaces

The repository indents with two spaces, as its WirePlumber drop-ins do. PipeWire's config parser ignores the whitespace, so nothing changes at runtime.

---------

Co-authored-by: Zack Siri <me@zacksiri.dev>
Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Sam Diaz <265920095+szaidi-code@users.noreply.github.com>
@emirb

emirb commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Thanks @zacksiri! omacom/omarchy#16824 · Give PipeWire realtime with… merged and builds on this PR. It keeps your rtkit install, and adds repairing the running session’s zero budgets and turning off the portal path for host clients. Closing this in favour of it. It was a LOT of testing, it should be in edge now!

@emirb emirb closed this Oct 28, 2026
@emirb emirb removed this from the 4.5 milestone Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment