loader: a hooked store that crosses a block boundary marks both blocks #423
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!423
Loading…
Reference in a new issue
No description provided.
Delete branch "qnjk/Darner:heap-sites-cross-block"
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?
Contributor role (optional)
What it changes
The problem on main:
heap_sites::hookedwrites the write-watch notes for both ends of the title's store —for last in [0, store.size - 1]— but the block marks that follow run once from the first byte's offset, and theTOLDexchange (xchg) goes to that one cell:(
crates/darner-loader/src/heap_sites.rs:1073-1085before this change). The software path for the same journal marks every block a write touches (crates/darner-gpu/src/heap_hooks.rs:397-402), andtake()skips every block whose mark is 0 whiletell_watch()tells only blocks whoseTOLDbyte is set. So a store whose last byte lands in the next block — a 16-byte store at +0xFFF8, say — left its notes there unread and that block untold to the watch, until some later store happened to mark it. The host's copy of the record was a round stale and a page we wrote through our view was one the watch had not been told about.This change tests for the crossing first (
movzxthe offset's low 16 bits,cmpagainst0x10000 - (size - 1),jae), and only in the coldcrossedpath marks and exchanges the first block and then the block after it. A one-byte store cannot cross and emits no test; a store inside one block — the common case — paysmovzx,cmpand a jump not taken, with no further memory access. A store is 32 bytes at most, so it crosses at most one boundary: no loop is needed, and the report says what the cold path costs (~118 bytes of stub area per hooked store).How it was tested
01c8e31(one commit onf3840d7).cargo test --locked -p darner-loader --lib— 93 passed, 0 failed.heap_sites::stub_tests::a_store_across_a_block_boundary_marks_both_blocks(#[cfg(all(test, windows))], the module the other stub tests live in): it makes a site whose span isvmovups [rcx-48h], xmm0— sixteen bytes at +0xFFF8 of the test heap, eight of them in block 1 — runs it through the existingruns()harness, and asserts that the registers and ymm come out as the unhooked run's, that the title's memory is unchanged, that our view has what the title's would, that the sixteen bytes really crossed (+0xFFF8..+0x10008), that(blocks[0], told[0], blocks[LINE], told[LINE]) == (1, 1, 1, 1), and that slots 0x7FF and 0x800 are noted withcells.any == 1. No title, no adapter, no fixture file: onlyVirtualAlloc.cargo clippy --locked -p darner-loader --all-targets -- -D warningspasses.cargo clippy --workspace --all-targets --locked -- -D warnings: passes.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.cargo test --workspace --locked: not green on this machine, and not because of this change. Three pre-existing failures, each covered by an open pull request:darner-gpustands still in parallel on the test deadlock #224 describes, and serially finishes 1772 passed and 1 failed (pipeline::make::tests::a_capped_draw_waits_once_then_drops, which passes on its own) beside the order-dependent flakes of #150;darner-shaderfailsemit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders, whose fixture #227 fixes.darner-loader's own suite is green.Checklist
main.docs/asset-policy.md. (cargo xtask policy: 555 files ok.)Checked for overlap
crates/darner-loader/src/heap_sites.rs— it adds missing// SAFETY:comments in that file and incallhook.rs, so a conflict in comment lines is possible but unlikely. No open or closed issue mentionshooked,stub_testsor a store crossing a block boundary.Integrated cleanly onto
c8258f9, passedcargo xtask policy,clippy --all-features --all-targets -- -D warnings(0 warnings), and full unit tests (1,819indarner-gpu,219indarner), and ran stably over 30,000+ frames of Series X gameplay on RTX 5070 Ti 16 GB / Core Ultra 7 265KF / 64 GB DDR5-6400 with zero cross-block write-watch misses, crashes, or regressions.[pr-fix][memory] loader: a hooked store that crosses a block boundary marks both blocksto loader: a hooked store that crosses a block boundary marks both blocksView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.