Skip to content

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

Closed
jagrat04 wants to merge 1 commit into
boykopovar:mainfrom
jagrat04:feat-libkernel-cpuset-affinity-errors
Closed

jagrat04 wants to merge 1 commit into
boykopovar:mainfrom
jagrat04:feat-libkernel-cpuset-affinity-errors

Conversation

@jagrat04

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown

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

@oneandonlydean

Copy link
Copy Markdown
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants