kernelx: count XMemVirtualAlloc address-limit violations per run #3353

Open
illu0x wants to merge 2 commits from upstream-pr/3353 into main
illu0x commented 2026-11-29 10:08:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by illu0x on 2026-11-29T10:08:52Z.


Diagnostics for XMemVirtualAlloc address limits, with no behaviour change. #3173 decodes the flags word (below_4g, address_bits) and limit(), but placement ignores it. This counts, per run, how many address-limited requests land above their limit — split by below-4 GiB (XMEM_GRAPHICS_32BIT_ADDRESS) and N-bit (XMEM_40BIT_ADDRESS..) — and logs the totals at shutdown.

A measured 60 s run of one retail title: 6 of 6 below-4 GiB requests land above their 4 GiB limit (one is placed at ~18 GiB). The actual low-address placement is a follow-up PR; this lands the measurement that justifies it.

Stacked on #3173; only the top commit belongs here. Draft, blocked on #3173: its base is behind main, so the required main-baseline regression run is deferred until #3173 merges and this rebases onto main. The run below is against the stack base, as a no-regression check for this commit alone.

What is in it

  • kernelx: count XMemVirtualAlloc address-limit violations per run — the tally, the above_limit predicate, and the shutdown report in crates/xcl/src/hle/kernelx.rs; the report call in crates/xcl/src/report.rs

Tested

  • Windows 11 x64, Rust stable-x86_64-pc-windows-msvc, debug; AMD RX 6600
  • cargo test -p xcl --lib above_limit_judges_placement_against_the_address_limit: 1 passed
  • Shutdown tally observed on the head run: mem: XMemVirtualAlloc address limits (placement unchanged): below-4GiB 6/6 above the limit, N-bit 0/0 above the limit

Regression run
Deferred (draft): the main-baseline run comes after #3173 merges and this rebases onto main. For now, a no-regression check against the stack base (#3173, 599bf81a) — a main baseline today would attribute main's 14-commit drift since #3173 branched to this PR. Both 60 s, XCL_PREPARE=0, same retail title (id b41e6560), AMD RX 6600.

xcl-smoke v1
commit: 599bf81a81d0ef98c2cfea973bf319da95e64150
gpu: AMD Radeon RX 6600
title: b41e6560
seconds: 60
exit: 0x0
frames shown: 1035 (PresentX 1035)
presents per 2 s (last 3): 52 52 53
device removals: 0
crashes: 0
peak commit: 16362 MB
xcl-smoke v1
commit: bc01bcb84abb5dc60b1ef7c5e8afaec85ba8e1e9
gpu: AMD Radeon RX 6600
title: b41e6560
seconds: 60
exit: 0x0
frames shown: 1109 (PresentX 1109)
presents per 2 s (last 3): 54 61 60
device removals: 0
crashes: 0
peak commit: 16685 MB

Head vs stack base: 1109 / 1035 frames = 107%, peak commit 16685 / 16362 MB = 102%, no device removal, no crash. As expected for a diagnostics-only change (a shutdown log line plus atomic counters on XMemVirtualAlloc), the difference is within run-to-run noise.

Not tested

  • Full workspace suite on this branch; other titles; NVIDIA

AI use

  • Claude Code with Claude Opus 4.8: wrote the code, the test and this description, and ran the measurement and the regression runs. The author has read and understands the diff.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5549695094 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3353). Originally posted by [illu0x](https://github.com/illu0x) on 2026-11-29T10:08:52Z. --- Diagnostics for `XMemVirtualAlloc` address limits, with no behaviour change. #3173 decodes the flags word (`below_4g`, `address_bits`) and `limit()`, but placement ignores it. This counts, per run, how many address-limited requests land **above** their limit — split by below-4 GiB (`XMEM_GRAPHICS_32BIT_ADDRESS`) and N-bit (`XMEM_40BIT_ADDRESS`..) — and logs the totals at shutdown. A measured 60 s run of one retail title: **6 of 6 below-4 GiB requests land above their 4 GiB limit** (one is placed at ~18 GiB). The actual low-address placement is a follow-up PR; this lands the measurement that justifies it. Stacked on #3173; only the top commit belongs here. **Draft, blocked on #3173:** its base is behind `main`, so the required `main`-baseline regression run is deferred until #3173 merges and this rebases onto `main`. The run below is against the stack base, as a no-regression check for this commit alone. **What is in it** - `kernelx: count XMemVirtualAlloc address-limit violations per run` — the tally, the `above_limit` predicate, and the shutdown report in `crates/xcl/src/hle/kernelx.rs`; the report call in `crates/xcl/src/report.rs` **Tested** - Windows 11 x64, Rust `stable-x86_64-pc-windows-msvc`, debug; AMD RX 6600 - `cargo test -p xcl --lib above_limit_judges_placement_against_the_address_limit`: 1 passed - Shutdown tally observed on the head run: `mem: XMemVirtualAlloc address limits (placement unchanged): below-4GiB 6/6 above the limit, N-bit 0/0 above the limit` **Regression run** Deferred (draft): the `main`-baseline run comes after #3173 merges and this rebases onto `main`. For now, a no-regression check against the **stack base (#3173, `599bf81a`)** — a `main` baseline today would attribute `main`'s 14-commit drift since #3173 branched to this PR. Both 60 s, `XCL_PREPARE=0`, same retail title (id `b41e6560`), AMD RX 6600. ``` xcl-smoke v1 commit: 599bf81a81d0ef98c2cfea973bf319da95e64150 gpu: AMD Radeon RX 6600 title: b41e6560 seconds: 60 exit: 0x0 frames shown: 1035 (PresentX 1035) presents per 2 s (last 3): 52 52 53 device removals: 0 crashes: 0 peak commit: 16362 MB ``` ``` xcl-smoke v1 commit: bc01bcb84abb5dc60b1ef7c5e8afaec85ba8e1e9 gpu: AMD Radeon RX 6600 title: b41e6560 seconds: 60 exit: 0x0 frames shown: 1109 (PresentX 1109) presents per 2 s (last 3): 54 61 60 device removals: 0 crashes: 0 peak commit: 16685 MB ``` Head vs stack base: 1109 / 1035 frames = 107%, peak commit 16685 / 16362 MB = 102%, no device removal, no crash. As expected for a diagnostics-only change (a shutdown log line plus atomic counters on `XMemVirtualAlloc`), the difference is within run-to-run noise. **Not tested** - Full workspace suite on this branch; other titles; NVIDIA **AI use** - Claude Code with Claude Opus 4.8: wrote the code, the test and this description, and ran the measurement and the regression runs. The author has read and understands the diff. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Foniass commented 2026-12-01 09:02:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:02:04Z.


Review (head bc01bcb8, the top commit only, diff read, not a merge-check; draft, stacked on #3173, PR description red):

  • It counts calls, not allocations. A reserve followed by a commit at the same fixed address counts twice. A fixed address the title chose itself is counted as XCL misplacing it (kernelx.rs ~757). So the "6/6" in the description may be inflated. Counting only requests without a fixed address, or only reserves, would keep it to XCL's placements.
  • The totals can be logged more than once per run. They are written from report::write_final (report.rs ~308), which runs from several exits (host.rs ~299, ~316, ~319, present.rs ~741). dump_fallbacks behaves the same, so it's at least consistent (unverified how often it happens in one run). There's no report.json field; the description could say it's a log line.
  • Nits:
    • above_limit (~752) repeats the end <= limit check in trace_virtual_alloc_flags (~797) instead of sharing it.
    • Comments say "PR 2 places them", a PR that doesn't exist yet.
    • The test comment at ~2462 names a retail title; the address alone is enough.

Fine: the cost is one or two relaxed atomic increments per limited call next to a VirtualAlloc. The limit is exclusive, the add saturates, and a failed allocation isn't judged. The unit test covers the boundaries, placement is unchanged, and the stack merges cleanly with main.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7306119220 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3353#issuecomment-7306119220). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:02:04Z. --- Review (head bc01bcb8, the top commit only, diff read, not a merge-check; draft, stacked on #3173, `PR description` red): - **It counts calls, not allocations.** A reserve followed by a commit at the same fixed address counts twice. A fixed address the title chose itself is counted as XCL misplacing it (`kernelx.rs` ~757). So the "6/6" in the description may be inflated. Counting only requests without a fixed address, or only reserves, would keep it to XCL's placements. - **The totals can be logged more than once per run.** They are written from `report::write_final` (`report.rs` ~308), which runs from several exits (`host.rs` ~299, ~316, ~319, `present.rs` ~741). `dump_fallbacks` behaves the same, so it's at least consistent (unverified how often it happens in one run). There's no `report.json` field; the description could say it's a log line. - **Nits:** - `above_limit` (~752) repeats the `end <= limit` check in `trace_virtual_alloc_flags` (~797) instead of sharing it. - Comments say "PR 2 places them", a PR that doesn't exist yet. - The test comment at ~2462 names a retail title; the address alone is enough. Fine: the cost is one or two relaxed atomic increments per limited call next to a `VirtualAlloc`. The limit is exclusive, the add saturates, and a failed allocation isn't judged. The unit test covers the boundaries, placement is unchanged, and the stack merges cleanly with main. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Foniass commented 2026-12-01 09:51:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:51:02Z.


Triage (#1607) – head bc01bcb

Stacked on #3173: its first commit is #3173's, and only the top commit (note_address_limit, report_address_limits and the shutdown call in report.rs) belongs here. The shared added lines with #3173 come from that base and are not duplicates. The tally is diagnostics only: it counts address-limited XMemVirtualAlloc requests placed above their limit and does not change placement. No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7307296908 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3353#issuecomment-7307296908). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:51:02Z. --- **Triage (#1607)** – head bc01bcb Stacked on #3173: its first commit is #3173's, and only the top commit (`note_address_limit`, `report_address_limits` and the shutdown call in `report.rs`) belongs here. The shared added lines with #3173 come from that base and are not duplicates. The tally is diagnostics only: it counts address-limited XMemVirtualAlloc requests placed above their limit and does not change placement. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3353:upstream-pr/3353'
git switch 'upstream-pr/3353'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/3353'
git switch 'upstream-pr/3353'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3353'
git switch 'upstream-pr/3353'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3353'
git switch 'main'
git merge --squash 'upstream-pr/3353'
git switch 'main'
git merge --ff-only 'upstream-pr/3353'
git switch 'main'
git merge 'upstream-pr/3353'
git push origin 'main'
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
xcl-dev/xcl!3353
No description provided.