lxd: github.com/lxc/lxd/lxd/cgroup Index | Files

package cgroup

import "github.com/lxc/lxd/lxd/cgroup"

Index

Package Files

abstraction.go cgroup_cpu.go errors.go init.go load.go types.go

Constants

const (
    // Unavailable indicates the lack of controller.
    Unavailable = Backend(0)

    // V1 indicates the controller is backed by Cgroup V1.
    V1  = Backend(1)

    // V2 indicates the controller is backed by Cgroup V2.
    V2  = Backend(2)
)

Variables

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

DeviceSchedRebalance channel for scheduling a CPU rebalance.

var ErrControllerMissing = fmt.Errorf("Cgroup controller is missing")

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

var ErrUnknownVersion = fmt.Errorf("Unknown cgroup version")

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

func ParseCPU Uses

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

ParseCPU parses CPU allowances.

func TaskSchedulerTrigger Uses

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

TaskSchedulerTrigger triggers a CPU rebalance.

type Backend Uses

type Backend int

Backend indicates whether to use v1, v2 or unavailable.

type CGroup Uses

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

CGroup represents the main cgroup abstraction.

func New Uses

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

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

func (*CGroup) GetBlkioWeight Uses

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

GetBlkioWeight returns the currently allowed range of weights

func (*CGroup) GetCPUAcctUsage Uses

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

GetCPUAcctUsage returns the total CPU time in ns used by processes

func (*CGroup) GetMaxMemory Uses

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

GetMaxMemory return the hard limit for memory

func (*CGroup) GetMemoryMaxUsage Uses

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

GetMemoryMaxUsage returns the record high for memory usage

func (*CGroup) GetMemorySoftLimit Uses

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

GetMemorySoftLimit returns the soft limit for memory

func (*CGroup) GetMemorySwMaxUsage Uses

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

GetMemorySwMaxUsage returns the record high for swap usage

func (*CGroup) GetMemorySwapLimit Uses

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

GetMemorySwapLimit returns the hard limit on swap usage

func (*CGroup) GetMemorySwapUsage Uses

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

GetMemorySwapUsage return current usage of swap

func (*CGroup) GetMemoryUsage Uses

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

GetMemoryUsage returns the current use of memory

func (*CGroup) GetProcessesUsage Uses

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

GetProcessesUsage returns the current number of pids

func (*CGroup) SetBlkioWeight Uses

func (cg *CGroup) SetBlkioWeight(value string) error

SetBlkioWeight set the currently allowed range of weights

func (*CGroup) SetCPUCfsPeriod Uses

func (cg *CGroup) SetCPUCfsPeriod(value string) error

SetCPUCfsPeriod sets the duration in ms for each scheduling period

func (*CGroup) SetCPUCfsQuota Uses

func (cg *CGroup) SetCPUCfsQuota(value string) error

SetCPUCfsQuota sets the max time in ms during each cfs_period_us that the current group can run for

func (*CGroup) SetCPUShare Uses

func (cg *CGroup) SetCPUShare(value string) error

SetCPUShare sets the weight of each group in the same hierarchy

func (*CGroup) SetMaxHugepages Uses

func (cg *CGroup) SetMaxHugepages(pageType string, value string) error

SetMaxHugepages applies a limit to the number of processes

func (*CGroup) SetMaxProcesses Uses

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

SetMaxProcesses applies a limit to the number of processes

func (*CGroup) SetMemoryMaxUsage Uses

func (cg *CGroup) SetMemoryMaxUsage(max string) error

SetMemoryMaxUsage sets the hard limit for memory

func (*CGroup) SetMemorySoftLimit Uses

func (cg *CGroup) SetMemorySoftLimit(softLim string) error

SetMemorySoftLimit set the soft limit for memory

func (*CGroup) SetMemorySwapMax Uses

func (cg *CGroup) SetMemorySwapMax(max string) error

SetMemorySwapMax sets the hard limit for swap

func (*CGroup) SetMemorySwappiness Uses

func (cg *CGroup) SetMemorySwappiness(value string) error

SetMemorySwappiness sets swappiness paramet of vmscan

func (*CGroup) SetNetIfPrio Uses

func (cg *CGroup) SetNetIfPrio(value string) error

SetNetIfPrio sets the priority for the process

type Info Uses

type Info struct {
    // Layout is one of CgroupsDisabled, CgroupsUnified, CgroupsHybrid, CgroupsLegacy
    Layout Layout

    // Namespacing indicates support for the cgroup namespace
    Namespacing bool
}

Info contains system cgroup information

func GetInfo Uses

func GetInfo() Info

GetInfo returns basic system cgroup information

func (*Info) Log Uses

func (info *Info) Log()

Log logs cgroup info

func (*Info) Mode Uses

func (info *Info) Mode() string

Mode returns the cgroup layout name

func (*Info) Supports Uses

func (info *Info) Supports(resource Resource, cgroup *CGroup) bool

Supports indicates whether or not a given resource is controllable.

func (*Info) SupportsVersion Uses

func (info *Info) SupportsVersion(resource Resource) (Backend, bool)

SupportsVersion indicates whether or not a given cgroup resource is controllable and in which type of cgroup filesystem.

type Layout Uses

type Layout int

Layout determines the cgroup layout on this system

const (
    // CgroupsDisabled indicates that cgroups are not supported
    CgroupsDisabled Layout = iota
    // CgroupsUnified indicates that this is a pure cgroup2 layout
    CgroupsUnified
    // CgroupsHybrid indicates that this is a mixed cgroup1 and cgroup2 layout
    CgroupsHybrid
    // CgroupsLegacy indicates that this is a pure cgroup1 layout
    CgroupsLegacy
)

type ReadWriter Uses

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

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

type Resource Uses

type Resource int

Resource is a generic type used to abstract resource control features support for the legacy and unified hierarchy.

const (
    // Blkio resource control
    Blkio Resource = iota

    // BlkioWeight resource control
    BlkioWeight

    // CPU resource control
    CPU

    // CPUAcct resource control
    CPUAcct

    // CPUSet resource control
    CPUSet

    // Devices resource control
    Devices

    // Freezer resource control
    Freezer

    // Hugetlb resource control
    Hugetlb

    // Memory resource control
    Memory

    // MemoryMaxUsage resource control
    MemoryMaxUsage

    // MemorySwap resource control
    MemorySwap

    // MemorySwapMaxUsage resource control
    MemorySwapMaxUsage

    // MemorySwapUsage resource control
    MemorySwapUsage

    // MemorySwappiness resource control
    MemorySwappiness

    // NetPrio resource control
    NetPrio

    // Pids resource control
    Pids
)

Package cgroup imports 8 packages (graph) and is imported by 12 packages. Updated 2020-04-07. Refresh now. Tools for package owners.