Skip to content

Commit

Permalink
balloons: add support for picking efficient/performance cores
Browse files Browse the repository at this point in the history
This commit introduces a new field in the balloons configuration CR,
enabling users to specify their efficient/performance core preferences
for their workloads. When a user explicitly requests efficient or
performance cores, the policy will attempt to allocate according
to the user preferences. If the request cannot be satisfied, the
policy will fall back to other available cores  on the host.

If a user adds `preferIsolCpus` in addition to specifying coreTypes,
the policy will prioritize allocating isolated CPUs cores over the
preferred efficient/performance cores, in case these sets are different.

Signed-off-by: Feruzjon Muyassarov <[email protected]>
  • Loading branch information
fmuyassarov committed Aug 21, 2024
1 parent 46d22a6 commit 94410bd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cmd/plugins/balloons/policy/balloons-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import (
)

const (
highPrio = cpuallocator.PriorityHigh
lowPrio = cpuallocator.PriorityLow

// PolicyName is the name of this policy.
PolicyName = "balloons"
// PolicyDescription is a short description of this policy.
Expand All @@ -56,6 +59,12 @@ const (
// virtDevIsolatedCpus is the name of a virtual device close to
// host isolated CPUs.
virtDevIsolatedCpus = "isolated CPUs"
// virtDevECores is the name of a virtual device close to
// efficient E-cores.
virtDevECores = "efficient cores"
// virtDevPCores is the name of a virtual device close to
// performance P-cores.
virtDevPCores = "performance cores"
)

// balloons contains configuration and runtime attributes of the balloons policy
Expand Down Expand Up @@ -562,8 +571,14 @@ func (p *balloons) newBalloon(blnDef *BalloonDef, confCpus bool) (*Balloon, erro
virtDevCpusets: map[string][]cpuset.CPUSet{
virtDevReservedCpus: {p.reserved},
virtDevIsolatedCpus: {p.options.System.Isolated()},
virtDevECores: {p.cpuAllocator.GetCPUPriorities()[lowPrio]},
virtDevPCores: {p.cpuAllocator.GetCPUPriorities()[highPrio]},
},
}
log.Info("###########################################")
log.Info(p.cpuAllocator.GetCPUPriorities()[lowPrio].String())
log.Info(p.cpuAllocator.GetCPUPriorities()[highPrio].String())
log.Info("###########################################")
if blnDef.AllocatorTopologyBalancing != nil {
allocatorOptions.topologyBalancing = *blnDef.AllocatorTopologyBalancing
}
Expand Down Expand Up @@ -1202,6 +1217,12 @@ func (p *balloons) fillCloseToDevices(blnDefs []*BalloonDef) {
if blnDef.PreferIsolCpus {
blnDef.PreferCloseToDevices = append(blnDef.PreferCloseToDevices, virtDevIsolatedCpus)
}
if blnDef.CoreType == "performance" {
blnDef.PreferCloseToDevices = append(blnDef.PreferCloseToDevices, virtDevPCores)
}
if blnDef.CoreType == "efficient" {
blnDef.PreferCloseToDevices = append(blnDef.PreferCloseToDevices, virtDevECores)
}
}
}

Expand All @@ -1221,6 +1242,12 @@ func (p *balloons) fillFarFromDevices(blnDefs []*BalloonDef) {
avoidDevs = append(avoidDevs, virtDevIsolatedCpus)
}
for _, blnDef := range blnDefs {
if blnDef.CoreType == "efficient" {
avoidDevs = append(avoidDevs, virtDevECores)
}
if blnDef.CoreType == "performance" {
avoidDevs = append(avoidDevs, virtDevPCores)
}
for _, closeDev := range blnDef.PreferCloseToDevices {
if _, ok := devDefClose[closeDev]; !ok {
avoidDevs = append(avoidDevs, closeDev)
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/config.nri_balloonspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ spec:
AllocatorTopologyBalancing is the balloon type specific
parameter of the policy level parameter with the same name.
type: boolean
coreType:
description: 'coreType: Accepts either performance or efficienct'
enum:
- efficient
- performance
type: string
cpuClass:
description: |-
CpuClass controls how CPUs of a balloon are (re)configured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ spec:
AllocatorTopologyBalancing is the balloon type specific
parameter of the policy level parameter with the same name.
type: boolean
coreType:
description: 'coreType: Accepts either performance or efficienct'
enum:
- efficient
- performance
type: string
cpuClass:
description: |-
CpuClass controls how CPUs of a balloon are (re)configured
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ type BalloonDef struct {
// preferIsolCpus: prefer kernel isolated cpus
// +kubebuilder:default:=false
PreferIsolCpus bool `json:"preferIsolCpus,omitempty"`
// coreType: Accepts either performance or efficienct
// +optional
// +kubebuilder:validation:Enum:=efficient;performance
CoreType string `json:"coreType,omitempty"`
}

// String stringifies a BalloonDef
Expand Down

0 comments on commit 94410bd

Please sign in to comment.