fix(kernel): honor the declared flexible memory budget #4508
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4508"
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 boykopovar/AnyPS5. Originally posted by jradelmo on 2026-10-12T13:49:44Z.
What
Read the optional
kernel.flexibleMemorySizevalue fromparam.jsonand apply it consistently to configured, available and mapped flexible memory. Keep the 448 MiB default when the field is absent, and reject values that are not positive 16 KiB-aligned unsigned integers.Add parser and guest-memory regression coverage for declared, limited, default, missing and invalid budgets, including accounting for loaded guest module segments.
Tested
Windows, MinGW-w64 GCC 15.2.0, Release.
param_json_parser_testsandguest_flexible_memory_budget_tests.param_json_parserand the fiveguest_flexible_memory_*cases: 6/6 passed.python tools/check_conventions.py --base origin/mainpassed.git diff --checkpassed.kernel.flexibleMemorySize: 838860800(800 MiB) inparam.json.[memory] flexible memory exhausted: request 0x80000 with 0x21ad8000 of 0x1c000000 in use[memory] configured flexible memory: 0x32000000 bytes (800 MiB)and continued loading for about 73 seconds before being stopped; reaching the menu was not confirmed.Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:23:54Z.
Which title declares
kernel.flexibleMemorySizeand runs out at 448 MiB on main? With the title ID, its param.json value and the[memory] flexible memory exhaustedline this can go in; otherwise I'll close it until one does.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T00:36:34Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/CMakeLists.txtL1157docs/dev/debt/libkernel.mdL40core/libs/prx/libkernel/CMakeLists.txtL1157Imported from boykopovar/AnyPS5. Originally posted by jradelmo on 2026-10-13T00:56:39Z.
Hey @oneandonlydean
The title is Black Myth: Wukong, PPSA23226, master version 02.00, content version 01.000.010 (content ID
HP6545-PPSA23226_00-GAME000000000000).Its installed
/app0/sce_sys/param.jsondeclares:838860800is0x32000000, or 800 MiB. The original file was not edited for these tests; its SHA-256 is403B75F52A5765135BAE3B663BC2A4D8A04EA16E229137B0F4964CFBC65EABD1.The pre-fix startup log contains this failure at line 154:
I also reproduced the same failure today in a controlled regression run, using the integrated Wukong branch and changing only the configured budget back to the 448 MiB default used by main. The unchanged installation produced:
The request is 512 KiB; image segments and tracked flexible mappings already account for 538.84375 MiB, exceeding the hardcoded 448 MiB budget.
_mapFlexibleconsequently returnsSCE_KERNEL_ERROR_ENOMEM. A guest access violation follows in both logs.With the fix restored, the startup log prints the requested diagnostic at line 154:
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T01:16:09Z.
Two things left before this goes in:
docs/dev/debt/libkernel.md: add a line for the budget. The direct memory size is not reduced when a title declares more than 448 MiB, and rejecting zero or a value that is not a multiple of 16 KiB is not measured on the console. Line 43 there still says "the 448 MiB flexible budget".flexible memory exhaustedline there.Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-13T07:25:35Z.
Tested on Windows with Black Myth: Wukong (PPSA23226). Its
param.jsondeclareskernel.flexibleMemorySize838860800 (800 MiB).Without this PR, the title stops 12.5 s after launch:
With this PR merged into the same build, there is no
flexible memory exhaustedline. The title sets its window title and runs for 270 s. It then stops on an unrelated engine watchdog:GameThread timed out waiting for RenderThread after 120.00 secs. That run started with a cold shader cache.The build was
mainplus several of my open PRs, including #4960, which this title needs to start.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T22:38:00Z.
Both points are in. The branch now has a merge commit (
afd245256d); please rebase onto main and force-push instead.Imported from boykopovar/AnyPS5. Originally posted by jradelmo on 2026-10-14T00:12:14Z.
rebased @oneandonlydean