Repository navigation
startup: track a refused page request through the consumer view - #1886
Conversation
Add startup_storage_consumer_pair: one Submit with a matched pair of page-destination zlib requests (page_offset 0xF000, destination_size 0x1000, ending at the first page's end). S inflates to exactly 0x1000 bytes; R inflates to 0x1800 and is refused for capacity. Each page has a distinct sentinel, each request its status entry and fence. The test maps the pages with XMemVirtualAlloc + XMemMapPhysicalPages from the xmem shim (X2W_XMEM_PERMISSIVE) and reads through that view at each fence and after both: S shows the exact bytes, every byte of R's page stays its sentinel and none equals R's stream prefix. The pages are then unmapped and freed, one is allocated again, and a follow-up of S's shape on the same queue completes with exact bytes. accept_refused_control expects R's stream prefix and must print that check's failure. A manual mutant writing R's prefix before the refusal fails the fixture on R's sentinel (recorded, reverted). The stand-in is unchanged. Refs R0Y00#1198 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tedin7
left a comment
There was a problem hiding this comment.
Reviewed head b5df528741ea3e0eda7d1fa20ce38899ad9c6f0a. No P1/P2 findings.
What it adds: a Windows-only fixture, startup_storage_consumer_pair, and a negative control, ..._accept_refused_control. The fixture sends two page-destination zlib requests that end at the first page's end. S completes and R is refused for capacity. Every read goes through an XMemMapPhysicalPages view, as a title would read it. It checks:
- the status of each request (S_OK and E_FAIL);
- fence order against the status entries, with a read inside each fence callback and another after both;
- that R's page stays entirely its sentinel and holds no byte of its stream prefix;
- the stand-in's log outcome for each request;
- unmap and free, with the live page count dropping by two;
- a zero-filled re-allocation, and a follow-up request that completes with exact bytes.
The sentinels are checked up front to differ from each other and from the data at every destination byte, so a sentinel byte can never pass as data. The CMake change only adds the target, the two tests and their properties. The control uses PASS_REGULAR_EXPRESSION on the exact failure text, so it fails for the right reason. The docs paragraph matches the fixture and says what it does not show. I saw no clean-room problem, and the diff touches no production code.
Linux commands run in a clean worktree:
git diff --check origin/main...HEAD-> rc 0python -B tests/docs_links_check.py-> rc 0 (18 files, 376 links)python -B tests/bidi_controls_check.py-> rc 0
Windows Server 2025 (MSVC 14.44, WARP), x2w_pipe.py win2025 at this exact head:
- Debug (
--preset dev):startup_storage_consumer_pairandstartup_storage_consumer_pair_accept_refused_control, 2/2 passed. - Release
/O2(--preset release): 2/2 passed.
Mutations in src/startup_stubs/xcrdapi.cpp, applied as local patches on Win2025 and each reverted with git checkout -- .:
- Capacity refusal disabled ->
startup_storage_consumer_pairFAILS (rc 1). The request falls to the "insufficient page grants" path, and the fixture reportsR logged outcome "insufficient page grants", expected "destination capacity exceeded". - The first 0x1000 inflated bytes written to R's page before the refusal, the mutant the docs describe ->
startup_storage_consumer_pairFAILS (rc 1, Debug). The control also fails because its expected message no longer appears.
Notes, not blocking:
- On early
return 1paths the fixture leaks the view and the temp log. This is harmless for a test process.
This is a review comment only, not an approval.
AI-assisted; commands listed were executed locally.
What
A source-built fixture,
startup_storage_consumer_pair, that follows one refused page-destination DirectStorage request end to end (enqueue, completion status, fence, the first consumer read of its destination, and the release of its pages) next to a successful request of the same shape. This is the step asked for on #1198.Why
Existing fixtures already cover parts of this:
startup_storage_refusal_order: enqueue, status and fence order for refused file-source reads into linear destinations, plus a poisoned destination.startup_dstorage_destination: a refusal before any byte is written when a linear destination is not writable.dstoragecase ofstartup_stubs(tests/startup_stub_consumer.cpp): a single short or missing-grant page request read through a mapped view, with one fill byte, no fence, no paired success and no release.None of them pairs a success and a refusal of the same page shape in one Submit with distinct sentinels, reads the pages through the title's mapped view at each fence, and then releases and reuses them. This fixture adds that and uses the same checkpoints as #1664 (status value, fence after its own status entry, destination bytes).
Change
tests/startup_storage_consumer_pair.cpp(new). It loads the stand-in DLL and the xmem shim (asxmem.dll,X2W_XMEM_PERMISSIVE=1), takes two page tokens fromXMemAllocatePhysicalPages, reserves a view withXMemVirtualAlloc(nullptr, 0x20000, 0x20402000, 0x21, PAGE_READWRITE)and maps the pages into it withXMemMapPhysicalPages. Every read goes through that view. Page writes go throughx2w_xmem_write_physical, which the stand-in already uses.page_offset0xF000,destination_size0x1000 (ends exactly at the page end), one token each. S inflates to exactly 0x1000 bytes. R inflates to 0x1800 bytes and is refused asdestination capacity exceeded. Each request is followed by its status entry and anEnqueueSignalfence.S_OK, RE_FAIL.inflatedfor S,destination capacity exceededfor R.XMemMapPhysicalPages(view, 2, nullptr)unmaps andXMemFreePhysicalPages(2, …)frees; both succeed.x2w_xmem_page_statslive backings drop by 2.S_OKwith the exact bytes at its fence and after.CMakeLists.txt: the test and itsaccept_refused_control.docs/startup-runtime.md: a short entry after "DirectStorage page-request ends", with the command and what each checkpoint shows.The stand-in (
src/startup_stubs/xcrdapi.cpp) and the xmem shim are unchanged, and no outcome changes. Aggregate counters, address placement and XDsp are out of scope.Tests
Built from upstream/main
df40e4bcplus this commit. Windows 11 x64 (10.0.26300), MSVC dev preset.2/2 passed:
startup_storage_consumer_pairandstartup_storage_consumer_pair_accept_refused_control. The main test prints:S published its exact bytes at its fence; R reported E_FAIL and every byte of its page stayed its sentinel (no stream prefix) at its fence and after; the pages were unmapped and freed, and a follow-up of S's shape into a page allocated afterwards completed with exact bytes19/19 passed.
241 tests: 237 passed, 0 failed, 4 skipped. The skips are capability skips, not passes:
startup_view_heap_hardware,startup_view_heap_warp,startup_logical_view_warpandstartup_logical_view_hardware.Negative controls
startup_storage_consumer_pair_accept_refused_control(--mutate accept-refused). This consumer takes R's destination as data and expects R's stream prefix there instead of R's sentinel. The control passes only on that check's exact failure line (PASS_REGULAR_EXPRESSION, asdstorage_rfc1950_refusals_truncation_controldoes). Observed:execute_request, inside thedecode_length > destination_capacitybranch, the mutant writes the destination-sized prefix (0x1000 bytes frompage_offset) throughx2w_xmem_write_physicaland then refuses as before. Steps: rebuildstartup_stub_xcrdapi, then runctest --preset dev --no-tests=error -R '^startup_storage_consumer_pair'.startup_storage_consumer_pairfails:Not covered
Refs #1198
🤖 Generated with Claude Code