GPU: taking a page while another mapping of it is busy drops it from the changed pages and its saved bytes #2454
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#2454
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@BastienRodz on GitHub · 2026-11-25 13:49 UTC · original
What happens
A physical page can show at two addresses,
a(tracked by a host copy) andb(a pool view), linked bytitle_memory_aliased. While a write the guards do not see is under way throughb(watch::writing(b, len): a kernel read or a DirectStorage write into the pool),bis inbusyand stays open. If the copy takes the page meanwhile (Tracked::takeat a refresh, orTracked::takenafter a copy-back),guard_aliasescallsprotectonband ignores its result:bis skipped as busy, yetais guarded, removed from the changed pages, and its saved bytes are dropped (Changed::taken).Then:
bbefore the write ends do not mark the copy, so its next refresh misses them (stale copy);Writing::dropmarks the page changed without saving. If the page is armed for marked writes,copy_back_markedfinds it changed with nothing saved and keeps the title's bytes, which drops the shaders' writes to it.title_memory_aliasedignoresprotect's result the same way when the new mapping of a guarded page cannot be guarded.Expected
watch.rs: "taking a page guards every address showing it", andprotect: "a page that is mapped but cannot be guarded is left out (it stays changed)". A page with a mapping that could not be guarded should stay changed and keep its saved bytes until every mapping can be guarded.Where
crates/victory-gpu/src/watch.rs:guard_aliases,Tracked::take,Tracked::taken,title_memory_aliased.AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.
github-bot referenced this issue2026-11-26 05:09:17 +00:00
@shawshanker18 on GitHub · 2026-11-25 16:41 UTC · original
Tested both fixes for this, each merged onto
main(67e8ae1), on Windows 11 with an RTX 4050 Laptop. Command:cargo test -p victory-gpu --lib.maina_busy_alias_leaves_the_page_changed_and_keeps_saved_bytes: okmain's 2 (the 1,000,000 view-heap cap on NVIDIA)a_page_whose_other_mapping_is_busy_is_not_taken,linking_an_unguardable_mapping_keeps_the_tracked_page_changed: okThe two conflict with each other. Both make the same change to
Tracked::takeandTracked::taken:guard_aliasesreturns the pages it could not guard, and those stay changed. They differ in one place: intitle_memory_aliased, when the new mapping cannot be guarded, #2455 callschanged(.., true)and #2561 callschanged(.., false).true, a tracker that is armed but has nothing saved yet saves the page at link time. The kernel write through the busy mapping may already be landing, so title bytes can be saved as "before", and a marked shader write over them then wins.false, nothing is saved, so a marked copy-back keeps the title's bytes and drops the shader's write there. That is the same outcome asWriting::dropin the issue.Neither is lossless in that window.
falseis the conservative one for title data.One more difference: #2561's tests unlink and open their alias pages at the end; #2455's test does not. That could matter for full-workspace runs where tests reuse pages (compare #1882, #2252).
#2415 (for #2414) merges cleanly with either of them.
@Marvisak on GitHub · 2026-11-25 18:49 UTC · original
Automated triage for the maintainers.
Confirmed in main. In
crates/victory-gpu/src/watch.rs,guard_aliasescallsprotect(g, &others)and discards the list it returns.protectfilters out pages ing.busy, and says in its docs that a page it could not guard "is left out (it stays changed)". So the tracked page is taken even though another mapping of it is still open.There are two open PRs, and they conflict with each other:
Both make
Tracked::takeandTracked::takenkeep such pages changed. They differ only intitle_memory_aliased: #2455 callschanged(.., true)and #2561 callschanged(.., false). The comment above explains the trade-off. #2415 (for #2414) merges cleanly with either.Generated by Claude Code