in pkg/noderesourcetopology/filter.go [104:142]
func resMatchNUMANodes(nodes NUMANodeList, resources v1.ResourceList, qos v1.PodQOSClass) bool {
bitmask := bm.NewEmptyBitMask()
// set all bits, each bit is a NUMA node, if resources couldn't be aligned
// on the NUMA node, bit should be unset
bitmask.Fill()
zeroQuantity := resource.MustParse("0")
for resource, quantity := range resources {
// for each requested resource, calculate which NUMA slots are good fits, and then AND with the aggregated bitmask, IOW unset appropriate bit if we can't align resources, or set it
// obvious, bits which are not in the NUMA id's range would be unset
resourceBitmask := bm.NewEmptyBitMask()
for _, numaNode := range nodes {
numaQuantity, ok := numaNode.Resources[resource]
// if can't find requested resource on the node - skip (don't set it as available NUMA node)
// if unfound resource has 0 quantity probably this numa node can be considered
if !ok && quantity.Cmp(zeroQuantity) != 0 {
continue
}
// Check for the following:
// 1. set numa node as possible node if resource is memory or Hugepages
// 2. set numa node as possible node if resource is cpu and it's not guaranteed QoS, since cpu will flow
// 3. set numa node as possible node if zero quantity for non existing resource was requested
// 4. otherwise check amount of resources
if resource == v1.ResourceMemory ||
strings.HasPrefix(string(resource), v1.ResourceHugePagesPrefix) ||
resource == v1.ResourceCPU && qos != v1.PodQOSGuaranteed ||
quantity.Cmp(zeroQuantity) == 0 ||
numaQuantity.Cmp(quantity) >= 0 {
// possible to align resources on NUMA node
resourceBitmask.Add(numaNode.NUMAID)
}
}
bitmask.And(resourceBitmask)
if bitmask.IsEmpty() {
return true
}
}
return bitmask.IsEmpty()
}