Repository navigation
fix(libkernel): report a thread's class and priority from rtprio_thread as measured on a PS5 - #7853
Conversation
…ad as measured on a PS5 RTP_LOOKUP threw for every thread made with the sce attributes, which allow only SCHED_FIFO and SCHED_RR, since the rtprio mapping was unmeasured. In a payload process on a PS5 (firmware 12.70) the lookup reports type 10 for SCHED_FIFO and 2 for SCHED_RR with prio equal to the scheduling priority, for the calling thread and for another live thread by its id; an unknown id fails with ESRCH, and so did function 2. Report that, and keep RTP_SET throwing for real-time and other threads, where no accepted value was measured.
da00182 to
4f004b0
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.
|
fogydes
left a comment
There was a problem hiding this comment.
Reviewed the diff, hardware probe evidence, and test fixtures:
- Author provides direct hardware oracle logs (
p79_libkernelon firmware 12.70) establishing thatrtprio_threadRTP_LOOKUPreturns type 10 (RTP_PRIO_FIFO) forSCHED_FIFOthreads and type 2 (RTP_PRIO_REALTIME) forSCHED_RRthreads with priority values in the 256–767 range, while an unrecognized function returnsESRCH(3) rather than FreeBSD'sEINVAL. Pthread/Posix/Thread.cppandPthread/src/Thread.cpp:GetLiveGuestThreadSched_nid_no_patchqueries live thread scheduling state cleanly under the registry lock, enabling lookups across threads by LWP ID.GuestRtprioThread.cpp: Covers self-lookups, target LWP lookups across FIFO/RR priorities, joined-thread lifecycle error assertions (ESRCH), null pointer guards (EFAULT), and verifies thatRTP_SETcontinues throwing.- CMake configuration correctly includes
configure_windows_unwindand the Windows DLL search path modification. - Zero comments added in code; Conventional Commits title; debt documentation in
docs/dev/debt/libkernel.mdupdated with measured values.
AI-assisted: yes
|
Morrowind (PPSA99630, the A local trace of the arguments shows one call before it stops, on It then throws AI-assisted: yes |
|
Console rows that overlap the attribute part of p79, measured on a PS4 Pro (firmware 10.71, The PS4 matches the PS5 log on these points: only |
|
Re-checked against current |
What
rtprio_threadthrewNotImplementedfor every thread made with the sce attributes, which allow onlySCHED_FIFOandSCHED_RR, because the console's mapping from a scheduling priority to the rtpriopriowas unmeasured. The debt entry names Morrowind (mshivam019/morrowind-ps5) as an importer at start-up.Measured in a payload process on a PS5 (firmware 12.70; payload SDK v0.44, clang 18.1.8), calling
rtprio_threadresolved fromlibkernel_sys.sprxwith anrtprioof the probe's own, on its main thread and on threads it created withscePthreadCreateand an explicit policy and priority (probep79_libkernel, source and log attached: p79-rtprio-equeue.zip; lines quoted unchanged with ap79:prefix;policy/prioare whatscePthreadGetschedparamreported inside the thread,type/rtpriowhatRTP_LOOKUPwith lwpid 0 reported there,rtprio_otheris the lookup by the thread's id from the main thread):So
RTP_LOOKUPreports type 10 (RTP_PRIO_FIFO) for aSCHED_FIFOthread and 2 (RTP_PRIO_REALTIME) for aSCHED_RRthread, withprioequal to the thread's scheduling priority (700, 256, 384, 512, 640, 767), for the calling thread and for another live thread by its id; an id that is no thread fails withESRCH, function 2 withESRCH, a nullrtpriowithEFAULT.RTP_SETwith type 2 and prio 0, 15 or 31 failed withEINVALon both classes and changed nothing.SCHED_OTHERwas refused byscePthreadAttrSetschedpolicy(0x8002002d) and priorities 896 and 959 byscePthreadAttrSetschedparam, so those threads ran asSCHED_FIFOat their default or requested priority (700; 512 forother512) and are not measurements of those requests.The change:
rtprio_thread_nid_postfixreportsRTP_LOOKUPfor the calling thread and, through a newGetLiveGuestThreadSched_nid_no_patch, for another live guest thread by its id: type 10 or 2 by the thread's policy andprioits priority; a thread that is not real-time keeps reportingRTP_PRIO_NORMAL(3) with 0 as before (the payload process refusedSCHED_OTHERthroughscePthreadAttrSetschedpolicy; the POSIXpthread_attr_setschedpolicypath was not probed, and here it storesSCHED_OTHER). An unknown function fails withESRCHinstead ofEINVAL(measured for function 2 only).RTP_SETkeeps throwing for a real-time thread and for another thread, since no accepted value was measured; the measuredEINVALs are recorded in the debt entry.guest_rtprio_thread(new): lookups on the main thread, on itself by id, inside and from outsideSCHED_FIFOthreads at 512 and 256 and aSCHED_RRthread at 600,ESRCHafter the thread is joined,ESRCHfor function 2 and ids 1 and 999999,EFAULTfor a nullrtprio, and thatRTP_SETstill throws for the calling thread and for another thread.guest_sched_prioritynow expects the lookup to succeed with type 10 and prio 700 on its main thread andESRCHfor function 2.RTP_SETon real-time and other threads, non-real-time threads) with what was measured for them, and the lookup and error codes in one sentence each.Not measured:
RTP_SETwith type 10 or with a prio in 256-767 (the probe restores each thread's looked-up type and prio with one such set but does not record its result),RTP_SETby another thread's id (none issued), a non-real-time thread, a thread of another process, and a game process; Morrowind was not run.Overlaps:
tools/pr_overlap.pyreports one open PR that changes the same lines: #7658 turns the threeNotImplemented_nid_no_patchcalls ofrtprio_thread(and cpuset's) intostd::runtime_errorthrows; it adds no lookup, so whichever lands second rebases the throw lines. It could not compare 27 PRs that conflict withmainand share a file with this branch (Pthread/src/Thread.cpp,Pthread.hpp,Posix/Thread.cpp, the libkernelCMakeLists.txt,GuestSchedPriority.cppor the libkernel debt file): #3986, #4972, #5021, #6044, #6149, #6226, #6446, #6469, #6519, #6879, #6908, #6936, #6942, #6977, #7039, #7049, #7075, #7088, #7105, #7121, #7129, #7149, #7192, #7201, #7299, #7332 and #7509; of those, the ones that touch the three thread files (#3986, #5021, #6879, #6908, #7149, #7201, #7332) change nortprio_threadline. No open PR implements the lookup.Tested
Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0 r7 (posix, UCRT), Ninja, Release,
-DBUILD_TESTING=ON, branch built and tested onmain36f60df, then rebased on f72c7aa; of the touched files,mainmeanwhile changed other lines of the libkernelCMakeLists.txtand debt file (#7813), with no conflict; the two tests rebuilt and rerun after the rebase, passed.guest_rtprio_thread(new),guest_sched_priorityandguest_pthread_schedparampass (3 of 3; the first two twice).Pthread/Posix/Thread.cpp,Pthread/src/Thread.cppandPthread/include/Pthread.hppfrommainand the tests kept,guest_rtprio_threadandguest_sched_priorityboth abort with "unhandled exception 'St13runtime_error' ... what(): rtprio_thread: a guest thread's real-time class not implemented"; restored, both pass.python tools/check_conventions.py --base origin/mainpasses.p79_libkernelbuilt with the payload SDK v0.44 and clang 18.1.8 (-target x86_64-sie-ps5), launched once through the payload manager; its equeue section is not used by this PR.Not tested: Linux (the change has no host-specific code;
GetLiveGuestThreadSched_nid_no_patchreads the same registry as the affinity helpers next to it), Morrowind or any title.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)