Documentation
¶
Overview ¶
Package cpufreq owns the cpufreq-side CPU-class lifecycle: resolution of symbolic frequencies (min/base/turbo), turbo-priority winner selection per turbo domain, and the per-CPU sysfs writes that follow. The package is consumed by the cpuclass handler and exposes no behavior to user-facing code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
Allocator owns the per-turbo-domain class state for cpufreq.
func New ¶
New returns an Allocator that publishes class definitions and per-CPU assignments to sink. The constructor does not push any class definitions; the caller follows up with Configure().
func (*Allocator) Configure ¶
func (a *Allocator) Configure(classes []*policyapi.CPUClass, turboDomain string, allowed cpuset.CPUSet) error
Configure replaces the CPU class set, turbo domain mode and the set of allowed CPUs. Resets per-domain turbo winners and re-publishes class definitions to the sink.
func (*Allocator) IsKnownClass ¶
IsKnownClass reports whether the given class name is known to the allocator's CPUClasses configuration.
type Hooks ¶
type Hooks struct {
SetMin func(cpu, kHz int) error
SetMax func(cpu, kHz int) error
SetGov func(cpu int, governor string) error
}
Hooks lets tests intercept per-CPU writes without touching real sysfs. Production use leaves all hooks nil; the writer then talks to the platform via goresctrl.
type Sink ¶
type Sink interface {
SetClassDef(name string, def types.ClassDef)
AssignCPUs(name string, cpus []int)
}
Sink is the back-channel through which the allocator publishes resolved class definitions and per-CPU class assignments to its owner (the cpuclass handler). The handler turns these into per-CPU dirty bits and sysfs writes performed by its Commit().
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is the direct per-CPU cpufreq sysfs writer. Properties are written only when the desired value differs from the last successfully written one. Failures on individual CPUs/properties are logged but do not stop processing of the remaining ones; the first error encountered is returned.
func NewWriter ¶
NewWriter returns a Writer wired to the given hooks. Pass a zero-valued Hooks to use real sysfs via goresctrl.
func (*Writer) Enforce ¶
Enforce writes min/max/governor to sysfs for every CPU in cpus, skipping properties whose desired value matches the last written one. A zero min or max means "don't enforce". An empty governor means "don't enforce". The first error encountered is returned.