AGC: agc_unit_shadow fails on CI's lavapipe since #2864: a publish's own copy reads as a newer CPU write #3215

Closed
opened 2026-10-11 01:36:47 +00:00 by adriadam10 · 2 comments
adriadam10 commented 2026-10-11 01:36:47 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T01:36:47Z.


agc_unit_shadow has failed on every Linux CI run of main since #2864 registered it (main run 38095564749 onward):

AGC graphics: the partial publish did not copy exactly the partly covered unit

Where it runs. unitShadowTests only exercises the shadows where host imports stay watched. CI's lavapipe is such a case: Mesa 25.2.8, /dev/udmabuf denied, log line host imports resolve write protection: no ... imported ranges stay watched. On RADV the run prints host imports are compared, not watched: unit shadows not tested and returns 0, not 77, so a local RADV pass doesn't mean it was tested. Before #2864 it wasn't in ctest; on lavapipe it stopped earlier, on the pin wait that #2864 fixes. #2864's head alone (f5618d912) fails the same way, so it isn't an interaction with another merge.

Why it fails (lavapipe, with a temporary print at the stale-drop site in publishUnits). The partial publish over units 3-4 returns 0. publishUnits drops unit 3 as stale with cpu[k] != 0, so its retiled bytes are never copied and the next check fails:

DBG stale drop unit 3 cpu=1
DBG partial=0 unit=65536 shadowed3=0 shadowed4=1

With lavapipe the "GPU" is the CPU. The earlier whole publish of unit 3 is a vkCmdCopyBuffer into the host-pointer import, executed by lavapipe's threads as CPU stores into watched pages. Those stores are collected only at the next CollectWritesUncached, which is after retile(*whole, unit3, ...) marked the unit with TrackerGeneration(). So the publish's own copy reads as a CPU write newer than the retile, and the unit is discarded.

It isn't lavapipe-only in principle: any driver where GPU writes to an imported host range trip the write watch would do the same. The publish's own copies would need to be absorbed (collected before the next mark, or excluded) rather than counted as title writes.

Reproduce: CI's lavapipe packages (mesa-vulkan-drivers, mesa-libgallium, libllvm20 25.2.8 from the "Install lavapipe" step), then bwrap --dev-bind / / --ro-bind <mode-000 file> /dev/udmabuf env APS5_PIN_WAIT_MS=3000 LD_LIBRARY_PATH=... VK_DRIVER_FILES=.../lvp_icd.json build/tests/agc_driver_recorder_tests --unit-shadow-only.

@MarcZX100, could you take a look? You know this path best. I fixed the third red test, agc_driver_image_packed16_load, in #3208. agc_driver_flat_apertures is a separate issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5797001362 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3215). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T01:36:47Z. --- `agc_unit_shadow` has failed on every Linux CI run of `main` since #2864 registered it (main run 38095564749 onward): ``` AGC graphics: the partial publish did not copy exactly the partly covered unit ``` **Where it runs.** `unitShadowTests` only exercises the shadows where host imports stay watched. CI's lavapipe is such a case: Mesa 25.2.8, `/dev/udmabuf` denied, log line `host imports resolve write protection: no ... imported ranges stay watched`. On RADV the run prints `host imports are compared, not watched: unit shadows not tested` and returns 0, not 77, so a local RADV pass doesn't mean it was tested. Before #2864 it wasn't in ctest; on lavapipe it stopped earlier, on the pin wait that #2864 fixes. #2864's head alone (`f5618d912`) fails the same way, so it isn't an interaction with another merge. **Why it fails** (lavapipe, with a temporary print at the stale-drop site in `publishUnits`). The partial publish over units 3-4 returns 0. `publishUnits` drops unit 3 as stale with `cpu[k] != 0`, so its retiled bytes are never copied and the next check fails: ``` DBG stale drop unit 3 cpu=1 DBG partial=0 unit=65536 shadowed3=0 shadowed4=1 ``` With lavapipe the "GPU" is the CPU. The earlier whole publish of unit 3 is a `vkCmdCopyBuffer` into the host-pointer import, executed by lavapipe's threads as CPU stores into watched pages. Those stores are collected only at the next `CollectWritesUncached`, which is after `retile(*whole, unit3, ...)` marked the unit with `TrackerGeneration()`. So the publish's own copy reads as a CPU write newer than the retile, and the unit is discarded. It isn't lavapipe-only in principle: any driver where GPU writes to an imported host range trip the write watch would do the same. The publish's own copies would need to be absorbed (collected before the next mark, or excluded) rather than counted as title writes. Reproduce: CI's lavapipe packages (`mesa-vulkan-drivers`, `mesa-libgallium`, `libllvm20` 25.2.8 from the "Install lavapipe" step), then `bwrap --dev-bind / / --ro-bind <mode-000 file> /dev/udmabuf env APS5_PIN_WAIT_MS=3000 LD_LIBRARY_PATH=... VK_DRIVER_FILES=.../lvp_icd.json build/tests/agc_driver_recorder_tests --unit-shadow-only`. @MarcZX100, could you take a look? You know this path best. I fixed the third red test, `agc_driver_image_packed16_load`, in #3208. `agc_driver_flat_apertures` is a separate issue.
Dextroid17 commented 2026-10-11 01:54:30 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-11T01:54:30Z.


Reproduced on a second machine — with no sandbox, and with udmabuf working.

I ran the test CI runs, on lavapipe, here:

$ build/tests/agc_driver_recorder_tests --unit-shadow-only      # Mesa 26.2.4 / LLVM 23.1.1
[write-watch] host imports resolve write protection: no (0 of 4 scratch pages written after a GPU read, 0 after the import); imported ranges stay watched
[write-watch] dma-buf imports keep write protection: yes (0 of 4 scratch pages written after a GPU read, 0 after the import, 1 seen after a CPU store); imported ranges stay watched
host imports stay watched
AGC graphics: the partial publish did not copy exactly the partly covered unit

exit 1. Mesa 26.2.4 / LLVM 23.1.1 here against CI's 25.2.8, so this is not a quirk of one Mesa.

The udmabuf part is worth comparing against your log, because here it is not the trigger. open("/dev/udmabuf", O_RDWR) succeeds on this machine — the device is root:kvm 0660 and the + on those permissions is an ACL granting this user rw- — and the run still reproduces, with the driver's own line reading host imports resolve write protection: no … imported ranges stay watched. That is the host-import path, not the dma-buf path. So the failing state is reachable with udmabuf available: what looks load-bearing is host imports staying watched, rather than the udmabuf denial itself.

One prerequisite for anyone reproducing: #2864's pin-release fix has to be present. On a tree without it the same binary never reaches unitShadowTests; it aborts earlier with

guest allocation 0x…+0x… is still pinned by GPU work or an import (waited 60000 ms for the lease (APS5_PIN_WAIT_MS))

which is PinnedFailure throwing from GuestAllocations.cpp:260-264. With #2864 cherry-picked, the shadow test is the first thing to fail, in seconds.

On the mechanism, two things in the code narrow it.

  • publishUnits already tells the two causes apart — (cpu[k] != 0 ? Stats().staleDroppedCpu : Stats().staleDroppedDriver) at UnitShadow.cpp:327. The failure is that on this device the publish's own copy is counted in the CPU bucket.
  • And the driver already tries to absorb its own writes: GuestMemory::CollectWritesUncached is called from the publish (UnitShadow.cpp:315) and from the device after a copy (VulkanDevice.cpp:522). So this looks like which copy gets absorbed rather than a mechanism that is missing — the partial publish's own vkCmdCopyBuffer over units 3–4 is the one that is not.

Two more instances of the same class, from tonight — which is why I think the "not lavapipe-only in principle" framing is the right one:

  • lavapipe reports maxComputeWorkGroupCount at the spec minimum (65535,65535,65535), so a legitimate 129199x1x1 dispatch throws instead of being split — filed as #3212.
  • lavapipe's "device-local" heap is host RAM, so the texture/storage cache budget (max(2048 MiB, heap / 4), ShaderResources.cpp:823) is 7978 MiB here where a real 12 GB GPU is entitled to 3072 — the software device gets the larger budget.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104379628 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3215#issuecomment-6104379628). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-11T01:54:30Z. --- **Reproduced on a second machine — with no sandbox, and with `udmabuf` working.** I ran the test CI runs, on lavapipe, here: ``` $ build/tests/agc_driver_recorder_tests --unit-shadow-only # Mesa 26.2.4 / LLVM 23.1.1 [write-watch] host imports resolve write protection: no (0 of 4 scratch pages written after a GPU read, 0 after the import); imported ranges stay watched [write-watch] dma-buf imports keep write protection: yes (0 of 4 scratch pages written after a GPU read, 0 after the import, 1 seen after a CPU store); imported ranges stay watched host imports stay watched AGC graphics: the partial publish did not copy exactly the partly covered unit ``` exit 1. **Mesa 26.2.4 / LLVM 23.1.1 here against CI's 25.2.8**, so this is not a quirk of one Mesa. **The udmabuf part is worth comparing against your log, because here it is not the trigger.** `open("/dev/udmabuf", O_RDWR)` *succeeds* on this machine — the device is `root:kvm 0660` and the `+` on those permissions is an ACL granting this user `rw-` — and the run still reproduces, with the driver's own line reading `host imports resolve write protection: no … imported ranges stay watched`. That is the **host-import** path, not the dma-buf path. So the failing state is reachable with udmabuf available: what looks load-bearing is host imports staying watched, rather than the udmabuf denial itself. **One prerequisite for anyone reproducing: #2864's pin-release fix has to be present.** On a tree without it the same binary never reaches `unitShadowTests`; it aborts earlier with ``` guest allocation 0x…+0x… is still pinned by GPU work or an import (waited 60000 ms for the lease (APS5_PIN_WAIT_MS)) ``` which is `PinnedFailure` throwing from `GuestAllocations.cpp:260-264`. With #2864 cherry-picked, the shadow test is the first thing to fail, in seconds. **On the mechanism, two things in the code narrow it.** - `publishUnits` already tells the two causes apart — `(cpu[k] != 0 ? Stats().staleDroppedCpu : Stats().staleDroppedDriver)` at `UnitShadow.cpp:327`. The failure is that on this device the publish's **own** copy is counted in the **CPU** bucket. - And the driver already tries to absorb its own writes: `GuestMemory::CollectWritesUncached` is called from the publish (`UnitShadow.cpp:315`) and from the device after a copy (`VulkanDevice.cpp:522`). So this looks like *which* copy gets absorbed rather than a mechanism that is missing — the partial publish's own `vkCmdCopyBuffer` over units 3–4 is the one that is not. **Two more instances of the same class, from tonight** — which is why I think the "not lavapipe-only in principle" framing is the right one: - lavapipe reports `maxComputeWorkGroupCount` at the spec minimum `(65535,65535,65535)`, so a legitimate `129199x1x1` dispatch throws instead of being split — filed as #3212. - lavapipe's "device-local" heap **is host RAM**, so the texture/storage cache budget (`max(2048 MiB, heap / 4)`, `ShaderResources.cpp:823`) is **7978 MiB** here where a real 12 GB GPU is entitled to **3072** — the software device gets the larger budget. Written with AI assistance.
oneandonlydean commented 2026-10-11 05:06:27 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T05:06:27Z.


Fixed by #3226 (merged). It extends the import probe with a GPU fill of the scratch range; lavapipe reports those pages as written, so imported ranges are compared instead of watched and the publish's own copy is no longer collected as a CPU store. The shadow checks then don't run on lavapipe, as on RADV; they still run on NVIDIA, where the fill reports 0 pages.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6105687584 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3215#issuecomment-6105687584). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T05:06:27Z. --- Fixed by #3226 (merged). It extends the import probe with a GPU fill of the scratch range; lavapipe reports those pages as written, so imported ranges are compared instead of watched and the publish's own copy is no longer collected as a CPU store. The shadow checks then don't run on lavapipe, as on RADV; they still run on NVIDIA, where the fill reports 0 pages.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#3215
No description provided.