Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

balloons: add support for power efficient & high performance cores #354

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 4 additions & 1 deletion docs/resource-policy/policy/balloons.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
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