Skip to content

Commit

Permalink
balloons: set frequency scaling governor only when requested
Browse files Browse the repository at this point in the history
Avoid enforcing the frequency scaling governor if the user hasn't
explicitly requested it. Previously, we attempted to set it regardless,
leading to unnecessary error logs. Furthermore, fix formatting issue
when logging error case.

Signed-off-by: Feruzjon Muyassarov <[email protected]>
  • Loading branch information
fmuyassarov committed Oct 10, 2024
1 parent 09d705a commit 055cc18
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions pkg/resmgr/control/cpu/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ func Assign(c cache.Cache, class string, cpus ...int) error {
if err := ctl.enforceCpufreq(class, cpus...); err != nil {
log.Error("cpufreq enforcement failed: %v", err)
}
if err := ctl.enforceCpufreqGovernor(class, cpus...); err != nil {
log.Error("cpufreq governor enforcement failed: %v", err)
if _, ok := ctl.classes[class]; ok {
if err := ctl.enforceCpufreqGovernor(class, cpus...); err != nil {
log.Error("cpufreq governor enforcement failed: %v", err)
}
}
if err := ctl.enforceUncore(assignments, cpus...); err != nil {
log.Error("uncore frequency enforcement failed: %v", err)
Expand Down
16 changes: 9 additions & 7 deletions pkg/resmgr/control/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ func (ctl *cpuctl) enforceCpufreqGovernor(class string, cpusIds ...int) error {
if _, ok := ctl.classes[class]; !ok {
return fmt.Errorf("non-existent cpu class %q", class)
}
governor := ctl.classes[class].FreqGovernor
for cpu := range cpusIds {
log.Info(strconv.Itoa(cpu), governor)
}
log.Debug("enforcing cpu frequency governor %q on %v", governor, cpusIds)
if err := utils.SetScalingGovernorForCPUs(cpusIds, governor); err != nil {
return fmt.Errorf("Cannot set cpufreq governor %d: %w", governor, err)
if ctl.classes[class].FreqGovernor != "" {
governor := ctl.classes[class].FreqGovernor
for cpu := range cpusIds {
log.Info(strconv.Itoa(cpu), governor)
}
log.Debug("enforcing cpu frequency governor %q on %v", governor, cpusIds)
if err := utils.SetScalingGovernorForCPUs(cpusIds, governor); err != nil {
return fmt.Errorf("cannot set cpufreq governor %q: %w", governor, err)
}
}
return nil
}
Expand Down

0 comments on commit 055cc18

Please sign in to comment.