cpuidle

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cpuidle is the C-state writer used by the cpuclass handler. It wraps the goresctrl cstates library, exposing a uniform Hooks-injectable interface that matches the cpufreq and uncorefreq writers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hooks

type Hooks struct {
	Apply func(cpus []int, enabled, disabled []string) error
}

Hooks lets tests intercept the cstate apply operations without touching real sysfs. Production use leaves all hooks nil; the writer then talks to the platform via goresctrl. The two hooks mirror the two Apply calls performed per enforce(): enable and disable.

type Writer

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

Writer enforces per-class enable/disable bits across the cstate names exposed by the platform. The cstates handle is created lazily on first enforce() call that has any disabled cstates; hosts and tests that never request a cstate change therefore never touch the cpuidle sysfs.

func NewWriter

func NewWriter(hooks Hooks) *Writer

NewWriter returns a Writer wired to the given hooks. Pass a zero-valued Hooks to use real sysfs via goresctrl.

func (*Writer) Enforce

func (w *Writer) Enforce(class string, disabledCstates []string, cpus []int) error

Enforce applies the class-specific C-state enable/disable mask on the given CPUs. An empty disabledCstates leaves the writer untouched as long as the cstates handle has never been initialized. Returns the first error encountered.

Jump to

Keyboard shortcuts

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