RT-QUEUE31-CPU-SOURCE-ALIAS: preserve CPU-backed pages in batch remaps #1878

Closed
leonida/mandy
lixonik wants to merge 0 commits from fix/queue31-cpu-source-alias into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

lixonik commented 2026-11-25 13:53:41 +00:00

Claimed in the coordination issue as: RT-QUEUE31-CPU-SOURCE-ALIAS

What and why

CopyPageMappingsBatchX looked up pool pages only at the GPU address. When a GPU-only source page was backed through its paired CPU view, the batch treated it as a hole. It could return success while leaving the destination unmapped. This is on the streaming path used during story load.

The batch and single-range copies now share the source lookup. It checks the direct mapping first and falls back to the paired CPU view for legacy paired ranges. An unmapped source with no CPU backing is still a hole.

Tested

  • Built the real xmem_test with MSVC, using the production xmem.cpp and registry. With the new regression and the old implementation, the batch returned success but the source bytes were missing at the destination. The full suite passed after the patch (482 checks) and with write watching disabled (462 checks).
  • The focused regression passed under both LEONIDA_SLOT31_RUNS=0 and =1. The full optional-mode run passed on retry (482 checks); earlier runs hit intermittent memory-accounting and concurrent-view assertions. Retail world load was not tested.
  • python -I -B scripts/run_semantic_tests.py tests/semantic passed 6,261 tests across 489 files.

GPUs tested: n/a (synthetic XMem tests)

AI-assisted.

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
Claimed in the coordination issue as: [RT-QUEUE31-CPU-SOURCE-ALIAS](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164244324) ### What and why `CopyPageMappingsBatchX` looked up pool pages only at the GPU address. When a GPU-only source page was backed through its paired CPU view, the batch treated it as a hole. It could return success while leaving the destination unmapped. This is on the [streaming path used during story load](https://github.com/ubiquitarianism/leonida/blob/main/docs/linux_proton.md#where-it-stops). The batch and single-range copies now share the source lookup. It checks the direct mapping first and falls back to the paired CPU view for legacy paired ranges. An unmapped source with no CPU backing is still a hole. ### Tested - Built the real `xmem_test` with MSVC, using the production `xmem.cpp` and registry. With the new regression and the old implementation, the batch returned success but the source bytes were missing at the destination. The full suite passed after the patch (482 checks) and with write watching disabled (462 checks). - The focused regression passed under both `LEONIDA_SLOT31_RUNS=0` and `=1`. The full optional-mode run passed on retry (482 checks); earlier runs hit intermittent memory-accounting and concurrent-view assertions. Retail world load was not tested. - `python -I -B scripts/run_semantic_tests.py tests/semantic` passed 6,261 tests across 489 files. GPUs tested: n/a (synthetic XMem tests) AI-assisted. ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption.
moffington commented 2026-11-25 15:17:50 +00:00

Independently reviewed 9c6a3dc on Linux/Wine with clang-cl 23.1.3 and Windows SDK 10.0.26100.

  • All 8 focused XMem, CPU emulation, CLZERO and D3D12 placed-resource tests passed on both base and head.
  • Applying the new regression test alone to the base reproduced the missing destination mapping. The patched implementation passed with LEONIDA_SLOT31_RUNS=0 and =1.
  • The intermittent test_split_view_race failure reproduced once in five runs on both base and head, confirming it is not newly introduced by this PR.
  • With LEONIDA_XMEM_SEC_COMMIT=0, both revisions exhibited the same two Wine commit-visibility failures.
  • Combined locally with #826 (ffdb44446): clean merge and 8/8 focused tests passed.

Source review confirmed direct-mapping precedence, independent-page isolation and preservation of unmapped-hole behavior.

No actionable PR-introduced defects found. Native Windows and retail world loading were not tested.

Advisory approval.

Independently reviewed `9c6a3dc` on Linux/Wine with clang-cl 23.1.3 and Windows SDK 10.0.26100. - All 8 focused XMem, CPU emulation, CLZERO and D3D12 placed-resource tests passed on both base and head. - Applying the new regression test alone to the base reproduced the missing destination mapping. The patched implementation passed with `LEONIDA_SLOT31_RUNS=0` and `=1`. - The intermittent `test_split_view_race` failure reproduced once in five runs on both base and head, confirming it is not newly introduced by this PR. - With `LEONIDA_XMEM_SEC_COMMIT=0`, both revisions exhibited the same two Wine commit-visibility failures. - Combined locally with #826 (`ffdb44446`): clean merge and 8/8 focused tests passed. Source review confirmed direct-mapping precedence, independent-page isolation and preservation of unmapped-hole behavior. No actionable PR-introduced defects found. Native Windows and retail world loading were not tested. Advisory approval.
zmasi commented 2026-11-28 21:24:31 +00:00

Independent Verification Report — 5108a02e3a + origin/main (aa918e5d9f)

Environment: Native Windows 11 (26200), AMD Ryzen 9 5950X, MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8, /O2 /MD, linked with /BASE:0x140000000 /DYNAMICBASE:NO).
Verdict: PASS (Ready to merge — native Windows 11 + MSVC verification complete) — clean merge with origin/main (918baaa3fbd3) and combined Batch 9 set (a422ed80f598).

1. Red -> Green Verification on Native Windows 11

  • Red (origin/main xmem.cpp + #1878 xmem_test.cpp): xmem_test fails (rc = 1, 490 checks, 3 failures) in test_copy_page_mappings_cpu_view:
    • FAIL a batch source at the paired CPU view leaves its destination mapped with the source bytes
    • FAIL mapping them does not charge them
    • FAIL writing to 512 of them charges about those 512 pages
  • Green (5108a02e3a + origin/main):
    • xmem_test (default): PASS (490/490 checks)
    • xmem_test --pool-zero-read: PASS
    • xmem_test (LEONIDA_WRITE_WATCH=0 & LEONIDA_WRITE_WATCH=1): PASS (490/490 checks)
    • xmem_test (LEONIDA_SLOT31_RUNS=0 & LEONIDA_SLOT31_RUNS=1): PASS (490/490 checks)
    • xmem_wine_commit_test: PASS
    • Zero new compiler warnings introduced by #1878; find_mapped_source_page cleanly preserves direct-mapping precedence, independent-page isolation, and unmapped-hole unmap semantics.

AI-assisted.

### Independent Verification Report — `5108a02e3a` + `origin/main` (`aa918e5d9f`) **Environment:** Native Windows 11 (`26200`), AMD Ryzen 9 5950X, MSVC `19.44.35228` (`x64`, `/std:c++20 /EHsc /W4 /permissive- /utf-8`, `/O2 /MD`, linked with `/BASE:0x140000000 /DYNAMICBASE:NO`). **Verdict:** **PASS (Ready to merge — native Windows 11 + MSVC verification complete)** — clean merge with `origin/main` (`918baaa3fbd3`) and combined Batch 9 set (`a422ed80f598`). #### 1. Red -> Green Verification on Native Windows 11 - **Red (`origin/main` `xmem.cpp` + `#1878` `xmem_test.cpp`):** `xmem_test` fails (`rc = 1`, `490 checks, 3 failures`) in `test_copy_page_mappings_cpu_view`: - `FAIL a batch source at the paired CPU view leaves its destination mapped with the source bytes` - `FAIL mapping them does not charge them` - `FAIL writing to 512 of them charges about those 512 pages` - **Green (`5108a02e3a` + `origin/main`):** - `xmem_test` (default): **PASS (`490/490` checks)** - `xmem_test --pool-zero-read`: **PASS** - `xmem_test` (`LEONIDA_WRITE_WATCH=0` & `LEONIDA_WRITE_WATCH=1`): **PASS (`490/490` checks)** - `xmem_test` (`LEONIDA_SLOT31_RUNS=0` & `LEONIDA_SLOT31_RUNS=1`): **PASS (`490/490` checks)** - `xmem_wine_commit_test`: **PASS** - Zero new compiler warnings introduced by `#1878`; `find_mapped_source_page` cleanly preserves direct-mapping precedence, independent-page isolation, and unmapped-hole unmap semantics. AI-assisted.
merzleckeier commented 2026-11-30 12:42:14 +00:00

Independent Wine A/B for a mixed slot-31 batch. I merged fe0aff58 onto 497bdd039 (tree ba4a9565, identical relevant sources to GitHub merge 0862fa00) and built Win64 Release with clang-cl 23.1.5 and SDK 10.0.26100. CachyOS, Wine 11.22, CPU-only synthetic pages.

I used the same test body against both arms. One four-page batch reads two GPU-table entries, one source mapped only at its paired CPU address, and one true source hole. The destination of the hole was mapped before the call. With LEONIDA_SLOT31_RUNS=0 and =1, I ran three trials per arm per mode and logged the effective switch value.

  • MEASURED, PR. All six runs passed all 50 checks. Both GPU-table pages matched, the CPU-backed page stayed mapped, and the genuine hole removed its old mapping. A write through the new destination also appeared at the paired CPU address and in the original physical pool mapping.
  • MEASURED, main control. All six runs lost the CPU-backed page. The other GPU-table pages and the true-hole behavior matched in every run.
  • The full stock xmem_test had one failure in each of three runs on both revisions, the same Wine commit-accounting assertion about touching 512 pages. xmem_pool_zero_read and xmem_wine_commit passed on the PR.

AI-assisted with OpenAI Codex. The results were independently checked against the raw logs.

**Independent Wine A/B for a mixed slot-31 batch.** I merged `fe0aff58` onto `497bdd039` (tree `ba4a9565`, identical relevant sources to GitHub merge `0862fa00`) and built Win64 Release with clang-cl 23.1.5 and SDK 10.0.26100. CachyOS, Wine 11.22, CPU-only synthetic pages. I used the same test body against both arms. One four-page batch reads two GPU-table entries, one source mapped only at its paired CPU address, and one true source hole. The destination of the hole was mapped before the call. With `LEONIDA_SLOT31_RUNS=0` and `=1`, I ran three trials per arm per mode and logged the effective switch value. - **MEASURED, PR.** All six runs passed all 50 checks. Both GPU-table pages matched, the CPU-backed page stayed mapped, and the genuine hole removed its old mapping. A write through the new destination also appeared at the paired CPU address and in the original physical pool mapping. - **MEASURED, main control.** All six runs lost the CPU-backed page. The other GPU-table pages and the true-hole behavior matched in every run. - The full stock `xmem_test` had one failure in each of three runs on both revisions, the same Wine commit-accounting assertion about touching 512 pages. `xmem_pool_zero_read` and `xmem_wine_commit` passed on the PR. AI-assisted with OpenAI Codex. The results were independently checked against the raw logs.
ammonium231 commented 2026-11-30 14:16:07 +00:00

RTX 3090 / 621.40, validation on, fe0aff58d merged onto main 20fe0c754: xmem_test OK, 540 checks (main 538). No validation errors.

RTX 3090 / 621.40, validation on, fe0aff58d merged onto main 20fe0c754: xmem_test OK, 540 checks (main 538). No validation errors.
aslan2142 commented 2026-12-02 00:44:01 +00:00

Thank you for the careful work and thorough verification here. The legacy C++/Vulkan runtime/ directory is now frozen and deprecated as active development focuses on the d3d12/ and clean-room Rust vulkan/ tracks, so we are closing open legacy runtime/ PRs. We really appreciate the effort that went into this.

Thank you for the careful work and thorough verification here. The legacy C++/Vulkan runtime/ directory is now frozen and deprecated as active development focuses on the d3d12/ and clean-room Rust vulkan/ tracks, so we are closing open legacy runtime/ PRs. We really appreciate the effort that went into this.
Sign in to join this conversation.
No description provided.