Skip to content

chcpu: refactor#4396

Open
cgoesche wants to merge 9 commits into
util-linux:masterfrom
cgoesche:refactor_chcpu
Open

chcpu: refactor#4396
cgoesche wants to merge 9 commits into
util-linux:masterfrom
cgoesche:refactor_chcpu

Conversation

@cgoesche

@cgoesche cgoesche commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

This is a temporary copy of my chcpu_tests branch which saved the refactor work and bug fixes that were initially added to PR #4390 . However, as suggested by @karelzak it is better to keep it simple and introduce these fixes in another iteration. Once the initial PR is merged, this branch will be rebased and commits will be adjusted accordingly to properly implement the changes.

@cgoesche cgoesche marked this pull request as draft June 2, 2026 11:59
@cgoesche cgoesche force-pushed the refactor_chcpu branch 2 times, most recently from 866dbde to 860ac42 Compare June 11, 2026 22:17
cgoesche added 9 commits June 11, 2026 18:18
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Previously, cpu_enable() and cpu_configure() compared the number
of fails with ctx->maxcpus and if equal it returned -1, which
culminated over to an exit code of 1 (failure). Otherwise, if
there were fails but less than ctx->maxcpus the fucntions return
code 1 would result in an exit code 64 indicating partial success.

Since ctx->maxcpus describes the maximum number of CPUs supported
by the kernel, in practice, this failure mode isn't really useful
as it means that a user would need to fail the configuration of
every possible CPU. This is why chcpu(8) almost always returns 64.

It is better to store the actual amount of requested CPUs and then
compare the amount of fails to it and provide more meaningful exit
codes.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Let's stay consistent with the function contract and return -1 and
print a warning with warn[x]() in case of failure.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
@cgoesche cgoesche marked this pull request as ready for review June 11, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant