Skip to content

Commit

Permalink
cpuallocator: allow querying CPU priorities.
Browse files Browse the repository at this point in the history
Allow querying cpusets for all discovered priorities. This is
useful and necessary for policies which pass pre-filtered CPU
sets to the allocator, to ensure that pre-filtering and the
allocator logic has a mutual understanding of which CPU cores
belong to what priority class.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
  • Loading branch information
klihub committed Mar 14, 2024
1 parent cb94607 commit ecb4ced
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/cpuallocator/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type allocatorHelper struct {
type CPUAllocator interface {
AllocateCpus(from *cpuset.CPUSet, cnt int, prefer CPUPriority) (cpuset.CPUSet, error)
ReleaseCpus(from *cpuset.CPUSet, cnt int, prefer CPUPriority) (cpuset.CPUSet, error)
GetCPUPriorities() map[CPUPriority]cpuset.CPUSet
}

type CPUPriority int
Expand Down Expand Up @@ -670,6 +671,16 @@ func (ca *cpuAllocator) ReleaseCpus(from *cpuset.CPUSet, cnt int, prefer CPUPrio
return result, err
}

// GetCPUPriorities returns the CPUSets for the discovered priorities.
func (ca *cpuAllocator) GetCPUPriorities() map[CPUPriority]cpuset.CPUSet {
prios := make(map[CPUPriority]cpuset.CPUSet)
for prio := CPUPriority(0); prio < NumCPUPriorities; prio++ {
cset := ca.topologyCache.cpuPriorities[prio]
prios[prio] = cset.Clone()
}
return prios
}

func newTopologyCache(sys sysfs.System) topologyCache {
c := topologyCache{
pkg: make(map[idset.ID]cpuset.CPUSet),
Expand Down

0 comments on commit ecb4ced

Please sign in to comment.