Repository navigation
perf(agc): answer small guest read checks without /proc/self/maps - #6179
Conversation
fedd378 to
4e97c2c
Compare
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
4e97c2c to
0621f21
Compare
0621f21 to
2bd87d2
Compare
e21b63a to
081d730
Compare
|
Tested on Linux (Arch), #6179 and #6184 together fail #6179's new test The message is the check at With the AI-assisted: yes |
|
Thanks @nicolasfalesy, that's the bug. The probe answered before the page table was consulted, so a page #6184 holds as inaccessible read as accessible whenever the host page was readable. 2108971 makes the probe step aside for any range with a recorded page state. Checked on Ubuntu 24.04 (kernel 6.8, no
So the two should now land in either order. AI-assisted: yes (Claude Code) |
On Linux kernels without PROCMAP_QUERY (before 6.11, which includes the stock Ubuntu 24.04 kernel), every guest range check that misses the page cache reads and parses /proc/self/maps up to the covering mapping. The cache only covers the guest arena and the image, so ranges in the host heap always miss. ASTRO BOT (PPSA21564) checks 96-byte shader headers there from RegisteredHeader (through SameHeader) on every sceAgcCreatePrimState and interpolant mapping, about 3,700 times per second while it loads. A read-only check of at most 4 KiB on such a kernel now first reads the range into a scratch buffer with process_vm_readv on the own process. If every byte is read, the range is readable. Anything else (a fault, a partial read, a refused call, a write check or a larger range) takes the path it took before, which also builds the failure message. agc_driver_graphics runs a second time with APS5_NO_PROCMAP_QUERY=1, so the fallback path is covered on kernels that have PROCMAP_QUERY too, and LiveStack gains read-only checks: a readable range, and ranges that end in a guard page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…age table The process_vm_readv probe answered a small read check before the page table was looked at, so a page the table holds as inaccessible (as boykopovar#6184 records them) read as accessible whenever the host page was readable. The probe now runs only for ranges with no recorded page state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2108971 to
4c50918
Compare
|
Rebased onto AI-assisted: yes (Claude Code) |
What
On Linux kernels without
PROCMAP_QUERY(before 6.11, including the stock Ubuntu 24.04 kernel),GuestMemory'sverify()reads and parses/proc/self/mapsup to the covering mapping for every range check that misses its page cache. That cache only covers the guest arena and the image, so a range anywhere else misses every time. ASTRO BOT (PPSA21564) checks the 96-byteShaderheaders it passes, which live in the host heap, fromRegisteredHeader(throughSameHeader). It does this on everysceAgcCreatePrimState,ResolveGraphicsAbiand interpolant mapping while it loads.Measured with a temporary counter around the
/proc/self/mapsfallback (the process has about 3,600 mappings at that stage):mainab9a476/proc/self/mapsreads inverify()process_vm_readvThe loader's checks run on its own thread, so the slow path throttled loading. With the fast path the title does about 40 times as many checks in the same time and gets further. The 110,000 remaining reads are write checks and ranges over 4 KiB.
Now, on such a kernel, a read-only check of at most 4 KiB first reads the range into a thread-local scratch buffer with
process_vm_readvon its own process. If every byte comes back, the range is readable, which is all a read-only check asks. Anything else takes the existing path, which also builds the failure message:EPERM(for example under a seccomp profile that blocks the call);PROCMAP_QUERY.agc_driver_graphicsis registered a second time on Linux withAPS5_NO_PROCMAP_QUERY=1, so the fallback is also exercised on kernels that havePROCMAP_QUERY.LiveStackgains read-only checks for a readable range and for two ranges that end in a guard page.Tested
Ubuntu 24.04, kernel 6.8.0 (no
PROCMAP_QUERY), GCC 13.3, Release with CI's configure flags, onmainab9a476:agc_driver_graphicsandagc_driver_graphics_maps_fallbackpass.ctestsuite passes (1,225 tests).agc_driver_graphics_maps_fallback2 of 2; this head passes it andagc_driver_graphics3 of 3, and all 663^agc_tests pass alone.tools/check_conventions.py --base upstream/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code