Documentation ¶
Index ¶
- Variables
- func DeviceFilter(devices []specs.LinuxDeviceCgroup) (asm.Instructions, string, error)
- func EnableNesting() error
- func LoadAttachCgroupDeviceFilter(insts asm.Instructions, license string, dirFD int) (func() error, error)
- func VerifyGroupPath(p string) error
- type CGMode
- type CPU
- type CPUMax
- type ControllerToggle
- type Manager
- type Memory
- type Resources
- type Value
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidGroupPath = errors.New("cgroups: invalid group path") ErrInvalidFormat = errors.New("cgroups: parsing file with invalid format failed") )
Functions ¶
func DeviceFilter ¶
func DeviceFilter(devices []specs.LinuxDeviceCgroup) (asm.Instructions, string, error)
func EnableNesting ¶
func EnableNesting() error
EnableV2Nesting migrates all process in the container to nested /init path and enables all available controllers in the root cgroup
func LoadAttachCgroupDeviceFilter ¶
func LoadAttachCgroupDeviceFilter(insts asm.Instructions, license string, dirFD int) (func() error, error)
LoadAttachCgroupDeviceFilter installs eBPF device filter program to /sys/fs/cgroup/<foo> directory.
Requires the system to be running in cgroup2 unified-mode with kernel >= 4.15 .
https://github.com/torvalds/linux/commit/ebc614f687369f9df99828572b1d85a7c2de3d92
func VerifyGroupPath ¶
VerifyGroupPath verifies the format of group path string p. The format is same as the third field in /proc/PID/cgroup. e.g. "/user.slice/user-1001.slice/session-1.scope"
p must be a "clean" absolute path starts with "/", and must not contain "/sys/fs/cgroup" prefix.
VerifyGroupPath doesn't verify whether p actually exists on the system.
Types ¶
type CPU ¶
type CPU struct { Weight *uint64 // Weight is a pointer to a uint64, indicating the CPU weight for relative priority in resource allocation. Max CPUMax // Max represents the maximum CPU quota in the cgroup. Cpus string // Cpus represents the list of available CPU cores in the CPU group. Mems string // Mems represents the list of available memory nodes in the CPU group. }
CPU represents the CPU-related attributes in a cgroup.
type CPUMax ¶
type CPUMax string
CPUMax represents the maximum CPU quota in a cgroup. It is a string type alias used to define the maximum CPU quota, which can be either a numeric value (representing microseconds) or "max" (indicating no limit).
type ControllerToggle ¶
type ControllerToggle int
const ( Enable ControllerToggle = iota + 1 Disable )
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
NewManager new a cgroup, and set resources controllers
func (*Manager) RootControllers ¶
RootControllers read /sys/fs/cgroup/cgroup.controllers content [cpuset cpu io memory pids rdma hugetlb]
func (*Manager) ToggleControllers ¶
func (m *Manager) ToggleControllers(controllers []string, t ControllerToggle) error