diff --git a/go.mod b/go.mod index fdfb21cda..86b16e4e3 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 - github.com/intel/goresctrl v0.7.0 + github.com/intel/goresctrl v0.8.0 github.com/klauspost/compress v1.17.10 github.com/mdlayher/vsock v1.2.1 github.com/moby/locker v1.0.1 diff --git a/go.sum b/go.sum index 29b55b007..bbe6147d5 100644 --- a/go.sum +++ b/go.sum @@ -921,8 +921,8 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/intel/goresctrl v0.7.0 h1:x6RclP6LiJc24t9mf47BRbjf06B8oVisZMBv31x3rKc= -github.com/intel/goresctrl v0.7.0/go.mod h1:T3ZZnuHSNouwELB5wvOoUJaB7l/4Rm23rJy/wuWJlr0= +github.com/intel/goresctrl v0.8.0 h1:N3shVbS3kA1Hk2AmcbHv8805Hjbv+zqsCIZCGktxx50= +github.com/intel/goresctrl v0.8.0/go.mod h1:T3ZZnuHSNouwELB5wvOoUJaB7l/4Rm23rJy/wuWJlr0= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= diff --git a/vendor/github.com/intel/goresctrl/pkg/utils/sysfs.go b/vendor/github.com/intel/goresctrl/pkg/utils/sysfs.go index 0dfb70c34..6e72338e3 100644 --- a/vendor/github.com/intel/goresctrl/pkg/utils/sysfs.go +++ b/vendor/github.com/intel/goresctrl/pkg/utils/sysfs.go @@ -34,6 +34,10 @@ func setCPUFreqValue(cpu ID, setting string, value int) error { return writeFileInt(cpuFreqPath(cpu, setting), value) } +func SetCPUScalingGovernor(cpu ID, governor string) error { + return writeFileStr(cpuFreqPath(cpu, "scaling_governor"), governor) +} + // GetCPUFreqValue returns information of the currently used CPU frequency func GetCPUFreqValue(cpu ID, setting string) (int, error) { raw, err := os.ReadFile(cpuFreqPath(cpu, setting)) @@ -63,6 +67,17 @@ func SetCPUScalingMaxFreq(cpu ID, freq int) error { return setCPUFreqValue(cpu, "scaling_max_freq", freq) } +// SetScalingGovernorForCPUs sets the scaling_governor of a given set of CPUs +func SetScalingGovernorForCPUs(cpus []ID, governor string) error { + for _, cpu := range cpus { + if err := SetCPUScalingGovernor(cpu, governor); err != nil { + return err + } + } + + return nil +} + // SetCPUsScalingMinFreq sets the scaling_min_freq value of a given set of CPUs func SetCPUsScalingMinFreq(cpus []ID, freq int) error { for _, cpu := range cpus { @@ -129,6 +144,10 @@ func writeFileInt(path string, value int) error { return os.WriteFile(path, []byte(strconv.Itoa(value)), 0644) } +func writeFileStr(path string, value string) error { + return os.WriteFile(path, []byte(value), 0644) +} + func readFileInt(path string) (int, error) { data, err := os.ReadFile(path) if err != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 529d8e814..e8126e044 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -317,7 +317,7 @@ github.com/grpc-ecosystem/grpc-gateway/v2/runtime github.com/grpc-ecosystem/grpc-gateway/v2/utilities # github.com/hashicorp/errwrap v1.1.0 ## explicit -# github.com/intel/goresctrl v0.7.0 +# github.com/intel/goresctrl v0.8.0 ## explicit; go 1.20 github.com/intel/goresctrl/pkg/blockio github.com/intel/goresctrl/pkg/kubernetes