cpuclass

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cpuclass is the resource-manager-wide CPU class handler. It owns the per-CPU frequency, c-state, uncore-frequency and Intel Priority Core Turbo state implied by a list of user-facing CPU class definitions.

Policies talk to a single *Handler, constructed with New(sys). Configure(spec) installs (or replaces) the class set; UseClass pins given CPUs to a named class; Commit() flushes deferred per-CPU sysfs writes; Hints() returns placement preferences a policy can use when picking new CPUs for an allocation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocationHints

type AllocationHints = types.AllocationHints

AllocationHints carries technology-agnostic placement preferences returned by Handler.Hints.

type AllocationIntent

type AllocationIntent = types.AllocationIntent

AllocationIntent describes an upcoming CPU allocation for which the caller wants placement preferences.

type ConfigSpec

type ConfigSpec struct {
	// Classes is the user-facing list of CPU classes.
	Classes []*policyapi.CPUClass
	// TurboDomain selects the per-domain turbo arbitration scope.
	// Empty resolves to "package".
	TurboDomain string
	// Allowed bounds every cpuclass operation. CPUs outside this
	// set are silently dropped by Configure, UseClass and Hints.
	Allowed cpuset.CPUSet
}

ConfigSpec carries cpuclass configuration applied via Handler.Configure. Idleness is intentionally absent: the caller decides which class name (if any) means "idle" and applies it via UseClass.

type CpuPreference

type CpuPreference = types.CpuPreference

CpuPreference is a named CPU set carrying a single placement preference (prefer or avoid).

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is the sole cpuclass entry point for policy code. It owns construction and configuration of the per-technology allocators (cpufreq, pct) and writers (cpufreq, cpuidle, uncorefreq).

func New

func New(sys sysfs.System) (*Handler, error)

New constructs a Handler with both internal allocators (cpufreq and pct) ready in a "no configuration applied" state. Configure must be called before the handler is usable.

func (*Handler) AssignCPUs

func (h *Handler) AssignCPUs(name string, cpus []int)

AssignCPUs updates the (cpu -> synthetic class) map for the given CPUs. CPUs whose class changes are added to the dirty set. An empty class name means "no class". Implements the cpufreq.Sink interface.

func (*Handler) Commit

func (h *Handler) Commit() error

Commit flushes pending cpufreq, cpuidle and uncore changes to sysfs. Per-property writes are deduplicated against the writers' lastWritten caches.

func (*Handler) Configure

func (h *Handler) Configure(spec ConfigSpec) error

Configure (re)applies a configuration spec. Idempotent: may be called repeatedly with changed classes, turbo-domain mode, or allowed set.

func (*Handler) Hints

func (h *Handler) Hints(intent AllocationIntent) AllocationHints

Hints returns technology-agnostic placement preferences for an upcoming CPU allocation. The returned CpuPreference sets are always subsets of the configured Allowed set.

func (*Handler) PctActive

func (h *Handler) PctActive() bool

PctActive reports whether PCT is in effect on this node.

func (*Handler) PctFreeClassCapacity

func (h *Handler) PctFreeClassCapacity(className string, held cpuset.CPUSet) int

PctFreeClassCapacity returns the number of logical CPUs that the PCT allocator can still route into the named cpuClass on this node, given that 'held' lists CPUs already consumed by some balloon belonging to any other cpuClass. Returns 0 if PCT is inactive or the class has no PCT plan.

func (*Handler) SetClassDef

func (h *Handler) SetClassDef(name string, def types.ClassDef)

SetClassDef records a class definition keyed by its synthetic name. If the definition materially changes, every CPU currently assigned to that synthetic class is marked dirty. Implements the cpufreq.Sink interface.

func (*Handler) Shutdown

func (h *Handler) Shutdown() error

Shutdown releases any platform-level resources owned by the handler. Safe to call multiple times.

func (*Handler) UseClass

func (h *Handler) UseClass(className string, cpus cpuset.CPUSet) error

UseClass applies className to the given CPUs across every internal allocator. An empty className means "no class". CPUs outside the configured Allowed set are silently dropped.

Directories

Path Synopsis
internal
cpufreq
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.
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.
cpuidle
Package cpuidle is the C-state writer used by the cpuclass handler.
Package cpuidle is the C-state writer used by the cpuclass handler.
pct
types
Package types defines the internal class-definition struct used by the cpuclass writers (cpufreq, cpuidle, uncorefreq).
Package types defines the internal class-definition struct used by the cpuclass writers (cpufreq, cpuidle, uncorefreq).
uncorefreq
Package uncorefreq is the per-die uncore frequency writer used by the cpuclass handler.
Package uncorefreq is the per-die uncore frequency writer used by the cpuclass handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL