Skip to content

Commit e33ba9e

Browse files
Avoid using socket for hints
Sockets don't affect performance as NUMA node does, since NUMA node has dedicated memory controller, but socket it's physical extension point. Socket it's only cpu specific thing and it's strange to merge bitmask of deviceplugin's and cpu manager, when cpu manager takes into account socket. Signed-off-by: Alexey Perevalov <[email protected]>
1 parent ff33efc commit e33ba9e

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

pkg/kubelet/cm/cpumanager/policy_static.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -364,24 +364,18 @@ func (p *staticPolicy) GetTopologyHints(s state.State, pod *v1.Pod, container *v
364364
func (p *staticPolicy) generateCPUTopologyHints(availableCPUs cpuset.CPUSet, reusableCPUs cpuset.CPUSet, request int) []topologymanager.TopologyHint {
365365
// Initialize minAffinitySize to include all NUMA Nodes.
366366
minAffinitySize := p.topology.CPUDetails.NUMANodes().Size()
367-
// Initialize minSocketsOnMinAffinity to include all Sockets.
368-
minSocketsOnMinAffinity := p.topology.CPUDetails.Sockets().Size()
369367

370-
// Iterate through all combinations of socket bitmask and build hints from them.
368+
// Iterate through all combinations of numa nodes bitmask and build hints from them.
371369
hints := []topologymanager.TopologyHint{}
372370
bitmask.IterateBitMasks(p.topology.CPUDetails.NUMANodes().ToSlice(), func(mask bitmask.BitMask) {
373-
// First, update minAffinitySize and minSocketsOnMinAffinity for the
374-
// current request size.
371+
// First, update minAffinitySize for the current request size.
375372
cpusInMask := p.topology.CPUDetails.CPUsInNUMANodes(mask.GetBits()...).Size()
376-
socketsInMask := p.topology.CPUDetails.SocketsInNUMANodes(mask.GetBits()...).Size()
377373
if cpusInMask >= request && mask.Count() < minAffinitySize {
378374
minAffinitySize = mask.Count()
379-
if socketsInMask < minSocketsOnMinAffinity {
380-
minSocketsOnMinAffinity = socketsInMask
381-
}
382375
}
383376

384-
// Then check to see if all of the reusable CPUs are part of the bitmask.
377+
// Then check to see if we have enough CPUs available on the current
378+
// numa node bitmask to satisfy the CPU request.
385379
numMatching := 0
386380
for _, c := range reusableCPUs.ToSlice() {
387381
// Disregard this mask if its NUMANode isn't part of it.
@@ -404,7 +398,7 @@ func (p *staticPolicy) generateCPUTopologyHints(availableCPUs cpuset.CPUSet, reu
404398
return
405399
}
406400

407-
// Otherwise, create a new hint from the socket bitmask and add it to the
401+
// Otherwise, create a new hint from the numa node bitmask and add it to the
408402
// list of hints. We set all hint preferences to 'false' on the first
409403
// pass through.
410404
hints = append(hints, topologymanager.TopologyHint{
@@ -416,14 +410,10 @@ func (p *staticPolicy) generateCPUTopologyHints(availableCPUs cpuset.CPUSet, reu
416410
// Loop back through all hints and update the 'Preferred' field based on
417411
// counting the number of bits sets in the affinity mask and comparing it
418412
// to the minAffinitySize. Only those with an equal number of bits set (and
419-
// with a minimal set of sockets) will be considered preferred.
413+
// with a minimal set of numa nodes) will be considered preferred.
420414
for i := range hints {
421415
if hints[i].NUMANodeAffinity.Count() == minAffinitySize {
422-
nodes := hints[i].NUMANodeAffinity.GetBits()
423-
numSockets := p.topology.CPUDetails.SocketsInNUMANodes(nodes...).Size()
424-
if numSockets == minSocketsOnMinAffinity {
425-
hints[i].Preferred = true
426-
}
416+
hints[i].Preferred = true
427417
}
428418
}
429419

0 commit comments

Comments
 (0)