mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Update filterHints:
- Only append valid preferred-true hints to filtered - Return true if allResourceHints only consist of nil-affinity/preferred-true hints: {nil true}, update defaultHint preference accordingly.
This commit is contained in:
parent
9f21f49493
commit
17d615bca2
@ -100,23 +100,34 @@ func (p *singleNumaNodePolicy) getHintMatch(allResourcesHints [][]TopologyHint)
|
|||||||
return foundMatch, match
|
return foundMatch, match
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return hints that have valid bitmasks with exactly one bit set
|
// Return hints that have valid bitmasks with exactly one bit set. Also return bool
|
||||||
func (p *singleNumaNodePolicy) filterHints(allResourcesHints [][]TopologyHint) [][]TopologyHint {
|
// which indicates whether allResourceHints only consists of {nil true} hints.
|
||||||
|
func (p *singleNumaNodePolicy) filterHints(allResourcesHints [][]TopologyHint) ([][]TopologyHint, bool) {
|
||||||
var filteredResourcesHints [][]TopologyHint
|
var filteredResourcesHints [][]TopologyHint
|
||||||
|
var noAffinityPreferredHints int
|
||||||
|
var totalHints int
|
||||||
if len(allResourcesHints) > 0 {
|
if len(allResourcesHints) > 0 {
|
||||||
for _, oneResourceHints := range allResourcesHints {
|
for _, oneResourceHints := range allResourcesHints {
|
||||||
var filtered []TopologyHint
|
var filtered []TopologyHint
|
||||||
if len(oneResourceHints) > 0 {
|
if len(oneResourceHints) > 0 {
|
||||||
for _, hint := range oneResourceHints {
|
for _, hint := range oneResourceHints {
|
||||||
if hint.NUMANodeAffinity != nil && hint.NUMANodeAffinity.Count() == 1 {
|
totalHints++
|
||||||
|
if hint.NUMANodeAffinity != nil && hint.NUMANodeAffinity.Count() == 1 && hint.Preferred == true {
|
||||||
filtered = append(filtered, hint)
|
filtered = append(filtered, hint)
|
||||||
}
|
}
|
||||||
|
if hint.NUMANodeAffinity == nil && hint.Preferred == true {
|
||||||
|
noAffinityPreferredHints++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filteredResourcesHints = append(filteredResourcesHints, filtered)
|
filteredResourcesHints = append(filteredResourcesHints, filtered)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return filteredResourcesHints
|
// Check if all resource hints only consist of nil-affinity/preferred hint: {nil true}.
|
||||||
|
if noAffinityPreferredHints == totalHints {
|
||||||
|
return filteredResourcesHints, true
|
||||||
|
}
|
||||||
|
return filteredResourcesHints, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *singleNumaNodePolicy) mergeProvidersHints(providersHints []map[string][]TopologyHint) TopologyHint {
|
func (p *singleNumaNodePolicy) mergeProvidersHints(providersHints []map[string][]TopologyHint) TopologyHint {
|
||||||
@ -164,16 +175,25 @@ func (p *singleNumaNodePolicy) mergeProvidersHints(providersHints []map[string][
|
|||||||
return defaultHint
|
return defaultHint
|
||||||
}
|
}
|
||||||
|
|
||||||
allResourcesHints = p.filterHints(allResourcesHints)
|
var noAffinityPreferredOnly bool
|
||||||
// if no hints or there is a resource with empty hints after filtering, then policy cannot be satisfied
|
allResourcesHints, noAffinityPreferredOnly = p.filterHints(allResourcesHints)
|
||||||
|
// If no hints, then policy cannot be satisfied
|
||||||
if len(allResourcesHints) == 0 {
|
if len(allResourcesHints) == 0 {
|
||||||
klog.Infof("[topologymanager] No hints that align to a single NUMA node.")
|
klog.Infof("[topologymanager] No hints that align to a single NUMA node.")
|
||||||
return defaultHint
|
return defaultHint
|
||||||
}
|
}
|
||||||
|
// If there is a resource with empty hints after filtering, then policy cannot be satisfied.
|
||||||
|
// In the event that the only hints that exist are {nil true} update default hint preferred
|
||||||
|
// to allow scheduling.
|
||||||
for _, hints := range allResourcesHints {
|
for _, hints := range allResourcesHints {
|
||||||
if len(hints) == 0 {
|
if len(hints) == 0 {
|
||||||
klog.Infof("[topologymanager] No hints that align to a single NUMA node for resource.")
|
klog.Infof("[topologymanager] No hints that align to a single NUMA node for resource.")
|
||||||
|
if !noAffinityPreferredOnly {
|
||||||
return defaultHint
|
return defaultHint
|
||||||
|
} else if noAffinityPreferredOnly {
|
||||||
|
defaultHint.Preferred = true
|
||||||
|
return defaultHint
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user