@@ -364,24 +364,18 @@ func (p *staticPolicy) GetTopologyHints(s state.State, pod *v1.Pod, container *v
364
364
func (p * staticPolicy ) generateCPUTopologyHints (availableCPUs cpuset.CPUSet , reusableCPUs cpuset.CPUSet , request int ) []topologymanager.TopologyHint {
365
365
// Initialize minAffinitySize to include all NUMA Nodes.
366
366
minAffinitySize := p .topology .CPUDetails .NUMANodes ().Size ()
367
- // Initialize minSocketsOnMinAffinity to include all Sockets.
368
- minSocketsOnMinAffinity := p .topology .CPUDetails .Sockets ().Size ()
369
367
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.
371
369
hints := []topologymanager.TopologyHint {}
372
370
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.
375
372
cpusInMask := p .topology .CPUDetails .CPUsInNUMANodes (mask .GetBits ()... ).Size ()
376
- socketsInMask := p .topology .CPUDetails .SocketsInNUMANodes (mask .GetBits ()... ).Size ()
377
373
if cpusInMask >= request && mask .Count () < minAffinitySize {
378
374
minAffinitySize = mask .Count ()
379
- if socketsInMask < minSocketsOnMinAffinity {
380
- minSocketsOnMinAffinity = socketsInMask
381
- }
382
375
}
383
376
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.
385
379
numMatching := 0
386
380
for _ , c := range reusableCPUs .ToSlice () {
387
381
// Disregard this mask if its NUMANode isn't part of it.
@@ -404,7 +398,7 @@ func (p *staticPolicy) generateCPUTopologyHints(availableCPUs cpuset.CPUSet, reu
404
398
return
405
399
}
406
400
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
408
402
// list of hints. We set all hint preferences to 'false' on the first
409
403
// pass through.
410
404
hints = append (hints , topologymanager.TopologyHint {
@@ -416,14 +410,10 @@ func (p *staticPolicy) generateCPUTopologyHints(availableCPUs cpuset.CPUSet, reu
416
410
// Loop back through all hints and update the 'Preferred' field based on
417
411
// counting the number of bits sets in the affinity mask and comparing it
418
412
// 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.
420
414
for i := range hints {
421
415
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
427
417
}
428
418
}
429
419
0 commit comments