cpuinfo

package
v0.0.0-...-bdfd8d1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCPUSet

func GetCPUSet(sysfs fs.FS, name string) ([]int, error)

GetCPUSet reads a CPU set range from sysfs (e.g., "present", "online").

func ParseRange

func ParseRange(r string) ([]int, error)

ParseRange parses a range string like "0-3,8-11" into a list of ints.

func StrRange

func StrRange(cpus []int) string

StrRange formats a list of ints into a range string like "0-3,8-11".

Types

type Core

type Core struct {
	ID      int // Kernel die-local core_id
	Die     *Die
	Threads []*Thread
}

Core corresponds to a physical hardware core.

type Die

type Die struct {
	ID     int // Kernel socket-local die_id
	Socket *Socket
	Cores  []*Core
}

Die corresponds to a silicon die within a package.

type Machine

type Machine struct {
	Threads []*Thread   // All logical CPUs in the system
	Cores   []*Core     // All physical cores
	Dies    []*Die      // All dies
	Sockets []*Socket   // All physical packages
	Nodes   []*NUMANode // All NUMA nodes
}

Machine represents the entire system topology.

Sockets, Dies, Cores, and Threads exist in a hierarchy. NUMA nodes generally correspond to Dies, but this isn't guaranteed.

func Load

func Load(sysfs fs.FS) (*Machine, error)

Load reads the CPU topology from the provided filesystem. For production, pass os.DirFS("/").

type NUMANode

type NUMANode struct {
	ID      int // Kernel NUMA node ID
	Threads []*Thread
}

NUMANode corresponds to a region of memory and associated CPUs.

type Socket

type Socket struct {
	ID   int // Kernel global physical_package_id
	Dies []*Die
}

Socket corresponds to a physical package (socket).

type Thread

type Thread struct {
	ID        int // Kernel global CPU ID (e.g., N from cpuN)
	Core      *Core
	Node      *NUMANode
	CoreIndex int // Tool-created index of this thread within its Core (0, 1, ...)
}

Thread corresponds to a logical CPU (hardware thread).

Jump to

Keyboard shortcuts

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