Repository navigation
drm/asahi: bound the queue structures held for firmware poweroff - #3234
Conversation
The queue structures of invalidated contexts are kept until a statistics batch ends with a PowerOff. Under sustained load the firmware reports each PowerOff together with the following PowerOn, so that boundary can be minutes away, and idle sends none. A load that keeps creating and destroying rendering contexts then pins about 60 KiB of kernel memory per destroyed context: on the M1 Pro, 20,000 retained contexts and +1.4 GB of Shmem in 180 seconds, and the same pattern on the M2 (G14G). Releasing at every PowerOff is not safe: it brings the G13S firmware crash back. Instead keep the boundary and cap the list. When more than 1024 contexts wait, release those invalidated longest ago. With a cap of 256 the firmware crash still occurred, after about 6,400 churned contexts; 512, 1024 and 4096 each ran about 100,000 churned contexts without one. Signed-off-by: Ryan Murray <[email protected]>
Move the bound from the previous commit into release_oldest_powered(), so that KUnit can check it: up to MAX_POWERED_CONTEXTS invalidated contexts all wait for a PowerOff, and four times as many leave only the newest of them, in invalidation order. Add tools/testing/selftests/drivers/gpu/asahi-churn/queue-churn for the hardware. A child process keeps a G13/G14 GPU busy with back-to-back compute dispatches, so that the firmware reports no PowerOff, while the test creates a Vulkan device, runs one fill on it and destroys it, 6144 times. Shmem then grows by about 60 KiB per destroyed context without the bound, and by at most the bound's worth with it; what is left goes once the GPU is idle. It needs the Vulkan loader and Mesa, so it is not in the selftests' TARGETS. Signed-off-by: DjDeveloperr <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
783c379 J413 (M2 Air, G14G B0) + J316s (M1 Pro, G13S C0) PASS (0-diff merge onto main, default cmdline): J413 stock fleet89 FAIL (+402,272 KiB / 65.5 KiB/ctx) -> PR PASS (+52,368 KiB / 8.5 KiB/ctx), 32/32 churn mix x1024 PASS, 600s 2x glmark2-gbm + 4x queue-churn 256 PASS (160/160 rounds / 40,960 ctx, Shmem flat +186..+212 MiB, +9.7 MiB 4s after idle); J316s PR PASS (+69,184 KiB / 11.3 KiB/ctx flat 4096..6144 ctx), 32/32 churn mix x1024 PASS, 600s 2x glmark2-gbm + 4x queue-churn 256 PASS (148/148 rounds / 37,888 ctx, Shmem flat +216..+249 MiB, +13.1 MiB 4s after idle); both: 0 vkerr, 0 GPU faults/fw crashes, Enforcing, 0 failed, 0 AVC, stock fleet89 restored. |
There was a problem hiding this comment.
Verdict: MERGE at 783c379f (once cancelled CI checks are rerun green)
Blockers: none (code, KUnit, and two-generation exact-head G13/G14 hardware rows are ready; rerun the 16 cancelled CI checks before merge).
Checked:
drivers/gpu/drm/asahi/gpu.rs:14-35,1898: verifiedMAX_POWERED_CONTEXTS = 1024andrelease_oldest_powered()drains oldest invalidated contexts first (powered.drain(..excess)) in the G13/G14 legacy manager only (G15/G16/G17 unaffected).- Verified KUnit tests (
contexts_up_to_the_bound_all_wait_for_poweroff,churn_without_poweroff_holds_only_the_newest_contexts) andtools/testing/selftests/drivers/gpu/asahi-churn/queue-churn.c. - Verified exact-head (
783c379faaab) hardware rows on both J413 (M2 Air, G14G: stock +402 MiB FAIL -> PR +52 MiB PASS, 600 s 40,960-ctx stress flat) and J316s (M1 Pro, G13S: +69 MiB flat).
Evidence
- Diff reviewed at
783c379f(all 4 files, 466 lines). - CI at review time: 3 passed, 0 failed, 16 cancelled.
|
Merge-train status at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
What: On G13/G14 (M1/M2), the queue structures of destroyed queues are kept until the firmware reports a PowerOff, and under sustained load that boundary can be minutes away. This caps the list at 1024 contexts and releases the oldest first. It's Ryan's change from #2619, rebased onto main unchanged, plus a KUnit test of the bound and a hardware selftest that shows the growth.
Tested: host build of
drivers/gpu/drm/asahi(asahi.config, LLVM, Rust, withCONFIG_KUNIT=y) at783c379faaab: builds with no new warnings, and the new KUnit cases compile. Theasahi-m4host suite passes. The cap itself has Ryan's M1 Pro and M2 rows from #2619 (table below), which ran the same hunk on an older base. No row yet at this head.Risk: two-way door · M1 and M2 Macs (the legacy G13/G14 manager only; G15, G16 and G17 don't use
powered_contexts)Not yet: G13 and G14 rows at this head (requested from PEER-ROWS):
queue-churnon base and on this head, the churn mix under load with no firmware crash, and Shmem returning after idle. A faster churner (M1 Max/Ultra), as #2619 notes. CI.Details
1.
drm/asahi: bound the queue structures held for firmware poweroff(Ryan Murray)This is the commit from #2619, cherry-picked onto main. The only conflict was textual: main had since added
garbage_action()next to the new constant.GpuManager::alloc()pushes each invalidated context's retained queue structures ontopowered_contexts, andfw_power_off()releases them only when a statistics batch ends with a PowerOff. When more thanMAX_POWERED_CONTEXTS(1024) contexts wait, the commit releases those invalidated longest ago, under the same locks as the push.The bound comes from Ryan's measurements:
Releasing at every PowerOff instead is not safe: it brings the G13S firmware crash back.
2.
drm/asahi: test the bound on queue structures held for firmware poweroffThe bound moves into
release_oldest_powered()with no change in behaviour, andasahi_gpu_garbagegets two cases:MAX_POWERED_CONTEXTScontexts all wait for a PowerOff;tools/testing/selftests/drivers/gpu/asahi-churn/queue-churnshows the growth on hardware:It needs the Vulkan loader and Mesa, so it isn't in the selftests'
TARGETS.Evidence
./linux-build/build kernel --profile asahi <tree> -- olddefconfig drivers/gpu/drm/asahi/withCONFIG_KUNIT=y: exit 0. The module object holds the new KUnit case names, and there is no warning ingpu.rs.gpu.rs.--strict: 0/0/0 on Ryan's commit. The second commit's warnings are the Vulkan API's CamelCase names, the selftest'sCHECK()macro and the MAINTAINERS reminder for the new directory.tools/asahi/run-host-tests.py --only asahi-m4: 1/1 passed.queue-churn.cbuilds withcc -O2 -Wall -Wextra ... -lvulkan. Its SPIR-V isglslc --target-env=vulkan1.0output, and passesspirv-val.