Skip to content

fix(agc): cache Linux describePages results - #4395

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
oneandonlydean:up4/carry-1810
Oct 12, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
oneandonlydean:up4/carry-1810

Conversation

@oneandonlydean

Copy link
Copy Markdown
Collaborator

What

This carries #1810 by @Swastik-51, rebased onto main after #3454, with the commits and their authors kept: fix(agc): cache Linux describePages results (@Swastik-51), fix(agc): store only the requested pages of a Linux page query (@ahir061) and the test commit I pushed to that branch on 10-10. #1810 was reviewed and accepted there; it could not go green because the AI-assisted: line of its description was never answered, which only the author can do on his PR. The only conflict was the name #3454 gave the query helper: ProcMapsQueryFd() is now HostMapping::QueryFd(), and the carry uses the new name. The changed lines are otherwise the same as in #1810.

Fixes #1791.

On Linux, describePages asked the kernel (PROCMAP_QUERY, or /proc/self/maps on kernels before 6.11) what a guest range maps to but did not store the readable pages it found in the page table, so every uncached guest-range check repeated the query.

  • Adds PageStates::record(), shared by both platforms, which stores the page state. The Windows VirtualQuery path already did this inline and now calls it.
  • The PROCMAP_QUERY path and the /proc/self/maps path store their results the same way.
  • Only the pages of the request, rounded out to whole pages, are stored. Linux merges adjacent anonymous mappings with equal flags, so an arena VMA can span GiBs, and storing all of it on each miss would rewrite every page after an invalidation.
  • The generation check and the invalidation through the allocation registry are unchanged.

Titles, from the runs posted on #1810:

  • Hades II (PPSA36082): 25.8 → 32.7 fps, p95 frame time 41.2 → 32.5 ms (@Raghav314, RTX 4090, standing in the hub for 20 s); 25.1-26.0 → 31.1-32.7 fps and 81.0 → 62.6 µs of AGC worker time per draw packet on a second machine (@eliyarson, RTX 3080 Ti, measured after refactor(agc): share the PROCMAP_QUERY lookup with GuestMemory #3454 with the same resolution of the rename). Before the change the PROCMAP_QUERY ioctl from describePages was the top frame in 116 of 400 samples of the AGC worker thread there.
  • Disney Epic Mickey: Rebrushed (PPSA15657) on kernel 6.8, where the /proc/self/maps path is used: logos and intro movies 5-6 → 57-60 fps, and the title screen is reached (@johnmaia).
  • PPSA28997: 7.4 → 60.3 fps where the frame rate was bound by these queries (@jeffrey12cali).

Tested

Linux (CachyOS, kernel 7.2, GCC 16.2.1, RTX 4090, NVIDIA 610.57.04), Release, configured with the CI flags (-DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON), on main 2979ae3:

  • Full build passes.
  • agc_driver_graphics (the arena block of RunUnmappedGapTests, which runs on Linux since fix(guest-arena): place guest address space in the PS5 window on Linux #861): with GuestMemory.cpp as on main and the test from this PR it fails with a checked arena page was queried again instead of read from the page table; with the change it passes.
  • ctest -R "agc|guest_|memory|write": 752 of 752 pass, on main and with the change (agc_driver_stencil_ref_export reports skipped on both).
  • python3 tools/check_conventions.py --base origin/main and tools/check_test_registration.py pass.
  • A 2D title we test with: one unattended run to gameplay passes its frame checks, no skipped draws, no fatal lines, no GPU errors in the kernel log.
  • The fps figures above are the testers' own, from fix(agc): cache Linux describePages results #1810; I did not measure a frame rate difference here.

Not tested here: the /proc/self/maps path (this kernel has PROCMAP_QUERY; @johnmaia ran it on kernel 6.8, before the rebase), Windows (the VirtualQuery path only moves into record(); the CI job is the test), and Hades II on this rebase.

Checklist

  • Based on current main; no other open PR implements the same functions (fix(agc): cache Linux describePages results #1810 is the PR this replaces)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Claude Code)

Swastik-51 and others added 3 commits October 12, 2026 21:35
describePages stored the whole VMA that PROCMAP_QUERY or /proc/self/maps returned. Linux merges adjacent
anonymous mappings with equal flags, so an arena VMA can span GiBs, and the first table miss inside it after
an invalidation rewrote every page of it. Only the pages of the request, rounded out to whole pages, are
stored now, as boykopovar#1791 describes.

When the guest arena is available, RunUnmappedGapTests checks that a check stores no pages outside its
range, and that protecting and unmapping through the registry clears the stored pages. The registry checks
follow the test on the perf/linux-page-cache branch linked from boykopovar#1791.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Revoke a checked arena page with mprotect behind the registry and check
that the stored answer comes back, so the test fails without the cache.
Pass the gpu argument that GuestAllocations::Mutation::Add and Protect
now take.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AGC: on Linux, describePages never stores PROCMAP_QUERY results in the page table, so every uncached guest-range check is an ioctl

3 participants