From b86eb19d309386162ed1b1c220e19053de566025 Mon Sep 17 00:00:00 2001 From: Charles Wong Date: Tue, 5 Nov 2024 13:41:02 -0600 Subject: [PATCH] update comments --- pkg/kubelet/cm/cpumanager/cpu_assignment.go | 6 ++++-- pkg/kubelet/cm/cpumanager/topology/topology.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/kubelet/cm/cpumanager/cpu_assignment.go b/pkg/kubelet/cm/cpumanager/cpu_assignment.go index 18025095502..b4abf37124f 100644 --- a/pkg/kubelet/cm/cpumanager/cpu_assignment.go +++ b/pkg/kubelet/cm/cpumanager/cpu_assignment.go @@ -561,11 +561,12 @@ func (a *cpuAccumulator) takeFullUncore() { func (a *cpuAccumulator) takePartialUncore(uncoreID int) { numCoresNeeded := a.numCPUsNeeded / a.topo.CPUsPerCore() - // note: we need to keep the first N free cores (physical cpus) and only we we got these expand to their - // cpus (virtual cpus). Taking directly the first M cpus (virtual cpus) leads to suboptimal allocation + // determine the N number of free cores (physical cpus) within the UncoreCache, then + // determine the M number of free cpus (virtual cpus) that correspond with the free cores freeCores := a.details.CoresNeededInUncoreCache(numCoresNeeded, uncoreID) freeCPUs := a.details.CPUsInCores(freeCores.UnsortedList()...) + // claim the cpus if the free cpus within the UncoreCache can satisfy the needed cpus claimed := (a.numCPUsNeeded == freeCPUs.Size()) klog.V(4).InfoS("takePartialUncore: trying to claim partial uncore", "uncore", uncoreID, @@ -594,6 +595,7 @@ func (a *cpuAccumulator) takeUncoreCache() { return } + // take partial UncoreCache if the CPUs needed is less than free UncoreCache size a.takePartialUncore(uncore) if a.isSatisfied() { return diff --git a/pkg/kubelet/cm/cpumanager/topology/topology.go b/pkg/kubelet/cm/cpumanager/topology/topology.go index 1de03c8fd9c..18b38233666 100644 --- a/pkg/kubelet/cm/cpumanager/topology/topology.go +++ b/pkg/kubelet/cm/cpumanager/topology/topology.go @@ -101,7 +101,7 @@ func (topo *CPUTopology) CPUNUMANodeID(cpu int) (int, error) { return info.NUMANodeID, nil } -// CPUInfo contains the NUMA, socket, unCoreCache and core IDs associated with a CPU. +// CPUInfo contains the NUMA, socket, UncoreCache and core IDs associated with a CPU. type CPUInfo struct { NUMANodeID int SocketID int