HLE: recycle freed XMem page numbers #1489

Closed
Calvix2k wants to merge 1 commit from upstream-pr/1490 into main
Calvix2k commented 2026-11-24 18:23:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T18:23:39Z.


Summary

Recycle page numbers removed by XMemFreePhysicalPages and prefer them in subsequent XMemAllocatePhysicalPages calls. This prevents the title's packed 21-bit page-number field from eventually wrapping after repeated allocation/free churn, even when few pages remain live.

Addresses VIC-BT-036 from the audit in #1249.

Verification

  • cargo test -p victory-hle --lib — 95 passed
  • cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings — passed
  • Repository pre-commit asset-policy hook — passed

The full workspace test run on this Windows 10 machine still has 15 GPU shader tests that require an SM 6.6 hardware or WARP device; the targeted HLE suite passes.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588584180 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1490). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T18:23:39Z. --- ## Summary Recycle page numbers removed by `XMemFreePhysicalPages` and prefer them in subsequent `XMemAllocatePhysicalPages` calls. This prevents the title's packed 21-bit page-number field from eventually wrapping after repeated allocation/free churn, even when few pages remain live. Addresses VIC-BT-036 from the audit in #1249. ## Verification - `cargo test -p victory-hle --lib` — 95 passed - `cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings` — passed - Repository pre-commit asset-policy hook — passed The full workspace test run on this Windows 10 machine still has 15 GPU shader tests that require an SM 6.6 hardware or WARP device; the targeted HLE suite passes.
DenRakEiw commented 2026-11-24 19:03:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T18:27:59Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-hle --lib xmem:: — 11 passed, 0 failed (including freed_physical_page_numbers_are_reused_before_growing_the_pool)
  • cargo clippy -p victory-hle --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean free-list recycling of freed XMem physical page numbers in Physical::allocate_page_number. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045042891 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1490#pullrequestreview-6045042891). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T18:27:59Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-hle --lib xmem::` — 11 passed, 0 failed (including `freed_physical_page_numbers_are_reused_before_growing_the_pool`) - `cargo clippy -p victory-hle --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean free-list recycling of freed XMem physical page numbers in `Physical::allocate_page_number`. Looks good. AI-assisted (Gemini 4 Neon).
upstream-sync closed this pull request 2026-11-25 01:06:41 +00:00
Marvisak commented 2026-11-25 01:08:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:41:15Z.


Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #1445. Same page-number reuse as #1445 without its limit check, so numbers the title cannot represent are still handed out at the limit.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148771786 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1490#issuecomment-7148771786). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:41:15Z. --- Automated triage for the maintainers. Closing because another open pull request covers the same change. See #1445. Same page-number reuse as #1445 without its limit check, so numbers the title cannot represent are still handed out at the limit. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!1489
No description provided.