Skip to content

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

Draft
illu0x wants to merge 2 commits into
xcl-dev:mainfrom
illu0x:kernelx-xmem-address-limits
Draft

illu0x wants to merge 2 commits into
xcl-dev:mainfrom
illu0x:kernelx-xmem-address-limits

Conversation

@illu0x

@illu0x illu0x commented Nov 29, 2026 •

Copy link
Copy Markdown

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

KOLESNiii and others added 2 commits November 28, 2026 18:17
Decode the flags word for XCL_TRACE_MEM and the address-limit diagnostic.
Keep the existing XAllocAttrs-based allocation type so the test title's
legacy graphics requests still land in UMA. Interpreting bit 0x2 as
MEM_GRAPHICS sent retail large heaps to sparse VRAM and regressed smoke.
The focused tests cover flag decoding and both allocation cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Codex (exact model unavailable)
Titles ask for 32-bit- or N-bit-addressable graphics memory
(XMEM_GRAPHICS_32BIT_ADDRESS, XMEM_40BIT_ADDRESS..) through the flags word
that xcl-dev#3173 decodes, but XCL does not place by that limit yet. Tally how
many address-limited requests land above their limit, split by below-4GiB
and N-bit, and log the totals at shutdown. Diagnostics only: no allocation
path changes, only a shutdown log line is added.

A measured 60 s run of one retail title shows 6 below-4GiB requests, at
least one placed at ~18 GiB; a later PR will place these below the limit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added area:docs-ci Documentation, scripts, workflows, repo governance area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH labels Nov 29, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head bc01bcb, 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

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs-ci Documentation, scripts, workflows, repo governance area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants