Repository navigation
Watch: dropping a tracker keeps a mapping guarded while a tracker holds its alias - #2238
denkencar-sketch wants to merge 1 commit into
Conversation
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):
cargo test -p victory-gpu --lib watch::— 8 passed, 0 failed (includinga_tracker_dropped_leaves_the_other_mapping_guardedanddropping_the_last_tracker_opens_both_mappings)cargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)
Clean alias-aware guard retention when dropping a tracker whose alias is still tracked. Looks good.
AI-assisted (Gemini 4 Neon).
catminou4
left a comment
There was a problem hiding this comment.
Watch: dropping a tracker keeps a mapping guarded while another tracker holds aliases of the same pages (watched check over alias_of). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Same cluster; fixes alias guard lifetime.
|
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head AI-assisted (Claude Code); no game data. |
|
Automated triage for the maintainers. Merge candidate (worth a look). After the rebase, On your reply: confirmed. The part already in Generated by Claude Code |
main already keeps a dropped page guarded while a tracker holds its alias. When the last tracker on any mapping drops, the other mappings that guard_aliases guarded still stayed read-only in protected until a write faulted. Drop now opens those unwatched aliases too.
6d86640 to
0c21a73
Compare
|
Rebased onto current \main\ (\842b0cb). \main\ now already keeps the dropped page guarded while an alias is held; this rebased commit keeps the remaining part (opening unwatched aliases in \protected\ when the last tracker drops) and its test. \watch::tests\ (16/16) and \clippy\ pass. |
…d while a tracker holds its alias
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed and verified 0c21a73bf5dcc09678ec1fabecd585811788f0f4 merged onto origin/main (63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, --features diagnostics, Rust 1.98.1 MSVC).
Code Audit
- In
Drop for Tracked(crates/victory-gpu/src/watch.rs:436-453), once a page leavesg.holders, iteratingstd::iter::once(page).chain(others)and callingopen(&mut g, p)only when!watched(&g, p)handles both invariants under the singleguards()lock (no additional locks or lock-order changes):- While any tracker remains on
por any alias ofp,pstays guarded. - Once the last tracker across the alias group drops, every alias guarded solely via
guard_aliasesis opened back toPAGE_READWRITEand removed fromg.protected, eliminating stale read-only guards.
- While any tracker remains on
Local Verification
cargo xtask policy— pass (191 files ok).cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features) — 0 warnings.cargo test --locked -p victory-gpu --features diagnostics --lib watch::tests::— 17/17 passed, includinga_tracker_dropped_on_one_mapping_leaves_the_other_guardedanddropping_the_last_tracker_opens_both_mappings(L1455-1467).- Additional 3-view alias clique probe (
a <-> b <-> c <-> a, matchingxmem::map): verified dropping trackertawhiletblives keeps all three views (a,b,c) guarded and faults/markstbon a write through untracked viewc, and dropping the final trackertbopens all three views with zero lingering entries ing.protected. - Also verified a 4-way co-merge with
#2295,#2294, and#2283(which also toucheswatch.rs) on63bcca43c6a0merges with zero conflicts, passes strict clippy (--all-features), and passes all 6 targeted tests on both RTX 5090 and WARP.
Looks good to merge.
Summary
When a tracker is dropped,
Drop for Trackedopens (PAGE_READWRITE) every page that no tracker holds any more. That includes a page whichguard_aliasesguarded for a tracker of another mapping of the same memory. A write through the opened mapping then goes unseen, and the other tracker'stake()finds nothing changed (it returns early when its changed set is empty, before it could guard the alias again).The other direction is a stale guard: when the last tracker goes, aliases that only
guard_aliaseshad guarded stay read-only until a write faults.Change
A page stays guarded while a tracker holds it or a page showing the same memory (
watched). When a page is freed, it and its aliases are opened only if nothing watches them any more.Testing
Two tests on two views of one section (
twin_views), both failing onmain:a_tracker_dropped_leaves_the_other_mapping_guarded: trackers on both views, both taken, drop the first, write through the first view: the second tracker'stakemust see the page (onmainit returns nothing).dropping_the_last_tracker_opens_both_mappings: after the only tracker is dropped, neither page is left inprotected.The suite passed three times in a row.
cargo clippy --workspace --all-targets [--all-features] --locked -- -D warningsis clean.Not tried: a run in the game.
modules::dstorage::tests::a_page_list_filled_after_its_request_startsfails now and then onmaintoo (5 of 20 runs ofcargo test -p victory-hle --lib); it is unrelated.AI-assisted.