Documentation ¶
Index ¶
- Constants
- func BlkioLimitSet(pathInSubSystem string, writeKiBps, readKiBps map[string]uint64)
- func CPUChildOfflineSet(pathInSubSystem string, enable bool) error
- func CPUOfflineLimit(cpuLimitNum int, minPercent int) error
- func CPUOfflineSet(pathInSubSystem string, enable bool) error
- func CPUOfflineSetShares(pathInSubSystem string, value string) error
- func CPUOfflineSupported() bool
- func CPUOfflineUsage(cgroupPath string) (uint64, error)
- func ChooseNumaCores(totalCores []int, chosenNum int) (chosen []int, left []int)
- func EnsureCgroupPath(pathInRoot string) error
- func EnsureCpuSetCores(pathInRoot string) error
- func GenerateTheadSiblings() error
- func GetCPUTotalUsage(pathInCgroup string) (uint64, error)
- func GetCgroupsByPid(pid int) (map[string]string, error)
- func GetCpuSet(pathInRoot string, needParse bool) ([]string, error)
- func GetCpuSetPids(pathInRoot string) ([]int, error)
- func GetFreezerPids(pathInRoot string) ([]int, error)
- func GetMemoryCgroupPath(pathInCgroup string) string
- func GetMemoryLimit(pathInRoot string) (limitValue int, limited bool, err error)
- func GetMemoryMoveImmigrate(pathInRoot string) (string, error)
- func GetMemoryUsage(pathInRoot string) (usageValue int, err error)
- func GetPerfEventCgroupPath(pathInCgroup string) (string, error)
- func GetPids(fullCgPath string) ([]int, error)
- func GetRoot() string
- func MemoryForceEmpty(pathInRoot string) (dropSupported bool, err error)
- func MovePids(subsystems []string, sourePath, targetPath string) ([]int, error)
- func MoveSpecificPids(subsystems []string, pids []int, targetPath string) error
- func SetBlkioWeight(pathInSubSystem string, deviceNames []string) error
- func SetCPUShares(pathInCgroup string, value uint64) error
- func SetCpuQuota(pathInCgroup string, cores float64) error
- func SetMemoryLimit(pathInRoot string, value int64) error
- func SetMemoryMoveImmigrate(pathInRoot, value string) error
- func WriteCpuSetCores(pathInRoot string, cores []int) error
- func WriteCpuSetCoresStr(pathInRoot string, coresStr string) error
- func WriteFile(data []byte, cgroupPath, cgroupFile string) error
Constants ¶
const ( BlkioSubsystem = "blkio" ReadThrottleFile = "blkio.throttle.read_bps_device" WriteThrottleFile = "blkio.throttle.write_bps_device" )
const ( MemorySubsystem = "memory" // "3" indicate moving both anonymous and file pages when moving pid list MemoryMoveImmigrateAnonymousAndFilePages = "3" )
const (
CPUSubsystem = "cpu"
)
const (
CpuSetSubsystem = "cpuset"
)
const (
DevicesSubsystem = "devices"
)
const (
PerfEventSubsystem = "perf_event"
)
Variables ¶
This section is empty.
Functions ¶
func BlkioLimitSet ¶
BlkioLimitSet set blkio readKiBps, writeKiBps limit of given cgroup path
func CPUChildOfflineSet ¶
CPUChildOfflineSet set offline feature for children cgroups
func CPUOfflineLimit ¶
CPUOfflineLimit limit offline task running on limited cores
func CPUOfflineSet ¶
CPUOfflineSet enable /sys/fs/cgroup/cpu,cpuacct/xx/cpu.offline
func CPUOfflineSetShares ¶
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 ¶
CPUOfflineUsage get cpu usage for offline cgroup
func ChooseNumaCores ¶
ChooseNumaCores will choose number cores from total cores based on NUMA struct
func EnsureCgroupPath ¶
EnsureCgroupPath check if cgroup path existed
func EnsureCpuSetCores ¶
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 ¶
GetCPUTotalUsage get cpu usage for cgroup
func GetCgroupsByPid ¶
GetCgroupsByPid parses /proc/<pid>/cgroup file into a map of subgroups to cgroup names.
func GetCpuSetPids ¶
GetCpuSetPids will get pids from "cgroup.procs"
func GetFreezerPids ¶
GetFreezerPids will get pids from "cgroup.procs"
func GetMemoryCgroupPath ¶
GetMemoryCgroupPath return memory cgroup path
func GetMemoryLimit ¶
GetMemoryLimit return memory cgroup limit value
func GetMemoryMoveImmigrate ¶
GetMemoryMoveImmigrate get memory.move_charge_at_immigrate value for the memory cgroup
func GetMemoryUsage ¶
GetMemoryUsage return memory current usage value
func GetPerfEventCgroupPath ¶
GetPerfEventCgroupPath return perf_event cgroup path
func MemoryForceEmpty ¶
MemoryForceEmpty drop cache for cgroup level
func MoveSpecificPids ¶
MoveSpecificPids moves specific pids to target cgroup path with assigned subsystem
func SetBlkioWeight ¶
SetBlkioWeight sets blkio weight for the given deviceNames and cgroups
func SetCPUShares ¶
SetCPUShares set cpu.shares for cgroup
func SetCpuQuota ¶
SetCpuQuota set cpu.cfs_quota_us for cgroup
func SetMemoryLimit ¶
SetMemoryLimit set memory limit
func SetMemoryMoveImmigrate ¶
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 ¶
WriteCpuSetCores write cores to "cpuset.cpus"
func WriteCpuSetCoresStr ¶
WriteCpuSetCoresStr write cores in string format to "cpuset.cpus"
Types ¶
This section is empty.