diff --git a/cmd/plugins/balloons/policy/balloons-policy.go b/cmd/plugins/balloons/policy/balloons-policy.go index 490d43fe3..a5e4415f3 100644 --- a/cmd/plugins/balloons/policy/balloons-policy.go +++ b/cmd/plugins/balloons/policy/balloons-policy.go @@ -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. @@ -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 @@ -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 { @@ -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) + } } } diff --git a/config/crd/bases/config.nri_balloonspolicies.yaml b/config/crd/bases/config.nri_balloonspolicies.yaml index 6babf6d1c..16f1d3872 100644 --- a/config/crd/bases/config.nri_balloonspolicies.yaml +++ b/config/crd/bases/config.nri_balloonspolicies.yaml @@ -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' diff --git a/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml b/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml index 6babf6d1c..16f1d3872 100644 --- a/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml +++ b/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml @@ -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' diff --git a/docs/resource-policy/policy/balloons.md b/docs/resource-policy/policy/balloons.md index 7e5b24863..5f3d62573 100644 --- a/docs/resource-policy/policy/balloons.md +++ b/docs/resource-policy/policy/balloons.md @@ -154,6 +154,9 @@ Balloons policy parameters: separate `cpu.classes` objects, see below. - `preferCloseToDevices`: prefer creating new balloons close to listed devices. List of strings + - `preferCoreType`: specifies preferences of the core type which + could be either power efficient (`efficient`) or high performance + (`performance`). - `preferSpreadingPods`: if `true`, containers of the same pod should be spread to different balloons of this type. The default is `false`: prefer placing containers of the same pod to the same @@ -168,7 +171,7 @@ Balloons policy parameters: preferring exclusive CPUs, as long as there are enough free CPUs. The default is `false`: prefer filling and inflating existing balloons over creating new ones. - - `preferIsolCpus`: if `true`,prefer system isolated CPUs (refer to + - `preferIsolCpus`: if `true`, prefer system isolated CPUs (refer to kernel command line parameter "isolcpus") for this balloon. Warning: if there are not enough isolated CPUs in the system for balloons that prefer them, balloons may include normal CPUs, too. This kind of diff --git a/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go b/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go index f5b73c17e..04b582e63 100644 --- a/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go +++ b/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go @@ -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