Linux: sceKernelGetModuleInfoForUnwind and sceSysmoduleGetModuleInfoForUnwind scan /proc/self/maps on every call #3235

Closed
opened 2026-10-11 02:47:41 +00:00 by GustavoGamarra95 · 1 comment
GustavoGamarra95 commented 2026-10-11 02:47:41 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by GustavoGamarra95 on 2026-10-11T02:47:41Z.


On Linux, sceKernelGetModuleInfoForUnwind (Module.cpp) and sceSysmoduleGetModuleInfoForUnwind (libSceSysmodule/Export.cpp) open /proc/self/maps and scan it line by line with sscanf on every call.

Unity IL2CPP titles call them on each stack walk. God of War Sons of Sparta (PPSA28997) has about 900 mappings. On its intro and title screens, 16 of 19 eu-stack samples of the main thread were inside that scan, and the title ran at about 10 FPS (Arch Linux, Ryzen 5 7535HS, RTX 3050 Laptop).

The kernel can answer the same question for one address with the PROCMAP_QUERY ioctl (Linux 6.11), which GuestMemory.cpp already uses. With both functions asking it on one descriptor opened once, and the line scan kept for older kernels and APS5_NO_PROCMAP_QUERY, the same screens run at 59.5 FPS (counted from MangoHud frame timestamps over 80 s).

A tested implementation is on GustavoGamarra95:perf/unwind-info-procmap-query, rebased on main d31b57a4. It has three commits: libkernel, libSceSysmodule (which loses its copy of the scan) and a new test for sceSysmoduleGetModuleInfoForUnwind, run with and without APS5_NO_PROCMAP_QUERY. It was opened as #3227 and closed by the PR intake gate. Anyone is welcome to carry it.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5797382923 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3235). Originally posted by [GustavoGamarra95](https://github.com/GustavoGamarra95) on 2026-10-11T02:47:41Z. --- On Linux, `sceKernelGetModuleInfoForUnwind` ([Module.cpp](https://github.com/boykopovar/AnyPS5/blob/d31b57a4/core/libs/prx/libkernel/Module/src/Module.cpp)) and `sceSysmoduleGetModuleInfoForUnwind` ([libSceSysmodule/Export.cpp](https://github.com/boykopovar/AnyPS5/blob/d31b57a4/core/libs/prx/libSceSysmodule/Export.cpp)) open `/proc/self/maps` and scan it line by line with `sscanf` on every call. Unity IL2CPP titles call them on each stack walk. God of War Sons of Sparta (PPSA28997) has about 900 mappings. On its intro and title screens, 16 of 19 `eu-stack` samples of the main thread were inside that scan, and the title ran at about 10 FPS (Arch Linux, Ryzen 5 7535HS, RTX 3050 Laptop). The kernel can answer the same question for one address with the `PROCMAP_QUERY` ioctl (Linux 6.11), which `GuestMemory.cpp` already uses. With both functions asking it on one descriptor opened once, and the line scan kept for older kernels and `APS5_NO_PROCMAP_QUERY`, the same screens run at 59.5 FPS (counted from MangoHud frame timestamps over 80 s). A tested implementation is on [GustavoGamarra95:perf/unwind-info-procmap-query](https://github.com/GustavoGamarra95/AnyPS5/tree/perf/unwind-info-procmap-query), rebased on `main` d31b57a4. It has three commits: libkernel, libSceSysmodule (which loses its copy of the scan) and a new test for `sceSysmoduleGetModuleInfoForUnwind`, run with and without `APS5_NO_PROCMAP_QUERY`. It was opened as #3227 and closed by the PR intake gate. Anyone is welcome to carry it.
GustavoGamarra95 commented 2026-10-11 10:43:31 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by GustavoGamarra95 on 2026-10-11T10:43:31Z.


Fixed by #3227, merged into main (0c63c838). Thanks @oneandonlydean for reopening it and @adriadam10 for the review.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108191988 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3235#issuecomment-6108191988). Originally posted by [GustavoGamarra95](https://github.com/GustavoGamarra95) on 2026-10-11T10:43:31Z. --- Fixed by #3227, merged into `main` (0c63c838). Thanks @oneandonlydean for reopening it and @adriadam10 for the review.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#3235
No description provided.