cgroup

package
v7.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeviceSchedRebalance = make(chan []string, 2)

DeviceSchedRebalance channel for scheduling a CPU rebalance.

View Source
var ErrControllerMissing = errors.New("Cgroup controller is missing")

ErrControllerMissing indicates that the requested controller isn't setup on the system.

View Source
var ErrUnknownVersion = errors.New("Unknown cgroup version")

ErrUnknownVersion indicates that a version other than those supported was detected during init.

Functions

func Init

func Init()

Init initializes cgroups.

func ParseCPU

func ParseCPU(cpuAllowance string, cpuPriority string) (int64, int64, int64, error)

ParseCPU parses CPU allowances.

func Supports

func Supports(resource Resource) bool

Supports indicates whether or not a given cgroup resource is controllable.

func TaskSchedulerTrigger

func TaskSchedulerTrigger(srcType string, srcName string, srcStatus string)

TaskSchedulerTrigger triggers a CPU rebalance.

func Warnings

func Warnings() []cluster.Warning

Warnings returns a list of CGroup warnings.

Types

type CGroup

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

CGroup represents the main cgroup abstraction.

func New

func New(rw ReadWriter) (*CGroup, error)

New setups a new CGroup abstraction using the provided read/writer.

func NewFileReadWriter

func NewFileReadWriter(pid int) (*CGroup, error)

NewFileReadWriter returns a CGroup instance using the filesystem as its backend.

func (*CGroup) GetBlkioWeight

func (cg *CGroup) GetBlkioWeight() (int64, error)

GetBlkioWeight returns the currently allowed range of weights.

func (*CGroup) GetCPUAcctUsage

func (cg *CGroup) GetCPUAcctUsage() (int64, error)

GetCPUAcctUsage returns the total CPU time in ns used by processes.

func (*CGroup) GetCPUAcctUsageAll

func (cg *CGroup) GetCPUAcctUsageAll() (map[int64]CPUStats, error)

GetCPUAcctUsageAll returns the user and system CPU times of each CPU thread in ns used by processes.

func (*CGroup) GetCPUCfsLimit

func (cg *CGroup) GetCPUCfsLimit() (int64, int64, error)

GetCPUCfsLimit gets the quota and duration in ms for each scheduling period.

func (*CGroup) GetCpuset

func (cg *CGroup) GetCpuset() (string, error)

GetCpuset returns the current set of CPUs for the cgroup.

func (*CGroup) GetEffectiveCPUs

func (cg *CGroup) GetEffectiveCPUs() (int, error)

GetEffectiveCPUs returns the total number of effective CPUs.

func (*CGroup) GetEffectiveCpuset

func (cg *CGroup) GetEffectiveCpuset() (string, error)

GetEffectiveCpuset returns the current set of CPUs for the cgroup.

func (*CGroup) GetEffectiveMemoryLimit

func (cg *CGroup) GetEffectiveMemoryLimit() (int64, error)

GetEffectiveMemoryLimit return the effective hard limit for memory. Returns the cgroup memory limit, or if the cgroup memory limit couldn't be determined or is larger than the total system memory, then the total system memory is returned.

func (*CGroup) GetIOStats

func (cg *CGroup) GetIOStats() (map[string]*IOStats, error)

GetIOStats returns disk stats.

func (*CGroup) GetMemoryLimit

func (cg *CGroup) GetMemoryLimit() (int64, error)

GetMemoryLimit return the hard limit for memory.

func (*CGroup) GetMemoryMaxUsage

func (cg *CGroup) GetMemoryMaxUsage() (int64, error)

GetMemoryMaxUsage returns the record high for memory usage.

func (*CGroup) GetMemorySoftLimit

func (cg *CGroup) GetMemorySoftLimit() (int64, error)

GetMemorySoftLimit returns the soft limit for memory.

func (*CGroup) GetMemoryStats

func (cg *CGroup) GetMemoryStats() (map[string]uint64, error)

GetMemoryStats returns memory stats.

func (*CGroup) GetMemorySwapLimit

func (cg *CGroup) GetMemorySwapLimit() (int64, error)

GetMemorySwapLimit returns the hard limit on swap usage.

func (*CGroup) GetMemorySwapMaxUsage

func (cg *CGroup) GetMemorySwapMaxUsage() (int64, error)

GetMemorySwapMaxUsage returns the record high for swap usage.

func (*CGroup) GetMemorySwapUsage

func (cg *CGroup) GetMemorySwapUsage() (int64, error)

GetMemorySwapUsage return current usage of swap.

func (*CGroup) GetMemoryUsage

func (cg *CGroup) GetMemoryUsage() (int64, error)

GetMemoryUsage returns the current use of memory.

func (*CGroup) GetOOMKills

func (cg *CGroup) GetOOMKills() (int64, error)

GetOOMKills returns the number of oom kills.

func (*CGroup) GetProcessesUsage

func (cg *CGroup) GetProcessesUsage() (int64, error)

GetProcessesUsage returns the current number of pids.

func (*CGroup) SetBlkioLimit

func (cg *CGroup) SetBlkioLimit(dev string, oType string, uType string, limit int64) error

SetBlkioLimit sets the specified read or write limit for a device.

func (*CGroup) SetBlkioWeight

func (cg *CGroup) SetBlkioWeight(limit int64) error

SetBlkioWeight sets the currently allowed range of weights.

func (*CGroup) SetCPUCfsLimit

func (cg *CGroup) SetCPUCfsLimit(limitPeriod int64, limitQuota int64) error

SetCPUCfsLimit sets the quota and duration in ms for each scheduling period.

func (*CGroup) SetCPUShare

func (cg *CGroup) SetCPUShare(limit int64) error

SetCPUShare sets the weight of each group in the same hierarchy.

func (*CGroup) SetCpuset

func (cg *CGroup) SetCpuset(limit string) error

SetCpuset set the currently allowed set of CPUs for the cgroups.

func (*CGroup) SetHugepagesLimit

func (cg *CGroup) SetHugepagesLimit(pageType string, limit int64) error

SetHugepagesLimit applies a limit to the number of processes.

func (*CGroup) SetMaxProcesses

func (cg *CGroup) SetMaxProcesses(limit int64) error

SetMaxProcesses applies a limit to the number of processes.

func (*CGroup) SetMemoryLimit

func (cg *CGroup) SetMemoryLimit(limit int64) error

SetMemoryLimit sets the hard limit for memory.

func (*CGroup) SetMemorySoftLimit

func (cg *CGroup) SetMemorySoftLimit(limit int64) error

SetMemorySoftLimit set the soft limit for memory.

func (*CGroup) SetMemorySwapLimit

func (cg *CGroup) SetMemorySwapLimit(limit int64) error

SetMemorySwapLimit sets the hard limit for swap.

func (*CGroup) SetMemorySwappiness

func (cg *CGroup) SetMemorySwappiness(limit int64) error

SetMemorySwappiness sets swappiness paramet of vmscan.

type CPUStats

type CPUStats struct {
	User   int64
	System int64
}

CPUStats represent CPU stats.

type IOStats

type IOStats struct {
	ReadBytes       uint64
	ReadsCompleted  uint64
	WrittenBytes    uint64
	WritesCompleted uint64
}

IOStats represent IO stats.

type ReadWriter

type ReadWriter interface {
	Get(controller string, key string) (string, error)
	Set(controller string, key string, value string) error
}

The ReadWriter interface is used to read/write cgroup data.

type Resource

type Resource int

Resource is a generic type used to abstract resource control features.

const (
	// BlkioWeight resource control.
	BlkioWeight Resource = iota

	// CPU resource control.
	CPU

	// CPUSet resource control.
	CPUSet

	// Hugetlb resource control.
	Hugetlb

	// IO resource control.
	IO

	// Memory resource control.
	Memory

	// Pids resource control.
	Pids
)

Jump to

Keyboard shortcuts

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