pct

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: 12 Imported by: 0

Documentation

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 manages Intel Priority Core Turbo CLOS associations driven by cpuClass definitions.

func NewAllocator

func NewAllocator(sys Sys) (*Allocator, error)

NewAllocator returns a new PCT allocator in the disabled mode.

func (*Allocator) Active

func (a *Allocator) Active() bool

active reports whether PCT is in effect (mode != disabled).

func (*Allocator) Configure

func (a *Allocator) Configure(classes []*policyapi.CPUClass, allowed cpuset.CPUSet) error

configure selects the PCT operating mode from the given cpuClass definitions and, in managed mode, programs the corresponding SST CLOSes. Honors `allowed` as the boundary of CPUs the allocator may touch.

  • classes: cpuClass definitions to inspect for PCT fields.
  • allowed: CPUs the allocator may configure.

func (*Allocator) FreeClassCapacity

func (a *Allocator) FreeClassCapacity(className string, held cpuset.CPUSet) int

freeClassCapacity returns the number of logical CPUs that can still be allocated to className, given that 'held' lists CPUs already consumed by some balloon on this node (any class).

Same formula in managed and assoc-only modes:

  • HP class: sum over HP-eligible punits of min(GuaranteedHpCpus, |pu.CPUs intersect Allowed minus held|). HP capacity is bounded by the punit's *guaranteed top-turbo* HP count (smallest non-zero SST-TF bucket HighPriorityCoreCount, or SST-BF HP CPU count when TF is unsupported) -- not by the larger MaxHpCpus the allocator uses for steering. The scheduler-visible capacity must reflect how many CPUs can *actually* sustain the highest turbo frequency this platform exposes; otherwise HP pods get scheduled past the guaranteed-turbo headroom and fall back to lower-bucket frequencies.
  • non-HP class: |Allowed minus held|. The allocator can re-associate any Allowed CPU to any CLOS on demand, so the gating set is what the plugin owns, not what currently lives on the target CLOS in hardware.

The modes differ in how hpEligiblePunit is populated:

  • Managed mode: every snapshotted punit is HP-eligible (the plugin enables SST-TF itself via PrepareManagedMode).
  • Assoc-only mode: a punit is HP-eligible only when SST-TF is currently enabled on it (operator's responsibility). Punits where TF is disabled cannot exceed the standard turbo-ratio bucket and contribute 0 to HP capacity, so the scheduler does not bin-pack HP pods onto nodes that cannot deliver top turbo.

Returns 0 for classes that have no PCT plan or when PCT is not active. Negative intermediate counts are clamped to 0.

func (*Allocator) Hints

hints returns prefer/avoid CPU sets that PCT would like an upcoming allocation under intent.ClassName to honor. Returned types.CpuPreference sets are not yet intersected with Allowed; the handler does that.

Behavior:

  • Class has an explicit CLOS plan (assoc-only or managed): Prefer CLOS-member CPUs.
  • Class is currently classified HP: Prefer hpReserveCpus (best-fit punit; same-package union as fallback), and also CLOS-member CPUs. No cross-package hint is ever emitted.
  • Class is not HP and at least one HP class exists: Avoid hpInUseCpus (punits currently hosting HP work).

func (*Allocator) Shutdown

func (a *Allocator) Shutdown() error

Shutdown restores the platform to its default state. Safe to call multiple times.

func (*Allocator) UseClass

func (a *Allocator) UseClass(className string, cpus cpuset.CPUSet) error

useClass associates the given CPUs to the CLOS chosen for className. In managed mode, CPUs whose className is not a PCT class are associated to the fallback CLOS. In assoc-only mode such CPUs are left unchanged. CPUs outside the configured Allowed set are silently dropped.

type Sys

type Sys interface {
	PackageIDs() []idset.ID
	Package(id idset.ID) sysfs.CPUPackage
	CPU(id idset.ID) sysfs.CPU
	CPUIDs() []idset.ID
}

Sys is the subset of sysfs.System that Allocator depends on. Defined here so tests can substitute a fake without implementing the full sysfs.System surface.

Jump to

Keyboard shortcuts

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