kubernetes/pkg
Francesco Romani 0e9b92090c node: cpumgr: stricter precheck for full-pcpus-only
In order to implement the `full-pcpus-only` cpumanager policy option,
we leverage the implementation of the algorithm which picks CPUs.
By design, CPUs are taken from the biggest chunk available (socket
or NUMA zone) to physical cores, down to single cores.

Leveraging this, if the requested CPU count is a multiple of the SMT
level (commonly 2), we're guaranteed that only full physical cores
will be taken.

The hidden assumption here is this holds true by construction iff
the user reserved CPUs (if any) considering full physical CPUs.
IOW, if the user did intentionally or mistakely reserve single threads
which are no core siblings[1], then the simple check we implemented
is not sufficient.

A easy example can probably outline this better. With this setup:

cores: [(0, 4), (1, 5), (2, 6), (3, 8)] (in parens: thread siblings).
SMT level: 2 (each tuple is 2 elements)
Reserved CPUs: 0,1 (explicit pick using `--reserved-cpus`)

A container then requests 6 cpus. full-pcpus-only check: 6 % 2 == 0. Passed.
The CPU allocator will take first full cores, (2,6) and (3,8), and will
then pick the remaining single CPUs. The allocation will succeed, but
it's incorrect.

We can fix this case with a stricter precheck.
We need to additionally consider all the core siblings of the reserved
CPUs as unavailable when computing the free cpus, before to start the
actual allocation. Doing so, we fall back in the intended behavior, and
by construction all possible CPUs allocation whose number is multiple
of the SMT level are now correct again.

+++

[1] or thread siblings in the linux parlance, in any case:
hyperthread siblings of the same physical core

Signed-off-by: Francesco Romani <fromani@redhat.com>
2023-03-02 16:00:58 +01:00
..
api Merge pull request #115035 from xing-yang/update_plugin_warning 2023-01-13 12:08:26 -08:00
apis Merge pull request #114492 from SataQiu/update-prefered-storageversion-20221215 2023-01-13 08:42:24 -08:00
auth
capabilities
client delete unused functions in pkg directory 2023-01-16 21:43:36 +08:00
cloudprovider Remove OpenStack cloud provider 2022-11-11 12:04:55 +01:00
cluster/ports e2e_node/{service,util}: use kubelet healthz port. 2022-04-22 16:14:31 -07:00
controller Merge pull request #115074 from yangjunmyfm192085/deleteklogv0-controller 2023-01-16 09:58:50 -08:00
controlplane apiserver: update serialization version priority for flowcontrol API 2023-01-13 22:19:39 +08:00
credentialprovider delete unused functions in pkg directory 2023-01-16 21:43:36 +08:00
features Prevent CSIMigrationAzureFile gate from being disabled 2023-01-10 09:43:35 -05:00
fieldpath Fix quotes that trip up gofmt 2022-07-26 13:14:04 -04:00
generated Merge pull request #114393 from danielvegamyhre/myfeature 2023-01-13 17:28:15 -08:00
kubeapiserver remove psp in extensions api/apis 2023-01-06 17:07:02 +08:00
kubectl Refactor to simplify factory Validator 2022-12-11 18:20:28 -08:00
kubelet node: cpumgr: stricter precheck for full-pcpus-only 2023-03-02 16:00:58 +01:00
kubemark Merge pull request #114725 from danwinship/kube-proxy-startup-cleanup 2023-01-05 13:57:59 -08:00
printers kubectl: remove psp support 2023-01-06 17:07:02 +08:00
probe Fix indentation/spacing in comments to render correctly in godoc 2022-12-17 23:27:38 -05:00
proxy Merge pull request #114724 from tnqn/fix-lb-svc-delete-error 2023-01-11 10:31:45 -08:00
quota/v1 Use https links for k8s KEPs, issues, PRs, etc 2022-09-23 23:36:24 +00:00
registry delete unused functions in pkg directory 2023-01-16 21:43:36 +08:00
routes unittests: Fixes unit tests for Windows (part 3) 2022-10-21 19:25:48 +03:00
scheduler Merge pull request #114897 from kidddddddddddddddddddddd/volumebinding 2023-01-16 23:38:32 -08:00
security delete unused functions in pkg directory 2023-01-16 21:43:36 +08:00
securitycontext delete unused functions in pkg directory 2023-01-16 21:43:36 +08:00
serviceaccount Merge pull request #111908 from dengyufeng2206/new-test0818 2022-11-08 13:51:20 -08:00
util delete unused functions in pkg/util directory 2023-01-16 17:22:35 +08:00
volume delete unused functions in pkg/volume directory 2023-01-16 21:19:11 +08:00
windows/service
.import-restrictions
OWNERS Move root approvers to subdirs 2022-10-10 13:43:03 -04:00