Skip to content

Commit

Permalink
Merge pull request #455 from askervin/5YY_cpufreq_optional
Browse files Browse the repository at this point in the history
balloons: do not require minFreq and maxFreq in CPU classes
  • Loading branch information
fmuyassarov authored Dec 18, 2024
2 parents 00c77b6 + 1d1f933 commit 4037edc
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 29 deletions.
3 changes: 0 additions & 3 deletions config/crd/bases/config.nri_balloonspolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,6 @@ spec:
description: UncoreMinFreq is the minimum uncore frequency
for this class.
type: integer
required:
- maxFreq
- minFreq
type: object
type: object
required:
Expand Down
3 changes: 0 additions & 3 deletions config/crd/bases/config.nri_templatepolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ spec:
description: UncoreMinFreq is the minimum uncore frequency
for this class.
type: integer
required:
- maxFreq
- minFreq
type: object
type: object
required:
Expand Down
3 changes: 0 additions & 3 deletions config/crd/bases/config.nri_topologyawarepolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ spec:
description: UncoreMinFreq is the minimum uncore frequency
for this class.
type: integer
required:
- maxFreq
- minFreq
type: object
type: object
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,6 @@ spec:
description: UncoreMinFreq is the minimum uncore frequency
for this class.
type: integer
required:
- maxFreq
- minFreq
type: object
type: object
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ spec:
description: UncoreMinFreq is the minimum uncore frequency
for this class.
type: integer
required:
- maxFreq
- minFreq
type: object
type: object
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ spec:
description: UncoreMinFreq is the minimum uncore frequency
for this class.
type: integer
required:
- maxFreq
- minFreq
type: object
type: object
required:
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/config/v1alpha1/resmgr/control/cpu/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ type Config struct {

type Class struct {
// MinFreq is the minimum frequency for this class.
MinFreq uint `json:"minFreq"`
MinFreq uint `json:"minFreq,omitempty"`
// MaxFreq is the maximum frequency for this class.
MaxFreq uint `json:"maxFreq"`
MaxFreq uint `json:"maxFreq,omitempty"`
// EnergyPerformancePreference for CPUs in this class.
EnergyPerformancePreference uint `json:"energyPerformancePreference,omitempty"`
// UncoreMinFreq is the minimum uncore frequency for this class.
Expand Down
19 changes: 10 additions & 9 deletions pkg/resmgr/control/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,22 @@ func (ctl *cpuctl) enforceCpufreq(class string, cpus ...int) error {
return fmt.Errorf("non-existent cpu class %q", class)
}

min := int(c.MinFreq)
max := int(c.MaxFreq)
log.Debug("enforcing cpu frequency limits {%d, %d} from class %q on %v", min, max, class, cpus)

if err := utils.SetCPUsScalingMinFreq(cpus, min); err != nil {
return fmt.Errorf("Cannot set min freq %d: %w", min, err)
if min := int(c.MinFreq); min > 0 {
log.Debug("enforcing cpu frequency min %d from class %q on %v", min, class, cpus)
if err := utils.SetCPUsScalingMinFreq(cpus, min); err != nil {
return fmt.Errorf("Cannot set min freq %d: %w", min, err)
}
}

if err := utils.SetCPUsScalingMaxFreq(cpus, max); err != nil {
return fmt.Errorf("Cannot set max freq %d: %w", max, err)
if max := int(c.MaxFreq); max > 0 {
log.Debug("enforcing cpu frequency max %d from class %q on %v", max, class, cpus)
if err := utils.SetCPUsScalingMaxFreq(cpus, max); err != nil {
return fmt.Errorf("Cannot set max freq %d: %w", max, err)
}
}

if governor := c.FreqGovernor; governor != "" {
log.Debug("enforcing cpu frequency governor %q from class %q on %v", governor, class, cpus)

if err := utils.SetScalingGovernorForCPUs(cpus, governor); err != nil {
return fmt.Errorf("cannot set cpufreq governor %q: %w", governor, err)
}
Expand Down

0 comments on commit 4037edc

Please sign in to comment.