resctrlfs

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package resctrlfs provides access to the monitoring data of the resctrl filesystem.

resctrl is the kernel interface to the cache and memory bandwidth resource control of the CPU: Intel calls it RDT (Resource Director Technology), AMD calls it PQoS (Platform Quality of Service), Arm calls it MPAM (Memory System Resource Partitioning and Monitoring). All vendors are served by the same kernel driver, so the file layout is identical.

The filesystem is not mounted by default. Mount it with:

mount -t resctrl resctrl /sys/fs/resctrl

This package only reads monitoring data. It does not configure allocation.

The filesystem is documented in the kernel tree:

Index

Constants

View Source
const DefaultMountPoint = fs.DefaultResctrlMountPoint

DefaultMountPoint is the common mount point of the resctrl filesystem.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

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

FS represents the pseudo-filesystem resctrl, which provides an interface to the cache and memory bandwidth monitoring of the CPU.

func NewDefaultFS

func NewDefaultFS() (FS, error)

NewDefaultFS returns a new FS mounted under the default mountPoint. It will error if the mount point can't be read.

func NewFS

func NewFS(mountPoint string) (FS, error)

NewFS returns a new FS mounted under the given mountPoint. It will error if the mount point can't be read.

func (FS) L3MonInfo

func (fs FS) L3MonInfo() (L3MonInfo, error)

L3MonInfo returns the L3 monitoring capabilities of the CPU.

It errors if info/L3_MON is missing, which means the CPU or the kernel does not support L3 monitoring. The error wraps the underlying os error, so it can be tested with os.IsNotExist.

func (FS) MonData

func (fs FS) MonData() ([]MonData, error)

MonData returns the monitoring counters of the root control group, one entry per monitoring domain. A domain is a socket, or a CCX on AMD.

It errors only if the mon_data directory itself can't be read. A domain counter that is missing, unreadable or unavailable stays nil, because the hardware may support only some of the features and samples are not always available. A mount without any monitoring domain returns an empty slice.

type L3MonInfo

type L3MonInfo struct {
	// NumRMIDs is the number of resource monitoring ids the hardware offers.
	// One RMID is used per monitoring group, so this is the upper limit of
	// groups that can be monitored at the same time.
	NumRMIDs uint64
	// MonFeatures lists the counters the hardware supports, in the order the
	// kernel reports them, e.g. "llc_occupancy", "mbm_total_bytes",
	// "mbm_local_bytes".
	MonFeatures []string
}

L3MonInfo describes the L3 monitoring capabilities from info/L3_MON.

type MonData

type MonData struct {
	Resource string // e.g. "L3"
	ID       string // domain id with leading zeros stripped, e.g. "0"
	// Counters are nil when the file is absent (feature not supported)
	// or reads "Unavailable" (no sample available right now). For example
	// Arm MPAM never offers MBMLocalBytes, because the hardware can not
	// tell local from remote traffic.
	LLCOccupancy  *uint64
	MBMTotalBytes *uint64
	MBMLocalBytes *uint64
}

MonData holds the monitoring counters of one domain of one resource, read from mon_data/mon_<resource>_<id>.

Jump to

Keyboard shortcuts

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