From c8559bc43e507d7f7759c7b53ea12ae70c017fa0 Mon Sep 17 00:00:00 2001 From: Kevin Klues Date: Wed, 24 Nov 2021 14:10:50 +0000 Subject: [PATCH] Short-circuit CPUManager distribute NUMA algo for unusable cpuGroupSize Signed-off-by: Kevin Klues --- pkg/kubelet/cm/cpumanager/cpu_assignment.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/kubelet/cm/cpumanager/cpu_assignment.go b/pkg/kubelet/cm/cpumanager/cpu_assignment.go index 696bafca8dd..0d24ad1c1a8 100644 --- a/pkg/kubelet/cm/cpumanager/cpu_assignment.go +++ b/pkg/kubelet/cm/cpumanager/cpu_assignment.go @@ -534,6 +534,14 @@ func takeByTopologyNUMAPacked(topo *topology.CPUTopology, availableCPUs cpuset.C // important, for example, to ensure that all CPUs (i.e. all hyperthreads) from // a single core are allocated together. func takeByTopologyNUMADistributed(topo *topology.CPUTopology, availableCPUs cpuset.CPUSet, numCPUs int, cpuGroupSize int) (cpuset.CPUSet, error) { + // If the number of CPUs requested cannot be handed out in chunks of + // 'cpuGroupSize', then we just call out the packing algorithm since we + // can't distribute CPUs in this chunk size. + if (numCPUs % cpuGroupSize) != 0 { + return takeByTopologyNUMAPacked(topo, availableCPUs, numCPUs) + } + + // Otherwise build an accumulator to start allocating CPUs from. acc := newCPUAccumulator(topo, availableCPUs, numCPUs) if acc.isSatisfied() { return acc.result, nil