cgroup

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cgroup provides cgroup utilities to handle nested cgroups.

When Talos runs in a container, it might either share or not share the host cgroup namespace. If the cgroup namespace is not shared, PID 1 will appear in cgroup '/', otherwise it will be part of some pre-existing cgroup hierarchy.

When Talos is running in a non-container mode, it is always at the root of the cgroup hierarchy.

This package provides a transparent way to handle nested cgroups by providing a Path() function which returns the correct cgroup path based on the cgroup hierarchy available.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitRoot

func InitRoot() error

InitRoot initializes the root cgroup path.

This function should be called once at the beginning of the program, after the cgroup filesystem is mounted.

This function only supports cgroupv2 nesting.

func MillicoresToCPUWeight added in v1.8.0

func MillicoresToCPUWeight(requested MilliCores) uint64

MillicoresToCPUWeight converts milli-cores to CPU weight.

It limits millicores to available CPU cores.

func Path

func Path(cgroupPath string) string

Path returns the path to the cgroup.

This function handles the case when the cgroups are nested.

func Root

func Root() string

Root returns the root cgroup path.

func SharesToCPUWeight added in v1.8.0

func SharesToCPUWeight(shares CPUShare) uint64

SharesToCPUWeight converts CPU shares to CPU weight.

Types

type CPUShare added in v1.8.0

type CPUShare uint64

CPUShare represents a CPU share value.

func MilliCoresToShares added in v1.8.0

func MilliCoresToShares(milliCores MilliCores) CPUShare

MilliCoresToShares converts milli-cores to CPU shares.

type MilliCores added in v1.8.0

type MilliCores uint

MilliCores represents a CPU value in milli-cores.

func AvailableMilliCores added in v1.8.0

func AvailableMilliCores() MilliCores

AvailableMilliCores returns the number of available CPU cores in milli-cores.

Jump to

Keyboard shortcuts

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