cgroup

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0, BSD-3-Clause, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlkioSubsystem = "blkio"

	ReadThrottleFile  = "blkio.throttle.read_bps_device"
	WriteThrottleFile = "blkio.throttle.write_bps_device"
)
View Source
const (
	MemorySubsystem = "memory"

	// "3" indicate moving both anonymous and file pages when moving pid list
	MemoryMoveImmigrateAnonymousAndFilePages = "3"
)
View Source
const (
	CPUSubsystem = "cpu"
)
View Source
const (
	CpuSetSubsystem = "cpuset"
)
View Source
const (
	DevicesSubsystem = "devices"
)
View Source
const (
	PerfEventSubsystem = "perf_event"
)

Variables

This section is empty.

Functions

func BlkioLimitSet

func BlkioLimitSet(pathInSubSystem string, writeKiBps, readKiBps map[string]uint64)

BlkioLimitSet set blkio readKiBps, writeKiBps limit of given cgroup path

func CPUChildOfflineSet

func CPUChildOfflineSet(pathInSubSystem string, enable bool) error

CPUChildOfflineSet set offline feature for children cgroups

func CPUOfflineLimit

func CPUOfflineLimit(cpuLimitNum int, minPercent int) error

CPUOfflineLimit limit offline task running on limited cores

func CPUOfflineSet

func CPUOfflineSet(pathInSubSystem string, enable bool) error

CPUOfflineSet enable /sys/fs/cgroup/cpu,cpuacct/xx/cpu.offline

func CPUOfflineSetShares

func CPUOfflineSetShares(pathInSubSystem string, value string) error

CPUOfflineSetShares set value to /sys/fs/cgroup/cpu,cpuacct/xx/cpu.bt_shares

func CPUOfflineSupported

func CPUOfflineSupported() bool

CPUOfflineSupported check if offline feature is supported

func CPUOfflineUsage

func CPUOfflineUsage(cgroupPath string) (uint64, error)

CPUOfflineUsage get cpu usage for offline cgroup

func ChooseNumaCores

func ChooseNumaCores(totalCores []int, chosenNum int) (chosen []int, left []int)

ChooseNumaCores will choose number cores from total cores based on NUMA struct

func EnsureCgroupPath

func EnsureCgroupPath(pathInRoot string) error

EnsureCgroupPath check if cgroup path existed

func EnsureCpuSetCores

func EnsureCpuSetCores(pathInRoot string) error

EnsureCpuSetCores will check if the "cpuset.cores" is nil, and assign global cores if is nil.

func GenerateTheadSiblings

func GenerateTheadSiblings() error

GenerateTheadSiblings will parse /proc/cpuinfo, and generate maps, showing which cores are belong to the same thead silbings. The map is nil when HT is disabled on the machine.

func GetCPUTotalUsage

func GetCPUTotalUsage(pathInCgroup string) (uint64, error)

GetCPUTotalUsage get cpu usage for cgroup

func GetCgroupsByPid

func GetCgroupsByPid(pid int) (map[string]string, error)

GetCgroupsByPid parses /proc/<pid>/cgroup file into a map of subgroups to cgroup names.

func GetCpuSet

func GetCpuSet(pathInRoot string, needParse bool) ([]string, error)

GetCpuSet return cores limited for the cgroup, with parsed format or origin value

func GetCpuSetPids

func GetCpuSetPids(pathInRoot string) ([]int, error)

GetCpuSetPids will get pids from "cgroup.procs"

func GetFreezerPids

func GetFreezerPids(pathInRoot string) ([]int, error)

GetFreezerPids will get pids from "cgroup.procs"

func GetMemoryCgroupPath

func GetMemoryCgroupPath(pathInCgroup string) string

GetMemoryCgroupPath return memory cgroup path

func GetMemoryLimit

func GetMemoryLimit(pathInRoot string) (limitValue int, limited bool, err error)

GetMemoryLimit return memory cgroup limit value

func GetMemoryMoveImmigrate

func GetMemoryMoveImmigrate(pathInRoot string) (string, error)

GetMemoryMoveImmigrate get memory.move_charge_at_immigrate value for the memory cgroup

func GetMemoryUsage

func GetMemoryUsage(pathInRoot string) (usageValue int, err error)

GetMemoryUsage return memory current usage value

func GetPerfEventCgroupPath

func GetPerfEventCgroupPath(pathInCgroup string) (string, error)

GetPerfEventCgroupPath return perf_event cgroup path

func GetPids

func GetPids(fullCgPath string) ([]int, error)

GetPids get cgroup pid list

func GetRoot

func GetRoot() string

GetRoot get cgroup root path

func MemoryForceEmpty

func MemoryForceEmpty(pathInRoot string) (dropSupported bool, err error)

MemoryForceEmpty drop cache for cgroup level

func MovePids

func MovePids(subsystems []string, sourePath, targetPath string) ([]int, error)

MovePids move pids of subsystems from source path to target path

func MoveSpecificPids

func MoveSpecificPids(subsystems []string, pids []int, targetPath string) error

MoveSpecificPids moves specific pids to target cgroup path with assigned subsystem

func SetBlkioWeight

func SetBlkioWeight(pathInSubSystem string, deviceNames []string) error

SetBlkioWeight sets blkio weight for the given deviceNames and cgroups

func SetCPUShares

func SetCPUShares(pathInCgroup string, value uint64) error

SetCPUShares set cpu.shares for cgroup

func SetCpuQuota

func SetCpuQuota(pathInCgroup string, cores float64) error

SetCpuQuota set cpu.cfs_quota_us for cgroup

func SetMemoryLimit

func SetMemoryLimit(pathInRoot string, value int64) error

SetMemoryLimit set memory limit

func SetMemoryMoveImmigrate

func SetMemoryMoveImmigrate(pathInRoot, value string) error

SetMemoryMoveImmigrate set memory.move_charge_at_immigrate for the memory cgroup. This file is used to move pages associated with tasks, different values have its owning meaning about what type of pages should be moved, as following:

  • 0: disable moving any pages
  • 1: moving anonymous pages used by the task
  • 2: moving file pages mapped by the task
  • 3: moving both anonymous pages and file pages for the task

func WriteCpuSetCores

func WriteCpuSetCores(pathInRoot string, cores []int) error

WriteCpuSetCores write cores to "cpuset.cpus"

func WriteCpuSetCoresStr

func WriteCpuSetCoresStr(pathInRoot string, coresStr string) error

WriteCpuSetCoresStr write cores in string format to "cpuset.cpus"

func WriteFile

func WriteFile(data []byte, cgroupPath, cgroupFile string) error

WriteFile write value to cgroup file

Types

This section is empty.

Jump to

Keyboard shortcuts

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