kernelx: the process's commit from VirtualQuery when PrivateUsage is 0 #2352
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2362"
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?
Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-25T16:40:39Z.
Under Wine, XCL tells a title how much memory it uses from the wrong counter. Wine's
K32GetProcessMemoryInfoleavesPrivateUsage0, andprocess_private_bytes()then falls back toPagefileUsage, which under CrossOver on macOS is the process's virtual size (~41 GiB) and does not move when memory is committed.TitleMemoryStatusandXMemGetWorkingSetStatisticsclamp that to the title memory budget, so a title on a Mac is told it has no memory available, and the activity log's commit figure (which readsPrivateUsageitself) is 0. WhenPrivateUsageis 0, the commit is now the sum of the process'sMEM_COMMIT+MEM_PRIVATEregions fromVirtualQuery. Windows, wherePrivateUsageis filled, is unchanged.Part of #258. It touches the same lines in
host.rsas #1097, which changes only the activity log and leaves the title-memory functions onPagefileUsage. On Wine under Linux this uses theVirtualQuerysum too, where #1097 keepsPagefileUsage.What is in it
crates/xcl/src/hle/kernelx.rs:process_private_bytes()falls back to a newcommitted_private_bytes()(aVirtualQuerywalk of the address space) instead ofPagefileUsage; new testprocess_private_bytes_counts_a_commitchecks that a 256 MB commit shows in both.crates/xcl/src/host.rs: the activity log's "committed by the process" figure usesprocess_private_bytes().Tested
x86_64-pc-windows-gnu, debug, onmain65fc114.cargo test -p xcl --lib --target x86_64-pc-windows-gnu --no-run, then each test ofhle::kernelx::testsin its own process in the CrossOver bottle (--exact <test> --test-threads=1): 42 tests, 41 passed, 0 failed, 1 ignored (scatter_timing), 0 SKIPPED.physical_home_without_sparse_windows_uses_coherent_windowpassed but its process did not exit within 120 s once; three reruns passed and exited normally.process_private_bytes_counts_a_commitfails:commit 44183973888 -> 44183977984(+4 KiB on a 256 MB commit). With the fix it passes.Regression run
scripts/smoke.ps1on.Not tested
hle::kernelx::testsmodule ran.VirtualQuerywalk when a title callsTitleMemoryStatus/XMemGetWorkingSetStatisticsoften (not measured).AI use
main, checked open PRs for overlap, built the tests, ran thekernelxtests and the check with the fix taken out under CrossOver, and drafted the commit message and this description.upstream-sync referenced this pull request2026-11-25 18:03:21 +00:00
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T18:50:15Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:55:16Z.
Review: COMMENTED
No concrete code defect found. The VirtualQuery fallback correctly sums committed private regions when K32 PrivateUsage is zero/fails, and opt-in 2s activity sampling keeps cost bounded. Merge readiness still needs the required description/smoke evidence. The 256 MiB process-wide allocation test has parallel flake/resource risk (it permits 64 MiB concurrent freeing); consider a controlled lower-allocation seam or document the cost. An independent Win11 report also notes an intermittent parallel abort worth reproducing.
Imported from ivall/xcl. Originally posted by Oliwettoo on 2026-11-25T22:44:56Z.
Read from the diff at
619cbb2(not run). The fix is right for the counter, but on Wineprocess_private_bytes()now walks the whole address space withVirtualQueryon every call, and its callers are title-facing:TitleMemoryStatusandXMemGetWorkingSetStatistics, which engines can poll often to size pools and texture streaming. A title with many small regions (a 24 GB reservation of 64 KiB pages, committed piecemeal) has thousands of regions to visit each time. Caching the sum for a short interval (e.g. 250 ms, or refreshed from the 2 s activity tick) would keep a polling title off that walk. Worth a timing under Wine on a retail title before merging.Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:45:05Z.
This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:48Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:55:48Z.
Triage (#1607) – head
064347f#1097 fixes the same Wine problem (PrivateUsage is 0) another way. It keeps PagefileUsage for the guest title-memory APIs and uses it for the activity log on Linux Wine only. This PR replaces the PagefileUsage fallback everywhere with a sum of the MEM_COMMIT + MEM_PRIVATE regions from VirtualQuery, which is also correct on a Mac.
Under Wine,
committed_private_byteswalks the whole address space on every call.TitleMemoryStatus, the stats write at kernelx.rs:1642 andmemory_reportall call it, so a title that polls these often pays a full walk each time. The cost is not measured in the PR.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-12-01T13:14:08Z.
Independent D103 review at
064347f. One edge case that distinguishes this from #1097 is a failed process-counter query: this PR still walks committed private regions and supplies that result to guest title-memory queries. The added 256 MiB allocation test checks an actual increase in both measurements. It does not measure the cost of repeated guest polling, so that question remains open.Group D103 review on #1607. AI use: OpenAI Codex (GPT-6) read and compared both diffs. No builds or tests were run for this review.
View 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.