topology

package module
v0.0.0-...-e344461 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ProviderKubelet is a constant to distinguish that topology hint comes
	// from parameters passed to CRI create/update requests from Kubelet.
	ProviderKubelet = "kubelet"
)

Variables

This section is empty.

Functions

func FindGivenSysFsDevice

func FindGivenSysFsDevice(devType string, major, minor int64) (string, error)

FindGivenSysFsDevice returns the physical device with the given device type, major, and minor numbers.

func FindSysFsDevice

func FindSysFsDevice(dev string) (string, error)

FindSysFsDevice for given argument returns physical device where it is linked to. For device nodes it will return path for device itself. For regular files or directories this function returns physical device where this inode resides (storage device). If result device is a virtual one (e.g. tmpfs), error will be returned. For non-existing path, no error returned and path is empty.

func ResetLogger

func ResetLogger()

ResetLogger resets any externally set logger.

func SetSysRoot

func SetSysRoot(root string)

SetSysRoot sets the sysfs root directory to use.

Types

type Hint

type Hint struct {
	// Provider is the sysfs path this hint was collected from.
	Provider string
	// CPUs is the CPU list the device is affine to, in Linux list
	// format (e.g. "0-3,7").
	CPUs string
	// NUMAs is the list of NUMA nodes the device is attached to.
	NUMAs string
	// Sockets is the list of physical sockets the device is on. Set
	// only as a fallback, when a kernel/BIOS quirk leaves NUMAs set
	// but no usable CPU list to derive it from.
	Sockets string
	// PCIeChain lists the device's ancestor PCI bridges and its root
	// complex, ordered from the nearest bridge to the root. Empty for
	// devices with no PCI ancestry.
	PCIeChain []PCIeHop
	// IRQs lists the interrupt numbers tied to the device, read from
	// its own sysfs "irq" file and "msi_irqs" entries.
	IRQs []int
}

Hint represents various hints that can be detected from sysfs for the device.

func (*Hint) String

func (h *Hint) String() string

String returns the hints as a string.

type Hints

type Hints map[string]Hint

Hints represents set of hints collected from multiple providers.

func MergeTopologyHints

func MergeTopologyHints(org, hints Hints) (res Hints)

MergeTopologyHints combines org and hints.

func NewTopologyHints

func NewTopologyHints(devPath string) (hints Hints, err error)

NewTopologyHints return array of hints for the main device and its depended devices (e.g. RAID).

func (Hints) ResolvePartialHints

func (hints Hints) ResolvePartialHints(resolve func(NUMAs string) string)

ResolvePartialHints resolves NUMA-only hints to CPU hints using the given function.

type Logger

type Logger interface {
	Debugf(format string, v ...interface{})
}

Logger is interface we expect from an optional, externally set logger.

func SetLogger

func SetLogger(l Logger) Logger

SetLogger sets the external logger used for (debug) logging.

type PCIeHop

type PCIeHop struct {
	// Address is the PCI address (e.g. "0000:00:1c.0"), or the sysfs
	// root bridge directory name (e.g. "pci0000:00") when Type is
	// PCIeHopRoot.
	Address string
	Type    PCIeHopType
}

PCIeHop is one ancestor bridge or the root complex above a device in its PCIe hierarchy.

type PCIeHopType

type PCIeHopType string

PCIeHopType tells what kind of node a PCIeHop entry refers to.

const (
	// PCIeHopBridge marks a PCI-to-PCI bridge (class 0604): a root
	// port, a switch upstream or downstream port, or a plain bridge.
	// Sysfs has no separate class for switches, so a switch just
	// shows up as consecutive bridge hops in the chain.
	PCIeHopBridge PCIeHopType = "bridge"
	// PCIeHopRoot marks the host bridge / root complex at the top of
	// a device's PCI hierarchy.
	PCIeHopRoot PCIeHopType = "root"
)

Jump to

Keyboard shortcuts

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