feat(libkernel_sys): implement scheduler policy query #9369
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9369"
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 MarcZX10 on 2026-10-21T19:30:41Z.
What
Implements
sched_getparamandsched_getschedulerfor the current guest process. Both accept pid 0 or the current process ID; the former returns the calling guest thread's tracked priority and the latter its tracked FIFO/round-robin policy. Invalid process IDs returnESRCH, null output returnsEFAULT, and an unsupported tracked policy returnsEINVAL. The debt entry records the scope and that console behavior remains unverified.Tested
Linux x86-64:
libkernel_sysandguest_kernel_sys_testsbuilt successfully.ctest -R '^guest_kernel_sys$'could not start because this VM's Intel Xeon E5-1620 v2 lacks required guest-execution CPU features (LZCNT, BMI1, BMI2, MOVBE, AVX2 and FMA). Convention checks passed. No overlap with open PRs.Checklist
main; no other open PR implements the same functionsNotImplemented_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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T19:31:29Z.
Progress report (
584c5a8→afe568e)📈 System libraries: 42.12% (+0.02%, +2 implemented functions)
✅ 2 implemented
sched_getparam_nid_postfixsched_getscheduler_nid_postfixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T19:52:35Z.
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)docs/dev/debt/libkernel_sys.mdL7-8core/libs/prx/libkernel_sys/Export.Discovery.cppL2451-2460sched_getparamsched_getschedulercore/libs/tests/GuestKernelSys.cppL1-2, L61Some 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.
core/libs/tests/GuestKernelSys.cppcore/libs/tests/GuestKernelSys.cppcore/libs/tests/GuestKernelSys.cppdocs/dev/debt/libkernel_sys.mdcore/libs/tests/GuestKernelSys.cppdocs/dev/debt/libkernel_sys.mddocs/dev/debt/libkernel_sys.mdcore/libs/prx/libkernel_sys/Export.Discovery.cppdocs/dev/debt/libkernel_sys.mdcore/libs/prx/libkernel_sys/Export.Discovery.cppdocs/dev/debt/libkernel_sys.mdcore/libs/prx/libkernel_sys/Export.Discovery.cppcore/libs/tests/GuestKernelSys.cppdocs/dev/debt/libkernel_sys.mdcore/libs/tests/GuestKernelSys.cppcore/libs/prx/libkernel_sys/Export.Discovery.cppcore/libs/tests/GuestKernelSys.cppdocs/dev/debt/libkernel_sys.mdcore/libs/prx/libkernel_sys/Export.Discovery.cppdocs/dev/debt/libkernel_sys.mdcore/libs/prx/libkernel_sys/Export.Discovery.cppdocs/dev/debt/libkernel_sys.mdImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T20:41:30Z.
Independent Windows run of this PR (data only).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against
mainis clean. I built onlyguest_kernel_sys_tests;ctest -N -R guest_kernel_syslists exactly one test.PR head tested:
afe568e9e1d812ce69927ef144ae3619d09936c5.Results (3 runs each):
guest_kernel_syspasses 3/3.core/libs/prx/libkernel_sys/Export.Discovery.cppwith the version from the PR's merge base (1896871ba7), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.GPU: the run output has no
Selected GPUline; no GPU claim is made.Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-21T23:39:40Z.
Linux run, and one difference from FreeBSD that a guest can reach.
Head
afe568e9e1merged onto maina6dcea927(clean). Windows 11 Home 10.0.26300, Ryzen 5 9600X, WinLibs GCC 15.2.0 (MinGW-w64 UCRT), Release,BUILD_TESTING=ON; WSL2 Ubuntu 24.04, GCC 13.3.0, Release.guest_kernel_sys: 3/3 on Linux (the description has no Linux test run), 3/3 on Windows. WithExport.Discovery.cppfrom main:sched_getparam_nid_postfix not implemented.check_conventions.py --base a6dcea927: passes.SCHED_OTHERthreads getEINVAL.pthread_attr_setschedpolicyaccepts 1 to 3 (Posix/Attr.cpp:141), and withPTHREAD_EXPLICIT_SCHEDthe new thread stores that policy (Pthread/src/Thread.cpp:390). Probe: create a thread with an explicit policy, then callsched_getscheduler(0)in it. Same on Windows and Linux:FreeBSD 11.4's
getschedulercannot fail: anything that is not FIFO or round-robin reportsSCHED_OTHER(ksched.c L106-L125). Returning 2 for policy 2 matches that. The test'sschedPolicy.store(0)case would then need a different expectation.sched_getparam/sched_getscheduler(O6gKl8uvGyE,SD7oNCIQWvE) are exported by PS5 3.20 libkernel as well as libkernel_sys (libkernel.c L8843-L8844). On Windows a libkernel import does not search libkernel_sys (WindowsEntryStubBuilder.cpp:175-177), so titles that import them from libkernel will not reach this code.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T07:44:59Z.
Closing this PR to avoid duplicate export work under CONTRIBUTING.md and the duplicate-export convention. Earlier open #9187 covers sched_getparam and sched_getscheduler, adds sched_setparam, and moves these exports to libkernel while removing the libkernel_sys copies. The overlap check also flagged the same exports. I have not transferred any code. Please continue scheduler work through the single coordinated implementation and resolve the independent findings there.
Pull request closed