Repository navigation
borealis: fast-reap retired submits via vm_status_mirror and deduplicate drmSyncobjQuery - #1162
Conversation
…ate drmSyncobjQuery
Retiring driver-owned packed-submission BOs in hk_cmd_pending_reap_queue()
currently performs a drmSyncobjQuery plus three syscalls per retired chunk
(drmSyncobjExportSyncFile, SYNC_IOC_FILE_INFO, and close), even when the
device already has a kernel-maintained vm_status_mirror mapping and the
queue timeline point was already observed during the same submission or an
earlier host wait.
1. Fast-reap single-chunk retired submits via vm_status_mirror:
- Seed `reached` from `queue->drm.signalled_value` and skip
`drmSyncobjQuery` when it already covers the newest pending entry;
otherwise publish the queried point via `hk_queue_note_signalled()`.
- When `dev->vm_status_mirror.word` is mapped, the device is not lost,
and an acquire load after observing `p->point <= reached` reads 0,
retire single-chunk submissions (`p->chunks == 1 && p->attempted == 1`)
directly without per-syncobj sync_file export/ioctl/close.
- Any non-zero error word, lost device, missing mirror, or multi-chunk
submission falls back to `hk_cmd_pending_poll()`.
2. Deduplicate per-submission `drmSyncobjQuery` calls across packing and
submission:
- Thread a per-submission `hk_queue_done_cache` through `hk_pack_runs()`
and `queue_submit_recordings()` so `hk_cmd_pending_reap_cached()`,
`hk_pack_atomics_allowed_cached()`, `hk_queue_query_progress()`,
`hk_sync_submit_needs_completed()`, and `hk_sibling_deep()` issue at
most one `drmSyncobjQuery` for the queue per submission and avoid
re-reaping when `hk_pack_runs()` already reaped.
3. Add unit tests in `test-hk-cmd-pending.c` covering zero-ioctl fast-reap
via `signalled_value` and cached points, as well as fallback on non-zero
`vm_status_mirror`, lost device, and multi-chunk submissions.
Signed-off-by: oreater <145754695+oreater@users.noreply.github.com>
|
This branch no longer merges into current |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 4348bcc5321a2
Blockers: none
Checked: Read the whole diff (hk_cmd_pool.c/.h, hk_queue.c, the new test). The fast reap only skips the sync_file status read when the queue timeline has reached the submission's point, the submission has one chunk and one attempted ioctl, the device is not lost, and the VM status mirror reads 0 with an acquire load after the point was observed. I checked the kernel side on aurora/main (g15/job.rs and g16/job.rs finish(), g17/completion.rs publish()): every error that can leave firmware referencing a job's memory (EIO, ENODEV, ETIMEDOUT, or a failure while the engine still had it) is recorded in the sticky VM status before the fence signals. The only errors that are not sticky are ECANCELED and errors after the job left the engine, and in those cases the GPU no longer touches the memory, so returning it to the BO cache is safe. Every use of the per-submission hk_queue_done_cache treats the cached point as a lower bound. The decisions that read it (packed atomics, sibling depth, the prior-busy check, the empty-wait own-timeline wait, the needs_completed point) only become more conservative when the value is stale, so none of them can drop a wait. There is no chip gate: the path depends on DRM_ASAHI_FEATURE_VM_STATUS_MIRROR through hk_init_vm_status_mirror(). The new test calls the new reap entry points and checks the fallback cases (non-zero mirror, lost device, multi-chunk).
To finish:
- Merge
aurora-wipinto the branch (a normal merge, no rebase). Thehk_queue.cconflict is mechanical: wip addedsubmit_is_originaltohk_pack_runs()and thehk_pack_obs_arm()blocks around bothqueue_submit_recordings()calls inqueue_submit_segment(). Keep wip's code and add&done_cache. A scratch merge resolved that way builds and passes the local gate (see Evidence). - Rows owed at the merged head: this is shared code for every Mac whose kernel offers the mirror, but the only row is on the J716c. Needed: the same CTS subset (api.command_buffers, synchronization basic fence and binary semaphore) on one G17P Mac (Neo) and one G14 or G16 Mac, plus the usual regression Mac.
Non-blocking: reached can come from queue->drm.signalled_value, which another thread may have stored. p_atomic_read is a relaxed load, so on arm64 the later acquire load of the mirror word is not ordered after it. Reading signalled_value with __ATOMIC_ACQUIRE, and storing it with release in hk_queue_note_signalled(), would make the "observed the point, then read the mirror" ordering hold across threads as well as within one.
Landing order with the other open submit-path PRs: #1162, #1176 and #1184 each add a parameter to queue_submit_recordings(), and #1173 and #1184 also rework queue_submit_segment(). I suggest landing #1162 first, then #1176 after merging aurora-wip in again; the others follow after their fixes.
Evidence
- Local x86 drm-shim gate (stands in for CI; docker
aurora/hk6356-mesa-x86-tests:local, clang release with asserts,-Dbuild-tests=true -Dtools=asahi,drm-shim,meson test --suite asahi --suite poly):- base
aurora-wipfa8970cda14f: 336 OK / 0 FAIL - scratch merge of
4348bcc5321a2intofa8970cda14f, with the conflict resolved as described above: 336 OK / 0 FAIL (hk_cmd_pending: ok)
- base
- Kernel contract read at aurora/main:
g16/job.rsfinish()records the error in the VM status (vm.status.record) beforefence.signal(result), andreport_failure(not sticky) covers only ECANCELED and errors after the job left the engine, outside EIO/ENODEV/ETIMEDOUT.g15/job.rsdoes the same with only ECANCELED left out. Ing17/completion.rs,publish()signals an error fence from insidestatus.signal_failure().
|
The 24 h window on the merge request from 11-27 04:20Z has passed, so per our PR fast-track policy I forward-merged Conflicts, all in
Host check at Before merge it goes into the next combined lab regression row (M1 Pro G13S + M4 G16G). If you'd rather resolve it differently, push on top and I'll re-run. |
|
@DjDeveloperr, code-owner heads-up: this PR has an aurora-silicon-review App approval at |
|
Merge-train landing at
Revert: |
What: Fast-reap retired single-chunk Borealis submissions via
vm_status_mirror(eliminating per-submitsync_filesyscalls) and deduplicatedrmSyncobjQueryioctls within a submission.Tested: J716c Apple M5 Max at
4348bcc5321: 212/212 asahi unit tests PASS,ExportSyncFile/SYNC_IOC_FILE_INFO-100% (2,097 -> 0),drmSyncobjQuery-42.3%, pipelined depth-4 compute submit -8.99% (1.10x), 167/167 Vulkan CTS PASS (0 fail, 0 diffs), 0 kernel errors.Risk: two-way door · all Macs — A plain revert restores
hk_cmd_pending_poll(). Relies on the existing kernelvm_status_mirrorordering contract documented inhk_init_vm_status_mirror(); multi-chunk submissions, lost devices, missing mirrors, and non-zero mirror words fall back tohk_cmd_pending_poll().Not yet: Multi-chunk packed submissions (
chunks > 1) whenchunk_timelinesis active still use per-syncobj polling and can be extended later if needed.Details and verification evidence
Summary
Eliminates per-retired-submission
sync_filesyscalls and redundantdrmSyncobjQueryioctls on packed compute submissions with zero chip-specific gating:Fast-reap retired single-chunk submissions via
vm_status_mirror(src/asahi/vulkan/hk_cmd_pool.c):reachedfromqueue->drm.signalled_valueand skipsdrmSyncobjQuerywhenever it already covers the newest pending submission on the queue; otherwise publishes any freshly queried point viahk_queue_note_signalled().dev->vm_status_mirror.word != NULL, the device is not lost (!vk_device_is_lost_no_report(&dev->vk)), and an__ATOMIC_ACQUIREload after observingp->point <= reachedreads0, single-chunk submissions (p->chunks == 1 && p->attempted == 1) retire directly withoutdrmSyncobjExportSyncFile+SYNC_IOC_FILE_INFO+close.hk_cmd_pending_poll().Deduplicate
drmSyncobjQuerywithin a single submission (src/asahi/vulkan/hk_queue.c,hk_cmd_pool.h):struct hk_queue_done_cachethroughhk_pack_runs()andqueue_submit_recordings()sohk_cmd_pending_reap_cached(),hk_pack_atomics_allowed_cached(),hk_queue_query_progress(),hk_sync_submit_needs_completed(), andhk_sibling_deep()issue at most onedrmSyncobjQueryfor the queue per submission and avoid re-reaping whenhk_pack_runs()already reaped.Unit tests (
src/asahi/vulkan/tests/test-hk-cmd-pending.c):test_vm_status_mirror_fast_reap()exercising zero-ioctl retirement viasignalled_valueand cached points (dev.dev.fd == -1), plus fallback verification for non-zerovm_status_mirror(-EIO), lost device, and multi-chunk submissions.Build & Artifacts
J716c Apple M5 Max (G17C B1), Fedora Remix 44, kernel7.3.0-40.j716c19.fc44.aurora.aarch64, GCC16.2.1--buildtype=release -Db_ndebug=true -Dbuild-tests=true -Dvulkan-drivers=asahi -Dgallium-drivers=origin/aurora-wip822cf58723a):libvulkan_asahi.soSHA-256d5b7e4582e1b034642e804f6477b070504ad077c2f0a3212989f6ad785228d684348bcc5321):libvulkan_asahi.soSHA-25682174c33ad76962bbbd3d03748c975773198134b13e8ce6044aa654dbbd15ab5Verification
meson test --suite asahi):212/212 PASS, 0 FAIL(includinghk_cmd_pending_testwith newtest_vm_status_mirror_fast_reap()).sync_fileioctl counts (2,000 pipelined depth-4 packed 2-CB compute submits + 100 warmup):DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD(ExportSyncFile)2,0970SYNC_IOC_FILE_INFO2,0970DRM_IOCTL_SYNCOBJ_QUERY(process total incl. commonvk_sync)5,5103,182-2,328)MESA_SHADER_CACHE_DISABLE=1, bit-exact GPU counters):4,000submits)22.70 us/sub20.66 us/sub1.10x)1,000submits, IRQ-bound)128.80 us/sub128.61 us/sub-0.15%(flat)deqp-vk, base vs head):167-casedEQP-VK.api.smoke.*,dEQP-VK.api.command_buffers.*,dEQP-VK.synchronization.smoke.*,dEQP-VK.synchronization2.smoke.*,dEQP-VK.synchronization.basic.fence.*,dEQP-VK.synchronization.basic.binary_semaphore.*:167/167 PASS, 0 FAIL, 0 status diffsvs base.SELinux=Enforcing,0DRM/asahi/GPU kernel errors.