build(deps): bump github.com/intel/goresctrl from 0.3.0 to 0.5.0

Bumps [github.com/intel/goresctrl](https://github.com/intel/goresctrl) from 0.3.0 to 0.5.0.
- [Release notes](https://github.com/intel/goresctrl/releases)
- [Commits](https://github.com/intel/goresctrl/compare/v0.3.0...v0.5.0)

---
updated-dependencies:
- dependency-name: github.com/intel/goresctrl
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2023-12-14 03:37:26 +00:00
committed by GitHub
parent a901236bf0
commit fc4b78c05c
25 changed files with 215 additions and 1671 deletions

View File

@@ -18,26 +18,25 @@ package utils
import (
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
goresctrlpath "github.com/intel/goresctrl/pkg/path"
)
const (
SysfsUncoreBasepath = "/sys/devices/system/cpu/intel_uncore_frequency/"
SysfsUncoreBasepath = "sys/devices/system/cpu/intel_uncore_frequency"
SysfsCpuBasepath = "sys/devices/system/cpu"
)
func setCPUFreqValue(cpu ID, setting string, value int) error {
path := fmt.Sprintf("/sys/devices/system/cpu/cpu%d/cpufreq/%s", cpu, setting)
return writeFileInt(path, value)
return writeFileInt(cpuFreqPath(cpu, setting), value)
}
// GetCPUFreqValue returns information of the currently used CPU frequency
func GetCPUFreqValue(cpu ID, setting string) (int, error) {
str := fmt.Sprintf("/sys/devices/system/cpu/cpu%d/cpufreq/%s", cpu, setting)
raw, err := ioutil.ReadFile(str)
raw, err := os.ReadFile(cpuFreqPath(cpu, setting))
if err != nil {
return 0, err
}
@@ -50,6 +49,10 @@ func GetCPUFreqValue(cpu ID, setting string) (int, error) {
return value, nil
}
func cpuFreqPath(cpu ID, setting string) string {
return goresctrlpath.Path(SysfsCpuBasepath, fmt.Sprintf("cpu%d", cpu), "cpufreq", setting)
}
// SetCPUScalingMinFreq sets the scaling_min_freq value of a given CPU
func SetCPUScalingMinFreq(cpu ID, freq int) error {
return setCPUFreqValue(cpu, "scaling_min_freq", freq)
@@ -84,7 +87,7 @@ func SetCPUsScalingMaxFreq(cpus []ID, freq int) error {
// UncoreFreqAvailable returns true if the uncore frequency control functions are available.
func UncoreFreqAvailable() bool {
_, err := os.Stat(SysfsUncoreBasepath)
_, err := os.Stat(goresctrlpath.Path(SysfsUncoreBasepath))
return err == nil
}
@@ -99,7 +102,7 @@ func SetUncoreMaxFreq(pkg, die ID, freqKhz int) error {
}
func uncoreFreqPath(pkg, die ID, attribute string) string {
return fmt.Sprintf(SysfsUncoreBasepath+"package_%02d_die_%02d/%s", pkg, die, attribute)
return goresctrlpath.Path(SysfsUncoreBasepath, fmt.Sprintf("package_%02d_die_%02d", pkg, die), attribute)
}
func getUncoreFreqValue(pkg, die ID, attribute string) (int, error) {
@@ -123,11 +126,11 @@ func setUncoreFreqValue(pkg, die ID, attribute string, value int) error {
}
func writeFileInt(path string, value int) error {
return ioutil.WriteFile(path, []byte(strconv.Itoa(value)), 0644)
return os.WriteFile(path, []byte(strconv.Itoa(value)), 0644)
}
func readFileInt(path string) (int, error) {
data, err := ioutil.ReadFile(path)
data, err := os.ReadFile(path)
if err != nil {
return 0, err
}