feat(libkernel): implement CPU_LEVEL_ROOT and CPU_LEVEL_CPUSET cpuset affinity #19612
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19612"
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 Mohabbadi11 on 2026-11-13T16:00:59Z.
What
Support CPU_LEVEL_ROOT and CPU_LEVEL_CPUSET hierarchy levels in cpuset_getaffinity and cpuset_setaffinity following FreeBSD 11.4 semantics:
Tested
Ran GuestAvailableCpumask test suite verifying:
Checklist
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T21:25:40Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
a9b37605d5:tools/check_conventions.pypassed;git diff --checkclean.guest_available_cpumask_testsbuilt cleanly.guest_available_cpumask):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 MarcZX10 on 2026-11-17T08:40:57Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
PR #19612 (
feat(libkernel): implement CPU_LEVEL_ROOT and CPU_LEVEL_CPUSET cpuset affinity) at heada9b37605d595927b0f550bcd8576b39645282790, basemain.What I ran
diff.patchfrom the review folder.repo_read.py searchto find the callers of the helpers whose signatures changed (SetLiveGuestThreadAffinity_nid_no_patch,SetLiveGuestThreadsAffinity,SetLiveGuestProcessCpuset,LockRegisteredGuestThread). No caller was left on the oldboolorvoidcontract.core/libs/prx/libkernel/Pthread/src/Thread.cpplines 589–616 at head, the constructor that clamps the thread affinity and registers the thread.Results
GuestAvailableCpumasktestsFindings
Blocking
None.
Non-blocking
The description overstates restoration. The description says explicit thread affinities are "preserved when the process cpuset expands". The code only narrows them:
core/libs/prx/libkernel/Pthread/src/Thread.cpp:686storesthread->affinity & maskand never widens an explicit thread again. The test atcore/libs/tests/GuestAvailableCpumask.cpp:342asserts that a pinned thread stays at its narrowed mask after the cpuset is restored. The behaviour is consistent with the test. Only the wording is off. "Not widened by a later expansion" would match the code.The TOCTOU claim holds for thread creation. The constructor clamps the affinity and registers the thread under the same
registry.lock(Thread.cpp:591andThread.cpp:615), so the description's claim that creation is atomic is correct for that path. Thestd::invalid_argumentit throws is caught inscePthreadCreate. The adopted-thread callers use the default constructor and cannot reach that throw.Not verified
GuestAvailableCpumasksuite, including the concurrency stress test. I only read the test code.pthread_setaffinity_nppath incore/libs/prx/libkernel/Pthread/Posix/Thread.cpp. It is not in the diff, and I did not trace how it reaches the cpuset setter.files/were not read.settled()check. I reasoned about it from the code and did not run it.Files read: all five in
files.jsonreviewed(diff hunks), plus head context forThread.cpp. Files excluded by rule: none.To get this to a good state
Nothing is required. Optional: reword the description as in finding 1.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T03:59:16Z.
Review: APPROVED
Reviewed — looks good
The reviewed change has no verified blocking defects; the source and added test cases support the stated affinity behavior, though the reported test and conventions runs were not independently run here.
What I ran
Reviewed head
2e23eb772398889bd919905c444d85288548c820. Read the prepared description, commit summary, manifest, diff, and all five changed files; targeted source context was read through the pinned reader. No tests or build commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The GuestAvailableCpumask suite and conventions check were not run during this review. Console behavior and the claims based on physical console measurements were not independently confirmed. The description’s test claims are author-reported.
files.jsonwas not present in the review bundle; the reader’s file listing shows all five changed files as included, and each was read. No files were excluded from the manifest.To get this to a good state
Nothing is required.