xmem: hold the whole private span for a GPU tile import #660
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/660"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from brcly/TuxBox. Originally posted by revonateB0T on 2026-12-02T19:56:22Z.
What I see
With private backing (
TUXBOX_XMEM_PRIVATE_VIEWS=1) the GPU loses the device a few seconds into a title:The kernel refuses the submission rather than the driver faulting on the pages themselves.
Which commit introduced this
c1139ab287f9b112b95c3c3862204da806b56b82— "d3d12: convert queue-backed textures on the GPU and stop refusing their batches" (2026-12-02).It widened the GPU tile import from one page to a run of pages, and left the hold at one page. In
runtime/d3d12/src/device/heap/gpu_tiles.rsit added:Before it, the tile imported the one page it was asked for:
The hold did not follow:
resolve_backingsputs only the page that was asked for intopinned_views, soview_holdscounted that page alone. The import got wider than the hold.Before that commit the private backing had no such problem, because the import was exactly the page the hold covered.
Why
A GPU tile import maps a private span as one host pointer: the driver takes the whole 64 KiB-aligned run of pages the tile belongs to, not the one page that was asked for. The import got wider than the hold in
c1139ab287f9b112b95c3c3862204da806b56b82:runtime/xmem/src/physical_pages/backing.rs,acquire_contiguous:resolve_backingsputs the page that was asked for intopinned_views, soview_holdscounts that page alone.The pages beside it are released on their own. The title unmaps one, or the span is split, and the page is decommitted (
private_views.rs,decommit_private_range) or re-protected (PAGE_NOACCESS) while the GPU still maps it. The kernel then refuses the next submission.A section-backed page does not show this: its import names a held view of its own (
writable_section_view), and the section keeps the pages mapped, so releasing a view does not release the pages.What this changes
A hold on a tile covers the whole private span, which is the unit that is released anyway.
The pages the import covers are kept apart from the pages the hold only keeps mapped.
tracking.import_viewsnames the pages the GPU can write, and the CPU's write watch is disturbed on those alone; naming the whole span there would make the provider digest every page before every submission.How I measured it
ProjectScarlett under GE-Proton11-16 on an AMD Radeon 780M (RADV,
1002:15bf),TUXBOX_XMEM_PRIVATE_VIEWS=1:CS has been rejectedc1139ab2What I could not run
The xmem crate is Windows-only, so its Rust tests cannot run on a Linux host;
python tuxbox.py check --no-gputype-checks the crate and its tests. The test inruntime/xmem/src/tests/physical_backing.rs(gpu_tile_hold_keeps_the_whole_private_span_mapped) states the behaviour for a host that can run it: a tile hold keeps a sibling page of the same span committed, and the page is released with the hold.Miri is the one place those tests run on Linux, and it does not emulate
VirtualAlloc, so every test in that file is markedcfg_attr(miri, ignore = ...). The new test says so as well.The Miri job fails on two graphics reservation tests that
1b4ed472added without the attribute. That is onmainas well, and this branch does not touch it.NVIDIA is untested here: this host has no NVIDIA card. The change only widens a hold, so the section path and the NVIDIA path keep the behaviour they had.
AI use
The code change and the measurements were prepared with an AI coding agent (DeepSeek Harness, running MiniMax-M3.1-Flash, following
AGENTS.md). All runs were executed on my local machine.