From 446c58e0e7b887b85d24ba50648d1b705810b005 Mon Sep 17 00:00:00 2001 From: Kevin Klues Date: Wed, 24 Nov 2021 00:17:31 +0000 Subject: [PATCH] Ensure we balance across *all* NUMA nodes in NUMA distribution algo Signed-off-by: Kevin Klues --- pkg/kubelet/cm/cpumanager/cpu_assignment.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkg/kubelet/cm/cpumanager/cpu_assignment.go b/pkg/kubelet/cm/cpumanager/cpu_assignment.go index 0d24ad1c1a8..2f8299c211f 100644 --- a/pkg/kubelet/cm/cpumanager/cpu_assignment.go +++ b/pkg/kubelet/cm/cpumanager/cpu_assignment.go @@ -605,13 +605,16 @@ func takeByTopologyNUMADistributed(topo *topology.CPUTopology, availableCPUs cpu } // Calculate how many CPUs will be available on each NUMA node in - // 'combo' after allocating an even distribution of CPU groups of - // size 'cpuGroupSize' from them. This will be used in the "balance - // score" calculation to help decide if this combo should - // ultimately be chosen. - availableAfterAllocation := make(mapIntInt, len(combo)) + // the system after allocating an even distribution of CPU groups + // of size 'cpuGroupSize' from each NUMA node in 'combo'. This will + // be used in the "balance score" calculation to help decide if + // this combo should ultimately be chosen. + availableAfterAllocation := make(mapIntInt, len(numas)) + for _, numa := range numas { + availableAfterAllocation[numa] = acc.details.CPUsInNUMANodes(numa).Size() + } for _, numa := range combo { - availableAfterAllocation[numa] = acc.details.CPUsInNUMANodes(numa).Size() - distribution + availableAfterAllocation[numa] -= distribution } // Check if there are any remaining CPUs to distribute across the @@ -648,7 +651,7 @@ func takeByTopologyNUMADistributed(topo *topology.CPUTopology, availableCPUs cpu } // Calculate the "balance score" as the standard deviation of - // the number of CPUs available on all NUMA nodes in 'combo' + // the number of CPUs available on all NUMA nodes in the system // after the remainder CPUs have been allocated across 'subset' // in groups of size 'cpuGroupSize'. balance := standardDeviation(availableAfterAllocation.Values())