feat(libkernel): return ESRCH and EINVAL for unsupported cpuset affinity targets #4168

Closed
jagrat04 wants to merge 1 commit from upstream-pr/4168 into main
jagrat04 commented 2026-10-12 00:25:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-10-12T00:25:57Z.


What

Handle invalid targets and unsupported scopes in cpuset_getaffinity and cpuset_setaffinity in libkernel:

  • When level is not CPU_LEVEL_WHICH (3) or which is not CPU_WHICH_TID (1) / CPU_WHICH_PID (2), return EINVAL (22) instead of throwing NotImplemented_nid_no_patch.
  • When which is CPU_WHICH_TID, allow the caller to pass its own thread ID (self->tid) in addition to -1. If id does not match the calling thread, return ESRCH (3) instead of throwing.
  • When which is CPU_WHICH_PID, if id is not -1 and not getpid(), return ESRCH (3) instead of throwing.
  • Add test coverage in core/libs/tests/GuestAvailableCpumask.cpp.
  • Document behavior in docs/dev/TechnicalDebt.md.

Tested

  • python tools/check_conventions.py --base origin/main passed with 0 violations.
  • Verified zero comments in C++ implementation files.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4823499590 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4168). Originally posted by [jagrat04](https://github.com/jagrat04) on 2026-10-12T00:25:57Z. --- ### What Handle invalid targets and unsupported scopes in `cpuset_getaffinity` and `cpuset_setaffinity` in `libkernel`: - When `level` is not `CPU_LEVEL_WHICH` (3) or `which` is not `CPU_WHICH_TID` (1) / `CPU_WHICH_PID` (2), return `EINVAL` (22) instead of throwing `NotImplemented_nid_no_patch`. - When `which` is `CPU_WHICH_TID`, allow the caller to pass its own thread ID (`self->tid`) in addition to `-1`. If `id` does not match the calling thread, return `ESRCH` (3) instead of throwing. - When `which` is `CPU_WHICH_PID`, if `id` is not `-1` and not `getpid()`, return `ESRCH` (3) instead of throwing. - Add test coverage in `core/libs/tests/GuestAvailableCpumask.cpp`. - Document behavior in `docs/dev/TechnicalDebt.md`. ### Tested - `python tools/check_conventions.py --base origin/main` passed with 0 violations. - Verified zero comments in C++ implementation files. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-12 00:29:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T00:29:41Z.


Progress report (bca7a29 → a225789)

📈 System libraries: 86.53% (+0.06%, +2 implemented functions)

✅ 2 implemented
Library Name
libkernel cpuset_getaffinity_nid_postfix
libkernel cpuset_setaffinity_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115614414 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4168#issuecomment-6115614414). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T00:29:41Z. --- <!-- progress-report --> ### Progress report (bca7a29 → a225789) 📈 **System libraries**: 86.53% (+0.06%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libkernel | `cpuset_getaffinity_nid_postfix` | | libkernel | `cpuset_setaffinity_nid_postfix` | </details>
oneandonlydean commented 2026-10-12 08:28:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T08:28:34Z.


Closing: no title is shown to reach these paths, and cpuset_getaffinity/cpuset_setaffinity now answer ESRCH for the id of any other thread, live ones included, where main throws because other threads aren't handled. Reopen with the title ID and the log line where it stops on main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120583941 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4168#issuecomment-6120583941). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T08:28:34Z. --- Closing: no title is shown to reach these paths, and `cpuset_getaffinity`/`cpuset_setaffinity` now answer `ESRCH` for the id of any other thread, live ones included, where main throws because other threads aren't handled. Reopen with the title ID and the log line where it stops on main.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4168
No description provided.