Repository navigation
feat(libkernel): count committed ranges in sceKernelGetPageTableStats - #4725
Conversation
|
Overlap note: #4101 implements the same function and predates this PR — my open-PR search missed it when I picked up #4067, apologies. The difference between the two: #4101 reports the 2048/2048 totals statically ("KytyPS5 additionally counts the 2 MiB entries of the committed ranges as used; this PR does not"). This PR does that counting — Same signature, constants, sources and EFAULT behavior otherwise. Happy to defer to whichever approach maintainers prefer. |
|
The live-range accounting is a useful distinction from #4101’s fixed available count, and the added mapping/protection tests exercise that behavior. I checked the exact PR branch against current main: it is nine commits ahead and includes two merge commits carrying unrelated discussion-template and shader/AGC changes (the page-table implementation itself is a focused commit). Please rebase/cherry-pick the page-table work onto current main before merge, then coordinate with #4101 on which implementation should proceed; the two PRs modify the same export, and the dynamic accounting here is the more complete behavior if its assumptions/tests are validated. No pressure on merge order—maintainers can choose the path. |
adriadam10
left a comment
There was a problem hiding this comment.
#4101 is merged now, so this conflicts with main in DirectMemory/Export.cpp and docs/dev/debt/libkernel.md. Please rebase onto current main (and drop the two unrelated merge commits MarcZX100 mentioned) so the diff is just the accounting change on top of the merged function.
Points to fix, since the PR says it follows KytyPS5's CountPageTableEntries:
DirectMemory.cpp:1124: Kyty charges a range to the CPU pool when it has any CPU access bit and to the GPU pool when it has GPU access bits, so a range with both counts in both. Here a range with0x30is charged to GPU only.DirectMemory.cpp:1121: Kyty only counts committed range types;g_protectionsrecords every guest mapping, including ones that are not committed memory. Say which ranges are meant to count and filter accordingly.DirectMemory.cpp:1123: entries are summed per range, so contiguous ranges smaller than 2 MiB that share a granule (any partialmprotectsplits a range) each charge it again. Count each granule once per pool, or state that the double count matches Kyty and pin it in the test.Export.cpp:399: with unverified constants,availablecan now drop to 0 wheremainreports 2048. Please show the numbers a typical start-up produces (e.g. the values printed at the call in PPSA30601) so we know the dynamic count doesn't starve a title that the static answer lets through.- Test: add a case with two sub-2 MiB neighbours in one granule and one for a CPU+GPU protection, with expected values taken from Kyty's rules, not from this implementation's output.
c84d3c9 to
59391b6
Compare
|
Rebased onto current Since #4101 merged first, this PR's diff now reads as: static totals kept, AI-assisted (Devin). |
59391b6 to
08774c0
Compare
|
All five points addressed in 08774c0:
AI-assisted (Devin). |
|
Verified on WSL Ubuntu 24.04 as well — |
08774c0 to
b5d80ad
Compare
adriadam10
left a comment
There was a problem hiding this comment.
Checked the counting against KytyPS5's CountPageTableEntries (per committed range, cpu and gpu pools independent, no-access ranges skipped, clamped at 2048): same results. The five earlier points are addressed. The only conflict was the sceKernelGetPageTableStats line in docs/dev/debt/libkernel.md next to clock_settime; rebased onto main, kept your entry. Scoped build and ctest 150/150, and guest_page_table_stats fails without the change. Merging once the full Build is green.
b5d80ad to
f9cc81d
Compare
|
Rebased onto current AI-assisted (Devin). |
|
Rebase handoff — rebased onto current Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
To pick it up: Head is |
|
f9cc81d is the current head — already rebased onto |
Charge each recorded protection ranges 2 MiB granules to the gpu pool when the range has GPU-access protection bits and to the cpu pool otherwise, so the available counts reflect committed usage instead of staying at the 2048-entry budget. Follows KytyPS5s counting model.
f9cc81d to
975ed12
Compare
|
Rebuilt on current |
What
Builds on the
sceKernelGetPageTableStatsimplementation merged in #4101 (issue #4067) by adding the usage counting it explicitly deferred:GuestPageTableUsageiterates the recorded protection ranges, charges one page-table entry per 2 MiB granule a range spans to the gpu pool when the range has GPU-access protection bits (0x30) and to the cpu pool otherwise, and follows changes through map/protect/unmap — soavailablereflects committed usage instead of staying at 2048. Totals, EFAULT-on-null and the KytyPS5 model (4 GiB pool / 2 MiB granules / 2048 entries) are unchanged from #4101.Unverified constants remain recorded in
docs/dev/debt/libkernel.mdper conventions.Tested
WSL Ubuntu 24.04, llvmpipe, on current
mainincluding #4101.guest_page_table_statscovers: EFAULT for each null argument, cpu accounting of a flexible mapping and its restore on unmap, cpu/gpu reclassification throughsceKernelMprotect, and gpu accounting of a direct mapping.guest_memory(which now contains #4101'sCheckPageTableStats),guest_memory_pool_stats,guest_addresses,guest_mlock,guest_msyncall pass;check_conventions.py --base upstream/mainclean. No console run — budget constants unverified on hardware.Checklist
main; layered on the implementation merged in fix(libkernel): answer sceKernelGetPageTableStats #4101NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)