Skip to content

device-panther: give Hyprland CAP_SYS_NICE for a high-priority GPU context - #429

Open
angelrenefm wants to merge 2 commits into
derekross:mainfrom
angelrenefm:pr-panther-hyprland-nice
Open

angelrenefm wants to merge 2 commits into
derekross:mainfrom
angelrenefm:pr-panther-hyprland-nice

Conversation

@angelrenefm

Copy link
Copy Markdown
Contributor

On the Pixel 7 at 90 Hz, with a client keeping the GPU busy, the screen stopped at about 63 frames a second. Hyprland asks panthor for a high-priority context, and panthor only grants it with CAP_SYS_NICE (or to the DRM master of panthor itself; Hyprland is master of gs-decon). Hyprland's log said "Failed to get a high priority context", so its frames ran at the client's priority and could wait a scheduler tick.

This adds a pacman hook to omamobile-device-panther, 90-omamobile-hyprland-nice.hook, which runs setcap cap_sys_nice+ep /usr/bin/Hyprland after every transaction that installs or upgrades hyprland (an upgrade replaces the binary and drops the capability) or this package; it does nothing if Hyprland isn't installed. libcap (for setcap) becomes a dependency. Only panther's package carries it, so other phones are unchanged; nothing in the tree gave a binary capabilities before, so a hook in the device package seemed the smallest place. Happy to move it to packages/hyprland if you'd rather.

Measured on a second Pixel 7, kernel 7.3.0-rc6-omamobile-push1-g44048a9aa795 (local, with the 90 Hz mode not yet proposed), mpv playing testsrc2 at 1080x2400@90 for 10 s, counting gs-decon's flips, each case after a reboot, twice:

Hyprland flips a second
as installed 62, 63
setcap cap_sys_nice+ep /usr/bin/Hyprland 89, 90
capability removed (control) 63, 63
capability back 90, 90

With it, Hyprland logs "Got a high priority context". No flip timeouts or late flips in any run; the panel kept 90 frame starts a second. Side effect: Hyprland then also runs SCHED_RR, priority 1, with SCHED_RESET_ON_FORK (its children start as normal tasks). Recorded in device/panther/NOTES.md.

Not checked: the hook itself on the phone (the capability was set by hand; the hook's Exec line runs in test/all against a stand-in setcap); power use; 60 Hz; the Pixel 7 Pro. Removing this package leaves the capability until Hyprland's next upgrade.

Checks: test/all (the hook's triggers, its Exec line with and without Hyprland, the libcap dependency; a hook giving another capability fails it) and tools/pr-check origin/main pass.

tools/phone-smoke (the same phone, 2026-11-04T18:47Z)

phone-smoke: panther

Kernel 7.3.0-rc6-omamobile-push1-g44048a9aa795, tools at 3435ed4, 2026-11-04T18:47Z.

Check Result Detail
boot (required) ok kernel 7.3.0-rc6-omamobile-push1-g44048a9aa795, slot b, up 865s
storage guard (required) ok 55 partitions; only userdata and slot B's boot images writable
root (required) ok ext4 on userdata, 97G free
kernel health (required) ok no oops or BUG; 0 WARN, 8 error lines in dmesg (8 known, 0 new)
systemd units ok none failed
USB gadget (required) ok bound to 11210000.usb
display ok card2-DSI-1 connected, 1080x2400
GPU ok render node on panthor
session (required) ok Hyprland and the Omarchy shell running
lock ok PAM file present, the shell can lock (passwordPam true, locked true)
touch ok FocalTech FT3658
buttons ok gpio-keys
Wi-Fi ok wlp1s0 on brcmfmac, link up
Bluetooth ok hci0, powered true
battery ok 91% Charging, 33 °C
sound cards ok googleaocsndcar
sensors ok Accelerometer AmbientLight Proximity
cameras skip no libcamera tools
thermal ok hottest zone 49 °C

Packages: hyprland 0.57.0-3.1, libcamera 0.7.2-4.22, mesa 1:26.2.4-1.4, omacam 0.3.3-1, omamobile-apps 0.2.0-1, omamobile-audio 0.5.13-1, omamobile-device-panther 0.1.5-1, omamobile-firstboot 0.1.3-1, omamobile-gnss 0.2.7-1, omamobile-keyring 20261026-1, omamobile-mirror 0.1.1-1, omamobile-omarchy 0.1.28-1, omamobile-owl-widgets 0.1.1-1, omamobile-sensors 0.2.1-1, omamobile-shell 0.2.79-1, omarchy 4.0.6-1, quickshell 0.3.2.r7.g2b4501a-1

I used AI help (Claude) to work on this.

…ntext

With a client keeping the GPU busy, a Pixel 7 at 90 Hz stopped at
about 63 frames a second. Hyprland asks panthor for a high-priority
context, which panthor only grants with CAP_SYS_NICE (or to its own DRM
master; Hyprland is master of gs-decon). Hyprland's log said "Failed to
get a high priority context".

A pacman hook now runs setcap cap_sys_nice+ep on /usr/bin/Hyprland
after every transaction that installs or upgrades hyprland (which
replaces the binary and drops the capability) or this package. setcap
comes from libcap, now a dependency. Only this device package carries
it; other phones are unchanged.

On a Pixel 7 (mpv testsrc2 at 1080x2400@90, 10 s, gs-decon's flips,
each case after a reboot, twice): 62-63 flips a second without the
capability, 89-90 with it, 63-63 with it removed again, 90-90 back;
the log then says "Got a high priority context". Hyprland also runs
SCHED_RR priority 1 with SCHED_RESET_ON_FORK. The capability was set
by hand; the hook itself has run only in test/all, not on the phone.

I used AI help (Claude) to work on this.
@derekross

Copy link
Copy Markdown
Owner

Thank you for tracking this down to panthor's priority check; the before, after, control and back again table is exactly the kind of measurement I like to see. Because it's the first time anything in the tree would give a binary a capability, I want to think about it a little more widely before it goes in:

  1. Scope. panthor applies the same rule on the Pixel 7 Pro at 120 Hz, so if Hyprland should have CAP_SYS_NICE, it probably belongs in our packages/hyprland rather than one device package. I'll decide that; you offered to move it, thank you.
  2. Evidence on what panther runs. The numbers are at 90 Hz on a kernel with a mode that isn't proposed yet. Could you add the same test at 60 Hz (what panther has today), and run the hook for real once: install the package with pacman -U, then getcap /usr/bin/Hyprland?
  3. Side effects in the session. With a file capability, the kernel starts Hyprland in secure-execution mode: glibc ignores LD_* variables, and libraries that read the environment through secure_getenv see nothing (sd-bus does this for the session bus address, as far as I know). Was your smoke run with the capability set? If not, could you check the shell, notifications, the portals and screenshots with it on?
  4. Fresh installs. The hook also runs while the root image is built in a container. A capability set inside a user namespace can be tied to that namespace and not count on the phone. A getcap on a phone installed from a freshly built image would settle it.

Smaller: removing the package leaves the capability behind; a remove hook with setcap -r would tidy that up. The version gets set at merge.

…ge goes

A second hook, 90-omamobile-hyprland-nice-remove.hook, runs
`setcap -r /usr/bin/Hyprland` before omamobile-device-panther is
removed, so the capability the install hook gave doesn't outlive the
package until Hyprland's next upgrade. It does nothing without Hyprland
and never fails the removal.

test/all checks its trigger (remove, this package only, before the
transaction) and runs its Exec line against a stand-in setcap, with and
without Hyprland; the new check fails when the Exec line changes. Not
run with pacman -R on the phone (removing the device package would take
the storage guard with it); the install hook was run for real, below in
the pull request.

I used AI help (Claude) to work on this.
@angelrenefm

Copy link
Copy Markdown
Contributor Author

Thanks, Derek. Going through your points in order.

1. Scope. Yours to decide. The hook lives only in panther's package for now. Moving it to packages/hyprland is a small move whenever you'd like it.

2. 60 Hz, and the hook for real. Same phone and kernel as before (7.3.0-rc6-omamobile-push1-g44048a9aa795). mpv played testsrc2 at the panel's rate for 10 s, counting gs-decon's flips. Each case ran twice, unlocked:

Hyprland 60 Hz 90 Hz
cap_sys_nice=ep ("Got a high priority context") 60, 60 90
no capability, a fresh boot ("Failed to get a high priority context") 59, 58 62, 61

At 60 Hz the gain is small; at 90 Hz it's the whole difference. No late flips in any run.

For the hook, I took the capability off (setcap -r, getcap empty) and installed a package with this branch's hooks using pacman -U. The pacman output showed Giving Hyprland CAP_SYS_NICE for a high-priority GPU context..., and afterwards getcap /usr/bin/Hyprland printed cap_sys_nice=ep. That package was main plus #419 plus this branch's hooks, so the phone kept its Wi-Fi and camera files.

3. Side effects with the capability on. My smoke runs did have the capability set: Hyprland has run with it on this phone since 2026-11-04, and the phone-smoke report above came from such a boot. To answer your question directly:

  • AT_SECURE is 1 in Hyprland's auxv, so secure-execution mode is real.
  • The shell, notifications (toasts and the notification centre), xdg-desktop-portal with xdg-desktop-portal-hyprland, and screenshots (grim) all worked through it.
  • Hyprland still has DBUS_SESSION_BUS_ADDRESS in its environment.
  • Its children start as normal tasks (SCHED_RESET_ON_FORK).

What I didn't check is anything that depends on LD_* reaching Hyprland itself; nothing in our session sets those.

4. Fresh installs: you were right, and it matters. tools/build-rootfs runs rootfs/build-inside in Docker, and its comments allow for rootless Docker. Under a user namespace, setcap writes a namespaced capability: v3, with the namespace's root uid in it. mkfs.ext4 -d then copies that xattr into the image unchanged. I reproduced both on the laptop with unshare -Ur setcap cap_sys_nice+ep and an image made by mkfs.ext4 -d: the image's security.capability is v3 with rootid 1000.

On the phone, a binary carrying that exact v3 xattr behaves differently from a normal one:

xattr on a copy of python3 getcap shows CapEff when run as the user
v3, rootid 1000 (as from a rootless build) cap_sys_nice=ep 0000000000000000
v2 (as setcap writes on the phone) cap_sys_nice=ep 0000000000800000

So an image built under rootless Docker would ship a Hyprland that looks right to getcap but gets nothing. I don't know how your images are built; with rootful Docker the hook writes v2 and it's fine.

Two ways out I can see, and I'm happy to do either:

  • re-run the same setcap on the phone once, for example from first boot or a oneshot unit that only acts when CapEff would be missing;
  • have build-inside rewrite the xattr as v2 after mkfs.

Smaller: removal. A second hook, 90-omamobile-hyprland-nice-remove.hook, runs setcap -r /usr/bin/Hyprland before this package is removed, and test/all covers it. I haven't run it with pacman -R on the phone, since that would also remove the storage guard.

I used AI help (Claude) to work on this.

@derekross

Copy link
Copy Markdown
Owner

Thank you, @angelrenefm, for going through every point with measurements. The 60 Hz table, the hook run for real with pacman -U, and the AT_SECURE check with the session working are exactly what I asked for. And thank you especially for chasing the fresh-install question to the end. You were right that it matters: our root images are built in rootless Docker, so as it stands every fresh Pixel 7 install would get a Hyprland that getcap says has the capability but that gets nothing.

Where this stands:

  1. The decision is still mine, and I haven't made it yet. Your 60 Hz numbers help: at the rate the Pixel 7 runs today, the gain is a frame or two a second, and the big win comes with 90 Hz. Moving it into our Hyprland package would also change the Pixel 7 Pro, which I can't test right now, so if it goes in soon it stays in the Pixel 7's package as you have it.
  2. If it goes in, the fresh-install case needs fixing first. Of your two options, I'd prefer a small oneshot unit in the device package that re-applies the capability on the phone when it's missing or namespaced (the v3 form). It should come with a test that feeds it a v3 xattr like the one your table shows. That fixes it on the phone, as real root, without touching the shared image build.

The remove hook looks good, and not trying pacman -R on a phone that would lose its storage guard is the right call. The version gets set at merge; this package has a few PRs queued, so it will be the next free number then.

@derekross

Copy link
Copy Markdown
Owner

@angelrenefm, I've decided on this one: not now, and let's revisit it when the Pixel 7 runs at 90 Hz.

At 60 Hz your own table shows the gain is 58-59 to 60 frames a second. That's real but small, and this would be the first file capability anywhere in our tree. It would also need the re-apply unit first, because a rootless image build writes a namespaced capability that grants nothing on the phone. When 90 Hz lands and the numbers show a clear win, please bring it back with that unit and its v3 test, as we discussed. I'll leave the PR open until then, as a draft if you prefer. Thank you for measuring instead of guessing; it made the decision easy.

@angelrenefm

Copy link
Copy Markdown
Contributor Author

For the squash message: these commits were written with Claude Opus 5.5, so the trailer CONTRIBUTING asks for is
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>. I've left the branch as you reviewed it.

@derekross

Copy link
Copy Markdown
Owner

Thank you, Ángel, and thanks for the trailer line, I'll use it when this lands.

My decision from the 7th still stands: this waits until the Pixel 7 runs at 90 Hz in the published kernel. The display series (linux-omarchy-mobile#181) is still in review and the 90 Hz mode isn't proposed yet, so there's nothing new to measure against. When it is, please bring this back with three things: a rebase onto main (it now conflicts in the panther NOTES, README, install and test/all), the small oneshot unit that re-applies the capability on the phone when it's missing or namespaced, with a test that feeds it a v3 xattr like the one in your table, and the 90 Hz numbers on that kernel. I'll keep it open until then; feel free to mark it as a draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants