Repository navigation
drm/asahi: g17: keep a queue's frontier off contiguous pages - #2719
jgoyvaerts wants to merge 1 commit into
Conversation
|
The change is right for the failure you hit. Nothing needs the frontier contiguous, and
The J616s d3d12 row you list (0 Assisted-by: LLM (Claude:Opus 5.5) |
a4dbd8f to
9ce4fbe
Compare
9ce4fbe to
7b024be
Compare
|
Thanks @RyanTheTide, both are folded into the commit (new head
On the peak length: in the m4.177 reproduction the frontier already held more than 2048 entries. The failing reserve asked for 4096 entries (196608 bytes, order 4), and KUnit: 725 tests, 723 pass, 1 skip (the 1 failure is Assisted-by: LLM (Claude:Opus 5.5) |
|
Re-checked at
One wording nit for the commit message and PR text: "an allocation failure now fails the submission before any of it is queued" holds for the frontier. Other per-command allocations still run after earlier commands are queued: Rows: if this merges ahead of #2732, the J616s m4.177 reproduction at Assisted-by: LLM (Claude:Opus 5.5) |
A logical queue keeps one frontier entry per command whose completion has not signalled yet, and the pruned entries of the current ioctl in `finished`. Both are KVecs, so they grow by krealloc() into physically contiguous memory. The frontier is bounded only by how much work userspace keeps queued: vkd3d-proton's test_resolve_image_exhaustive_descriptors records 64 x 1024 resolves in one command list, and the frontier reaches thousands of entries. Growing it then needs an order-5 or order-6 block (512 KiB to 1 MiB with 16K pages). On a fragmented machine (4.3 GB free, nothing above order 4) the allocation fails. If it is `finished`, prune_frontier() falls back and only warn_alloc() dumps a trace. If it is the frontier's own reserve, the submit fails with ENOMEM after some of its commands may already have been queued, so Mesa marks the queue lost and reports VK_ERROR_DEVICE_LOST: vkd3d_queue: page allocation failure: order:6, mode:0x40cc0(GFP_KERNEL|__GFP_COMP) ... krealloc_node_align_noprof+0x154/0x238 rust_helper_krealloc_node_align+0x10/0x20 ..._asahi_core3g175queue...14prune_frontier... asahi 28a600000.gpu: [File 119992 Queue 1]: IOCTL: submit failed! (submission ID: 38521603 err: ENOMEM) The same test reproduces it alone on a loaded machine (nothing free above order 3): a perf probe on kmem:kmalloc shows the frontier's reserve asking for 196608 bytes (2048 -> 4096 entries) and getting NULL, and the submit fails with ENOMEM. Nothing needs these arrays contiguous: only the ioctl reads them. Make both KVVecs. kvrealloc() still tries kmalloc first, for a large size without direct reclaim or a warning, and falls back to vmalloc. Small frontiers keep their kmalloc memory, and a deep one no longer depends on high-order pages. Reserve the frontier room for a whole submission before its output fences are published, instead of one entry per command as it is queued, so that an allocation failure fails the submission cleanly instead of half-way. Userspace decides how long the frontier gets, and it can now grow past what contiguous pages ever allowed, so charge it and `finished` to the caller's memory cgroup (GFP_KERNEL_ACCOUNT). Fixes: 52ef95b ("drm/asahi: add the T8140 firmware interface") Fixes: 39bdd5b ("drm/asahi: release pruned G17 frontier entries after the ioctl publishes") Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
7b024be to
cde874e
Compare
|
Hardware evidence, J616s (M4 Pro), our m4.179 kernel. It carries this commit together with #2732's and #2858's, plus compaction re-enabled in our config. Same machine as the m4.177 runs in the description, and the same system Mesa on both kernels.
Moving this out of draft. Still not tested on the M4, the M4 Max or the M5. Assisted-by: LLM (Claude:Opus 5.5) |
|
Still needed: on integration/aurora at daa9e2d both frontier lists in the G17 queue are still KVecs, and cde874e merges onto that tip without conflicts (it is already based on a tip that has #2500). Both review points are folded in. @jgoyvaerts what is left to take it out of draft is the row you listed: the J616s d3d12 reproduction on this head with no |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at cde874ee627d75331949bedfdd1c853dfccda797 (host-tests: green; mergeStateStatus: CLEAN; not superseded on integration/aurora).
Code, Safety & Attribution Assessment (0 code blockers)
- §1 No model gating: Pass — shared G17 queue code with no chip/board/firmware gates.
- §2 Production-ready / Correctness: Pass —
frontiersandfinishedare moved toKVVec(only accessed and dropped in sleepable ioctl /Queue::dropcontext),Engine::of(&Validated)cleanly deduplicates the command-to-engine match, andsubmit()reserves exact per-engine command counts forpendingbeforeoutputs.publish()(drivers/gpu/drm/asahi/g17/queue/mod.rs:595-604) so frontier growth can no longer fail mid-enqueue.prune_frontier()only removes elements viaretain(), andfinished.reserve()keeps its safe inline-drop fallback. - §3 Safety: Pass — eliminates high-order contiguous allocation failures (
order:4..6,VK_ERROR_DEVICE_LOST) under deep queues and charges userspace-driven growth of bothfrontiersandfinishedto the caller's memcg viaGFP_KERNEL_ACCOUNT. - §4 Clean-room & attribution: Pass — commit
cde874ee627dcarries human author/committer (Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>) and humanSigned-off-by:only, zero AI commit trailers;Assisted-by:is at the end of the PR body. - §6 Naming / CI: Pass —
host-testsgreen, KUnit (723/725, 1 skip, 1 pre-existingisp_test_sensor_sysfs) andrun-host-tests.py --only g17(90/90) pass.
§5 Blocker Holding APPROVE / MERGETRAIN-LINUX4
- No standalone exact-head hardware run on
cde874ee627d: The J616sm4.179boot bundled draft PR #2732 and draft PR #2858 alongside this commit. Because #2732 replacesfrontiers: [KVVec<(u64, Fences)>; 2]andprune_frontier()'sretain()scan withOutstanding<Fences>/Outstanding::prune(), them4.179boot never actually exercised #2719's ownKVVecfrontier andretain()code path standalone (where 65,536 queued entries still traverseprune_frontier()on every enqueue), and #2732 remains a draft. - Required before approval:
- An exact-head (
cde874ee627donintegration/aurora, default cmdline, without #2732/#2858) J616s hardware + regression row (test_resolve_image_exhaustive_descriptorspassing with peak frontier size, d3d12 / timeline-semaphore CTS check, 0page allocation failure/ OOM /prune_frontier/submit failed, 0 GPU recoveries, 0 SELinux denials, 0 failed units, 0 new kernel errors) — or stack/merge together once #2732 is ready. - One additional G17 Mac row (M4, M4 Max, or M5) confirming shared G17 queue behavior with 0 regressions (per §1/§5).
- An exact-head (
(Non-blocking wording nit: the commit message states an allocation failure fails the submission cleanly instead of half-way; that holds specifically for frontier growth, as other small per-command allocations in enqueue() still run after earlier commands are queued.)
Assisted-by: LLM (Gemini 4 Neon)
A G17 logical queue keeps a frontier: one entry for each command whose completion hasn't signalled yet, plus the entries pruned during the current ioctl (
finished). Both were KVecs, so they grow by krealloc() into physically contiguous memory. Only userspace bounds them. vkd3d-proton'stest_resolve_image_exhaustive_descriptorsrecords 64 x 1024 resolves in one command list, and the frontier grows to thousands of entries. Growing it then needs an order-5 or order-6 block (512 KiB to 1 MiB with 16K pages).On a fragmented machine that fails even with plenty of memory free. Seen on a J616s (M4 Pro) during the vkd3d-proton d3d12 suite: 4.3 GB free, nothing above order 4.
finishedreserve inprune_frontier()fails, it falls back and only warn_alloc() dumps a trace.reserve(1)fails, the submit fails with ENOMEM after some of its commands may already be queued. Mesa then marks the queue lost (VK_ERROR_DEVICE_LOST), and the test reads 0 in every layer.The change makes both lists KVVecs. Only the submit ioctl reads them, and the queue is dropped in sleepable context, so they don't need contiguous pages. kvrealloc() tries kmalloc first (above PAGE_SIZE without direct reclaim or a warning), then falls back to vmalloc. A small frontier keeps its kmalloc memory; a deep one no longer depends on high-order pages.
Two more changes from review:
submit(), before its output fences are published, instead of one entry per command inenqueue(). An allocation failure now fails the submission before any of it is queued, like an ENOMEM inprepare_submission().Engine::of()replaces the three copies of the command-to-engine match this needed a fourth of.GFP_KERNEL_ACCOUNT, so a runaway client hits its own memory cgroup's limit.No uAPI change. The other submit-path vectors are bounded:
Scratchholds at most 64 commands per submission, and admission footprints are bounded by drm_sched credits.Considered and not done:
Testing
kmem:kmallocof 32 KiB or more. The frontier's reserve inQueue::submitasked for 196608 bytes (2048 -> 4096 entries) and got NULL (order-4 page allocation failure), and the submit failed with ENOMEM.finishedreached 163840 bytes (4096 entries) in the same run. No GPU recovery.isp_test_sensor_sysfs, which also fails on the base. No Rust warnings in the changed files.tools/asahi/run-host-tests.py --only g17: 90/90.On hardware (J616s, our m4.179 kernel)
test_resolve_image_exhaustive_descriptorspasses. The frontier peaked at 65,536 entries (3 MiB, through the vmalloc fallback), 16 times the depth where m4.177 failed.prune_frontier/submit failedlines; 0 GPU recoveries; 0 SELinux denials; 0 failed units; 0 error-level kernel messages. Details in the PR comment.Not done
prune_frontier()still scans the whole frontier on every enqueue. drm/asahi: g17: prune a queue's frontier from the front #2732 fixes that on top of this PR.Assisted-by: LLM (Claude:Opus 5.5)