Repository navigation
drm/asahi: g17: drop the completion thread's frequency boost while the GPU is the bottleneck - #558
Merged
Conversation
…utilization The G17 mailboxes receive in a threaded IRQ handler, which runs as an RT thread. RT threads run with the RT default minimum utilization, 1024 unless the system lowers sched_util_clamp_min_rt_default, so schedutil raises the thread's CPU cluster to its top frequency for every message. For the GPU completion mailbox that means one top-frequency burst per GPU completion, also while the GPU itself is the bottleneck and the CPU has nothing to do quickly. Add apple_mbox_set_rx_util_min(), which records the minimum utilization a consumer wants for the receive thread, or -1 for the scheduler's default, and have the threaded handler apply it to itself (sched_setattr_nocheck() on current, keeping its policy and priority) the next time it runs. The request is a single store, so it may be made from any context. Only mailboxes with a threaded receive handler support it; until a consumer asks, the thread keeps the default. Wrap it for RTKit consumers as apple_rtkit_set_rx_util_min() and RtKit::set_rx_util_min(). RtKit::rx_util_min_handle() returns a handle that makes the same request without borrowing the RtKit, for consumers that update it from their submission and completion paths. A KUnit case covers the request checks, and applying a request to a FIFO thread without changing its policy or priority.
…e GPU is the bottleneck Every G17 completion arrives through the primary coprocessor's mailbox, whose receive thread is an RT thread. With the RT default minimum utilization, schedutil raises its CPU cluster to the top frequency for each completion. While the GPU itself is the bottleneck that burst gains nothing. On J700, during GPU-bound work the P-cluster sits at its top frequency in about half of 1 s samples although the CPUs are about 3% busy, and once the SoC reaches its thermal limit (within about 40 s of heavy work) that power comes out of the GPU's clock. Have the feed detector also recognize when the GPU is the bottleneck: at least eight passes in a row whose refill gaps stay under a quarter of their busy time, the complement of its host-refill-bound test, lingering 8 ms like that state. While it holds, the port asks for a minimum utilization of 256 for the receive thread, and for the scheduler's default otherwise. The port re-evaluates at every publication and completion through a lock-free RTKit handle, so after a pause the publication that ends the state restores the default before its completion arrives. There is no new work item or timer. Lowering the boost whenever the feed is not streaming is not enough. The completion that ends a short pause then runs slower too: idle.wake with 2 ms gaps took 5% longer even at a floor of 512. A floor of 0 instead of 256 costs single-submit heavy compute about one completion per 250 ms. Measured on J700 with the panel off, in one boot after a 45 s heat-up, the old and new behaviour strictly alternated five times (gpubench, microseconds per submit, mean of the per-round medians; lower is better): render.heavy fill 2160p d1 2817 -> 2723 -3.3% render.heavy fill 2160p d16 2655 -> 2577 -2.9% render.heavy fill 1080p d1 802 -> 780 -2.7% compute.heavy alu d16 1199 -> 1179 -1.7% compute.heavy alu d1 1374 -> 1375 (one window in five) idle.wake 2 ms / 20 ms 191 / 588 -> 191 / 590 (medians) render.light d1/d32, compute.light d1/d8, compute.light queues d2, sync.signal binary queues within run-to-run noise On the heavy rows the P-cluster's mean frequency drops from 2.5 to 1.0 GHz and system power by 0.4-0.5 W. A KUnit suite covers the detector's three outcomes.
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every G17 completion is delivered by the GPU coprocessor's mailbox. Its receive handler is a threaded IRQ (SCHED_FIFO, since #382). RT threads run with the RT default minimum utilization (
sched_util_clamp_min_rt_default, 1024), so schedutil raises CPU0's cluster to its top frequency for each completion. During GPU-bound work that burst gains nothing: on J700 the P-cluster sits at 4.04 GHz in about half of 1 s samples while the CPUs are ~3% busy. Once the SoC reaches its thermal limit (TVD0 107 °C within ~40 s of heavy work), that power comes out of the GPU's clock.The mailbox driver owns the thread, so it gets the mechanism. asahi only decides the policy.
soc: apple: mailbox
apple_mbox_set_rx_util_min(mbox, util_min)takes 0..1024, or -1 for the scheduler default. The request is a single store.sched_setattr_nocheck()on its next run, keeping its policy and priority.apple_rtkit_set_rx_util_min(),RtKit::set_rx_util_min(), and a borrow-freeRtKit::rx_util_min_handle().drm/asahi: g17
Measurements (J700, panel off, one boot, 45 s heat-up, old/new strictly alternated ×5; gpubench µs per submit, lower is better)
On the heavy rows, the P-cluster's mean frequency drops from 2.5 to 1.0 GHz and system power by 0.4–0.5 W.
Alternatives measured and rejected:
Qualification
Production kit (integration 87e3a4d + these two commits, no diagnostics) on J700, fresh boot, Mesa wip83:
UCLAMP_TASK): 1786 tests, 1782 pass, 4 skips unrelated to this change. This includesapple_mbox_g17_stall.apple_g17_rx_util_min_testandasahi_g17_feed_detector(3 cases).No omacom mirror: omacom/linux-aurora's integration has no threaded G17 receive handler (#382 isn't there). Its completions are received in hard-IRQ context, so there is no RT minimum-utilization boost to remove, and the patch has nothing to act on there.