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 Sep 2, 2024
1 parent 46d22a6 commit f295f33
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/plugins/balloons/policy/balloons-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const (
PolicyName = "balloons"
// PolicyDescription is a short description of this policy.
PolicyDescription = "Flexible pools with per-pool CPU parameters"

// balloonKey is a pod annotation key, the value is a pod balloon name.
balloonKey = "balloon." + PolicyName + "." + kubernetes.ResmgrKeyNamespace
// hideHyperthreadsKey is a pod annotation key for pod/container-specific hyperthread allowance.
Expand All @@ -56,6 +55,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
// power efficient cores.
virtDevECores = "efficient cores"
// virtDevPCores is the name of a virtual device close to
// high performance cores.
virtDevPCores = "performance cores"
)

// balloons contains configuration and runtime attributes of the balloons policy
Expand Down Expand Up @@ -562,6 +567,8 @@ 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()[cpuallocator.PriorityLow]},
virtDevPCores: {p.cpuAllocator.GetCPUPriorities()[cpuallocator.PriorityHigh]},
},
}
if blnDef.AllocatorTopologyBalancing != nil {
Expand Down Expand Up @@ -1202,6 +1209,12 @@ func (p *balloons) fillCloseToDevices(blnDefs []*BalloonDef) {
if blnDef.PreferIsolCpus {
blnDef.PreferCloseToDevices = append(blnDef.PreferCloseToDevices, virtDevIsolatedCpus)
}
if blnDef.PreferCoreType == "performance" {
blnDef.PreferCloseToDevices = append(blnDef.PreferCloseToDevices, virtDevPCores)
}
if blnDef.PreferCoreType == "efficient" {
blnDef.PreferCloseToDevices = append(blnDef.PreferCloseToDevices, virtDevECores)
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/config.nri_balloonspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ spec:
items:
type: string
type: array
preferCoreType:
description: |-
preferCoreType: prefer performance or efficient (P/E) CPU cores on
hybrid architectures.
enum:
- efficient
- performance
type: string
preferIsolCpus:
default: false
description: 'preferIsolCpus: prefer kernel isolated cpus'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ spec:
items:
type: string
type: array
preferCoreType:
description: |-
preferCoreType: prefer performance or efficient (P/E) CPU cores on
hybrid architectures.
enum:
- efficient
- performance
type: string
preferIsolCpus:
default: false
description: 'preferIsolCpus: prefer kernel isolated cpus'
Expand Down
5 changes: 5 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,11 @@ type BalloonDef struct {
// preferIsolCpus: prefer kernel isolated cpus
// +kubebuilder:default:=false
PreferIsolCpus bool `json:"preferIsolCpus,omitempty"`
// preferCoreType: prefer performance or efficient (P/E) CPU cores on
// hybrid architectures.
// +optional
// +kubebuilder:validation:Enum:=efficient;performance
PreferCoreType string `json:"preferCoreType,omitempty"`
}

// String stringifies a BalloonDef
Expand Down

0 comments on commit f295f33

Please sign in to comment.