cgroup

package
v0.0.0-...-522126a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package cgroup provides an interface to read and write configuration to cgroup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadPaths

func LoadPaths(pid string) (map[string]string, error)

LoadPaths loads cgroup paths for given 'pid', may be set to 'self'.

Types

type Cgroup

type Cgroup struct {
	Name    string            `json:"name"`
	Parents map[string]string `json:"parents"`
	Own     bool              `json:"own"`
}

Cgroup represents a group inside all controllers. For example: Name='/foo/bar' maps to /sys/fs/cgroup/<controller>/foo/bar on all controllers.

func New

func New(spec *specs.Spec) (*Cgroup, error)

New creates a new Cgroup instance if the spec includes a cgroup path. Returns nil otherwise.

func (*Cgroup) CPUQuota

func (c *Cgroup) CPUQuota() (float64, error)

func (*Cgroup) Install

func (c *Cgroup) Install(res *specs.LinuxResources) error

Install creates and configures cgroups according to 'res'. If cgroup path already exists, it means that the caller has already provided a pre-configured cgroups, and 'res' is ignored.

func (*Cgroup) Join

func (c *Cgroup) Join() (func(), error)

Join adds the current process to the all controllers. Returns function that restores cgroup to the original state.

func (*Cgroup) MemoryLimit

func (c *Cgroup) MemoryLimit() (uint64, error)

MemoryLimit returns the memory limit.

func (*Cgroup) NumCPU

func (c *Cgroup) NumCPU() (int, error)

NumCPU returns the number of CPUs configured in 'cpuset/cpuset.cpus'.

func (*Cgroup) Uninstall

func (c *Cgroup) Uninstall() error

Uninstall removes the settings done in Install(). If cgroup path already existed when Install() was called, Uninstall is a noop.

Jump to

Keyboard shortcuts

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