feat(libkernel): implement real-time priority sets in rtprio_thread #27994
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27994"
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 cmsierrave-coder on 2026-11-28T02:07:27Z.
What
Implement real-time thread priority sets (
RTP_PRIO_REALTIME= 2 andRTP_PRIO_FIFO= 10, priorities 256..767) inrtprio_thread(RTP_SET), replacing the remaining real-timeNotImplemented_nid_no_patchthrow while keeping idle (960) and normal+FIFO (615..895) throwing as documented.SetLiveGuestThreadSched_nid_no_patch(tid, policy, priority)incore/libs/prx/libkernel/Pthread/include/Pthread.hppandcore/libs/prx/libkernel/Pthread/src/Thread.cppunderCpuClocks().lockso guest scheduling policy (SCHED_RR/SCHED_FIFO) and priority are updated atomically on live target threads (self vialwpid == 0or own thread id, or another live thread bylwpid) and returnfalse(ESRCH) once ended.rtprio_thread_nid_postfixincore/libs/prx/libkernel/Pthread/Posix/Thread.cppto applySCHED_FIFO/SCHED_RRand priority256..767viaSetLiveGuestThreadSched_nid_no_patch, preservingerrnoon success and returningESRCHif the target thread exited concurrently.core/libs/tests/GuestRtprioThread.cppto verify self and cross-thread real-timeRTP_SETacross boundaries (256,512,767), read-only inputGuestRtPrio*handling, consistency withrtprio_thread(RTP_LOOKUP),scePthreadGetschedparam,pthread_getschedparam,scePthreadGetprio,pthread_getprio,sched_getscheduler, andsched_getparam, unchangederrnoon success, andESRCHafter thread exit.docs/dev/debt/changes/fix-libkernel-rtprio-thread-set-classes.md.Tested
Windows 11 (MinGW-w64 / WinLibs GCC 15.2.0, Ninja Release build):
cmake --build build --target libkernel guest_rtprio_thread_tests guest_pthread_schedparam_testsbuilt cleanly.ctest --test-dir build -R "^(guest_rtprio_thread|guest_pthread_schedparam)$" --output-on-failure -Vpassed 2/2 (guest_pthread_schedparam0.16s,guest_rtprio_thread0.12s).python tools/debt_fold.py --checkpassed.python tools/guest_pointer_audit.py libkernelshowed zero findings inPthread/Posix/Thread.cppandSetLiveGuestThreadSched_nid_no_patch.python tools/check_test_registration.py buildpassed (3743 test executables, 0 unrecorded).python tools/check_conventions.py --base origin/mainpassed.python tools/pr_overlap.py --names rtprio_threadandpython tools/pr_overlap.py --branch feat/libkernel-rtprio-thread-setchecked all open PRs; all 14 conflicted Pthread PRs were manually inspected by title and do not touchrtprio_thread.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-28T02:10:48Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
992aa93f62:tools/check_conventions.pypassed.guest_rtprio_thread_testsbuilt cleanly.guest_rtprio_thread):core/libs/prx/libkernel/Pthread/Posix/Thread.cpp,core/libs/prx/libkernel/Pthread/include/Pthread.hpp,core/libs/prx/libkernel/Pthread/src/Thread.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-28T02:15:17Z.
Review: COMMENTED
f2e2445b-a44c-43c8-ae4d-8061fd0f0107Reviewing files that changed from the base of the PR and between
c479945ac2and992aa93f62.core/libs/prx/libkernel/Pthread/Posix/Thread.cppcore/libs/prx/libkernel/Pthread/include/Pthread.hppcore/libs/prx/libkernel/Pthread/src/Thread.cppcore/libs/tests/GuestRtprioThread.cppdocs/dev/debt/changes/fix-libkernel-rtprio-thread-set-classes.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T07:01:46Z.
Review: APPROVED
Checked head
992aa93f62. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomain4c7578e0a4together with #28006, #27985, #28002, #28001, #27991, #27987, #28007.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded. In the full CPU suite (5,135 tests) the only failure iswindows_read_trap_unknown, which fails onmaintoo (fixed in #28028).guest_rtprio_threadpasses.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T07:24:16Z.
Review: APPROVED
Reviewed — looks good
The implementation at head
992aa93f62b3c9bff3bc9c2e1a8e3471a2d0fa0bupdates live guest scheduling policy and priority under the thread registry lock; the described build and tests are author-reported and were not run in this review.What I ran
Read the prepared diff and the changed files at the pinned head through
repo_read.pytools. No commands or tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the build, tests, or the other checks listed in the PR description, and did not verify behavior on a physical console. The description, commits, diff, manifest, and all five changed files were read;
files.jsonwas not available in the review folder. No changed file was excluded by the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T06:57:58Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes at head
a3d7caa4739326cf234573aed82305dcaceb1287show no verified blocking defects; builds and behavioral tests were not run independently.What I ran
Read the changed files supplied in the review folder and used
repo_read.pyto inspect live-thread locking and scheduling context at the pinned head. The reader returned the requested source text, then exited with an error when it tried to append to the read-only run folder.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
The scheduling update validates the target and priority class, then updates the live thread’s policy and priority under the registry lock. The scheduling getters and setters also hold that lock while reading or updating the pair: rtprio_thread changes, live-thread update, scheduling parameter access.
Not verified
Builds, tests, and console behavior were not independently verified. The description reports Windows build and test results, but those were not run during this review. Read:
core/libs/prx/libkernel/Pthread/Posix/Thread.cpp,core/libs/prx/libkernel/Pthread/include/Pthread.hpp,core/libs/prx/libkernel/Pthread/src/Thread.cpp(changed region and related locking context),core/libs/tests/GuestPthreadSchedparam.cpp,core/libs/tests/GuestRtprioThread.cpp, anddocs/dev/debt/changes/fix-libkernel-rtprio-thread-set-classes.md.files.jsonlists no excluded files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T06:58:40Z.
Review: COMMENTED
Actionable comments
1eb0b54b-8c03-411c-9c31-22213e1c8b31Reviewing files that changed from the base of the PR and between
992aa93f62anda3d7caa473.core/libs/prx/libkernel/Pthread/Posix/Thread.cppcore/libs/tests/GuestPthreadSchedparam.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:45:25Z.
Review: COMMENTED
The Linux guest_rtprio_thread and guest_pthread_schedparam CTests both passed with the patch. The cases cover setting the current thread by both forms of ID, setting priority from a read-only request record, preserving the caller’s error state, and restoring the prior priority.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T15:33:40Z.
Review: APPROVED
Re-checked
a3d7caa473, the commit added since my approval at992aa93f62, applied to main484b0368d3. Tested on Windows 11 with GCC 15.2.scePthreadGetschedparamandscePthreadSetschedparamnow read or write both policy and priority underLockLiveGuestThread, instead of going throughscePthreadGetprio/scePthreadSetprio. The behaviour on main is unchanged: a null thread still givesEINVALfrom set andESRCHfrom get, an ended thread givesESRCH, and the range check is already inAcceptsSchedParam.rtprio_threadnow looks up the calling thread throughGetLiveGuestThreadSched_nid_no_patchtoo. That is safe because everyPthreadPrivateregisters itself inCpuClocks().threadswhen it is constructed.guest_rtprio_threadandguest_pthread_schedparampass, including the new loop that checks a reader never sees a FIFO policy with the RR priority, or the reverse.AI-assisted: yes (Claude Code)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.