feat(libkernel_sys): implement cpuset, cpuset_getid and cpuset_setid #10741
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10741"
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 camezaro-intc on 2026-10-24T20:25:07Z.
What
Implement
cpuset,cpuset_getidandcpuset_setidinlibkernel_sysfollowing FreeBSD 11.4kern_cpuset.c:cpuset: allocates a sequential CPU set ID from 2 upwards, assigns the process to it, and stores the ID.cpuset_setid: supportsCPU_WHICH_PIDto assign known set IDs (or root 0 and default 1) to the calling process.cpuset_getid: implementsCPU_WHICH_PID: returns root 0 forCPU_LEVEL_ROOTand the assigned set ID forCPU_LEVEL_CPUSET. Invalid levels orwhichspecifiers (IRQ,DOMAIN) and non-cpusetCPU_LEVEL_WHICHfail withEINVAL; unknown process IDs fail withESRCH; out-of-range set IDs fail withESRCHwithout integer wrapping; null pointers fail withEFAULT. Unmodeled scopes (CPU_WHICH_TID,CPU_WHICH_CPUSET,CPU_WHICH_JAIL) throwNotImplemented_nid_no_patch.Export.Discovery.cpp, registers unit tests incore/libs/tests/GuestKernelSysCpuset.cpp, and records technical debt indocs/dev/debt/libkernel_sys.md.Tested
Windows 11 (AMD Ryzen 5 3600X, MinGW-w64 GCC 15.2.0):
guest_kernel_sys_cpusetunit test suite passes 100% exercisingcpuset, process-levelcpuset_getid(valid transitions, root/cpuset levels, error conditions, out-of-range IDs), andcpuset_setid(valid transitions, invalid which, non-existent PID, invalid set IDs).python tools/check_conventions.py --base upstream/mainpasses with zero errors and zero warnings.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 MarcZX10 on 2026-10-24T20:25:57Z.
Review: CHANGES_REQUESTED
Reviewed exact head
2e875b85062935f7af7b2322eb1779750b8ad75e. The new tests cover normal set creation, process/thread lookups, invalid levels and set IDs, and the reported Windows focused suite passes. I found one correctness gap incpuset_getid_nid_postfix: forwhich == WhichCpuset, it converts the 64-bitidtointbefore checking membership. Values outside theintrange can wrap to an existing ID; for example, on the usual 32-bitint,id == 4294967296becomes 0 and can report the root set successfully instead ofESRCH. Please reject IDs that cannot be represented by the guest cpuset ID type before the cast, and add a regression asserting that an out-of-range ID fails without changing the output. I am requesting changes for this malformed-ID behavior. Hosted eligibility, conventions, intake and labels pass; product build jobs were skipped, and I could not run the focused test locally because this checkout has no configured build directory.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:35:18Z.
Review: APPROVED
Reviewed updated head
82b0d7d1b9e3e69c7fd299a9f3bee5317d7214de. The new representability check runs before theintcast forWhichCpuset, and the regression cases cover positive and negative out-of-range IDs while asserting that*setidremains untouched for all three levels. The author reports the focused Windowsguest_kernel_sys_cpusetsuite and conventions check passing. I did not run the C++ test locally; the hosted workflow skipped product test jobs, so that result remains author-reported. The exact-head conventions, intake, eligibility, and labels checks pass.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T00:09:18Z.
Review: CHANGES_REQUESTED
The process-level model is internally consistent for the tested paths, but
cpuset_getidreports support forCPU_WHICH_TIDandCPU_WHICH_CPUSETthat the existing affinity implementation does not currently provide. For TIDs, it callscpuset_getaffinity_nid_postfix(LevelWhich, WhichThread, ...); that function can resolve a live guest thread, but this PR still returnscurrentProcessSetIdfor every TID instead of tracking each thread’s assigned cpuset.cpuset()andcpuset_setid(CPU_WHICH_PID, ...)update only the process-wide ID, so an existing thread-specific model/affinity change can make the result incorrect. For CPUSET lookups, newly allocated set IDs are global here, while FreeBSD resolves them relative to the caller’s visible set namespace; the current test expects querying set1 while joined to set2 to succeed, which may not match the 11.4 reference. Please either limit claims/behavior to the process-level operations modeled here or add per-thread assignment and verify CPUSET visibility andCPU_LEVEL_ROOTsemantics against the target/reference. I inspected the tests and FreeBSD 11.4 kernel code; I could not run the Windows-only target locally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T02:52:05Z.
Review: DISMISSED
Reviewed updated head
9c34140bd3bfcb5d19602fb5548445fc7724698d. The implementation and debt entry now limitcpuset_getidtoCPU_WHICH_PID, and the new tests expect the other scopes to throw. However, the PR description still claimsCPU_LEVEL_CPUSETsupportsCPU_WHICH_TIDandCPU_WHICH_CPUSET, andCPU_LEVEL_WHICHsupportsCPU_WHICH_CPUSET; its Tested section likewise says the suite exercises all scopes and set lookups. InCpuset.cpp, those requests reachif (which != WhichProcess) NotImplemented_nid_no_patch(...), so those claims are false for this head. Please align the What and Tested sections with the intentionally process-only behavior. The earlier representability fix is present in the code and tests. This branch is currently DIRTY against main, so it will also need to be made mergeable before landing; I did not rebase another contributor’s branch.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:15:56Z.
Review: COMMENTED
Re-reviewed the rebased head
ea3de34867ec76bf3080437e0bbd0efc154a13c5. The description now matches the implementation’s process-only scope, the out-of-range ID check and tests remain present, and the branch is clean againstmain. Hosted conventions, eligibility, and labels pass; product builds/tests are skipped by the PR workflow, and I did not rerun the Windows-only focused suite locally. No further issue found in this update. I am withdrawing my prior change request.