cgrouputils

package
v0.3.9-9 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

View Source
const (
	CGROUP_PATH_SYSFS = "/sys/fs/cgroup"
	CGROUP_PATH_ROOT  = "/cgroup"
	CGROUP_TASKS      = "tasks"
)
View Source
const (
	CgroupsSharesWeight = 1024
	CPU_SHARES          = "cpu.shares"
)
View Source
const (
	IoWeightBase    = 100
	IoWeightMax     = 1000
	IoWeightMin     = 100
	BLOCK_IO_WEIGHT = "blkio.weight"

	BLOCK_IO_BFQ_WEIGHT = "blkio.bfq.weight"

	IOSCHED_CFQ = "cfq"
	IOSCHED_BFQ = "bfq"
)
View Source
const (
	CPUSET_CPUS               = "cpuset.cpus"
	CPUSET_MEMS               = "cpuset.mems"
	CPUSET_SCHED_LOAD_BALANCE = "cpuset.sched_load_balance"
)
View Source
const (
	MAX_HISTORY_UTIL_COUNT = 5
)
View Source
const (
	MEMORY_SWAPPINESS = "memory.swappiness"
)

Variables

View Source
var (
	/*
	 * A global IoScheduler variable, should be set before initialize CGROUP
	 */
	IoScheduler string
)

Functions

func Average

func Average(arr []float64) float64

func CgroupCleanAll

func CgroupCleanAll()

func CgroupDestroy

func CgroupDestroy(pid, name string) bool

func CgroupIoHardlimitSet

func CgroupIoHardlimitSet(
	pid, name string, coreNum int,
	params map[string]int, devId string,
) bool

func CgroupIsMounted

func CgroupIsMounted() bool

func CgroupSet

func CgroupSet(pid, name string, coreNum int) bool

func CleanupNonexistPids

func CleanupNonexistPids(module string)

cleanup

func CommitProcessCpuset

func CommitProcessCpuset(proc *ProcessCPUinfo, idx int)

func CommitProcessesCpuset

func CommitProcessesCpuset(cpus []CPULoad)

func FetchHistoryUtil

func FetchHistoryUtil() map[string][]float64

func GetAllPids

func GetAllPids() ([]string, error)

func GetMaxLoadDiff

func GetMaxLoadDiff(cpus []CPULoad) float64

func GetProcessWeight

func GetProcessWeight(share *float64, util float64) float64

func GetRootParam

func GetRootParam(module, name, pid string) string

func GetTaskParamPath

func GetTaskParamPath(module, name, pid string) string

func Init

func Init(ioScheduler string) bool

func ModuleIsMounted

func ModuleIsMounted(module string) bool

func ParseCpusetStr

func ParseCpusetStr(cpuset string) string

func RebalanceProcesses

func RebalanceProcesses(pids []string)

func RootTaskPath

func RootTaskPath(module string) string

func SaveHistoryUtil

func SaveHistoryUtil()

func SetRootParam

func SetRootParam(module, name, value, pid string) bool

Types

type CGroupCPUSetTask

type CGroupCPUSetTask struct {
	*CGroupTask
	// contains filtered or unexported fields
}

func NewCGroupCPUSetTask

func NewCGroupCPUSetTask(pid, name string, coreNum int, cpuset string) CGroupCPUSetTask

func (*CGroupCPUSetTask) CustomConfig

func (c *CGroupCPUSetTask) CustomConfig(key, value string) bool

func (*CGroupCPUSetTask) GetConfig

func (c *CGroupCPUSetTask) GetConfig() map[string]string

func (*CGroupCPUSetTask) GetStaticConfig

func (c *CGroupCPUSetTask) GetStaticConfig() map[string]string

func (*CGroupCPUSetTask) Module

func (c *CGroupCPUSetTask) Module() string

type CGroupCPUTask

type CGroupCPUTask struct {
	*CGroupTask
}

func NewCGroupCPUTask

func NewCGroupCPUTask(pid, name string, coreNum int) CGroupCPUTask

func (*CGroupCPUTask) GetConfig

func (c *CGroupCPUTask) GetConfig() map[string]string

func (*CGroupCPUTask) Module

func (c *CGroupCPUTask) Module() string

type CGroupIOHardlimitTask

type CGroupIOHardlimitTask struct {
	*CGroupIOTask
	// contains filtered or unexported fields
}

func NewCGroupIOHardlimitTask

func NewCGroupIOHardlimitTask(pid, name string, coreNum int, params map[string]int, devId string) *CGroupIOHardlimitTask

func (*CGroupIOHardlimitTask) GetConfig

func (c *CGroupIOHardlimitTask) GetConfig() map[string]string

type CGroupIOTask

type CGroupIOTask struct {
	*CGroupTask
}

func NewCGroupIOTask

func NewCGroupIOTask(pid, name string, coreNum int) *CGroupIOTask

func (*CGroupIOTask) GetConfig

func (c *CGroupIOTask) GetConfig() map[string]string

func (*CGroupIOTask) Module

func (c *CGroupIOTask) Module() string

type CGroupMemoryTask

type CGroupMemoryTask struct {
	*CGroupTask
}

func NewCGroupMemoryTask

func NewCGroupMemoryTask(pid, name string, coreNum int) *CGroupMemoryTask

func (*CGroupMemoryTask) GetConfig

func (c *CGroupMemoryTask) GetConfig() map[string]string

func (*CGroupMemoryTask) Module

func (c *CGroupMemoryTask) Module() string

type CGroupTask

type CGroupTask struct {
	// contains filtered or unexported fields
}

func NewCGroupTask

func NewCGroupTask(pid, name string, coreNum int) *CGroupTask

func (*CGroupTask) Configure

func (c *CGroupTask) Configure() bool

func (*CGroupTask) GetConfig

func (c *CGroupTask) GetConfig() map[string]string

func (*CGroupTask) GetParam

func (c *CGroupTask) GetParam(name string) string

func (*CGroupTask) GetStaticConfig

func (c *CGroupTask) GetStaticConfig() map[string]string

func (*CGroupTask) GetTaskIds

func (c *CGroupTask) GetTaskIds() []string

func (*CGroupTask) GetWeight

func (c *CGroupTask) GetWeight() float64

func (*CGroupTask) GroupName

func (c *CGroupTask) GroupName() string

func (*CGroupTask) InitTask

func (c *CGroupTask) InitTask(hand ICGroupTask, coreNum int, pid, name string)

func (*CGroupTask) Module

func (c *CGroupTask) Module() string

func (*CGroupTask) MoveTasksToRoot

func (c *CGroupTask) MoveTasksToRoot()

func (*CGroupTask) PushPid

func (c *CGroupTask) PushPid(pid string, isRoot bool)

func (*CGroupTask) RemoveTask

func (c *CGroupTask) RemoveTask() bool

func (*CGroupTask) SetHand

func (c *CGroupTask) SetHand(hand ICGroupTask)

func (*CGroupTask) SetName

func (c *CGroupTask) SetName(name string)

func (*CGroupTask) SetParam

func (c *CGroupTask) SetParam(name, value string) bool

func (*CGroupTask) SetParams

func (c *CGroupTask) SetParams(conf map[string]string) bool

func (*CGroupTask) SetPid

func (c *CGroupTask) SetPid(pid string)

func (*CGroupTask) SetTask

func (c *CGroupTask) SetTask() bool

func (*CGroupTask) SetWeight

func (c *CGroupTask) SetWeight(coreNum int)

func (*CGroupTask) TaskPath

func (c *CGroupTask) TaskPath() string

type CPU

type CPU struct {
	DieList []*CPUDie
}

func GetSystemCpu

func GetSystemCpu() (*CPU, error)

func NewCPU

func NewCPU() (*CPU, error)

func (*CPU) AddCore

func (c *CPU) AddCore(core *CPUCore)

func (*CPU) GetCpuset

func (c *CPU) GetCpuset(idx int) string

func (*CPU) GetPhysicalId

func (c *CPU) GetPhysicalId(cstr string) int

func (*CPU) GetPhysicalNum

func (c *CPU) GetPhysicalNum() int

type CPUCore

type CPUCore struct {
	Index      int
	VendorId   string
	Mhz        float64
	CacheSize  string
	PhysicalId int
	CoreId     int
}

func NewCPUCore

func NewCPUCore(index int) *CPUCore

type CPUDie

type CPUDie struct {
	Index    int
	CoreList []*CPUCore
}

func NewCPUDie

func NewCPUDie(index int) *CPUDie

func (*CPUDie) AddCore

func (d *CPUDie) AddCore(core *CPUCore)

func (*CPUDie) GetCoreStr

func (d *CPUDie) GetCoreStr() string

type CPULoad

type CPULoad struct {
	Processes []*ProcessCPUinfo
}

func ArrangeProcesses

func ArrangeProcesses(infos []*ProcessCPUinfo, cpuCount int) []CPULoad

func GetMinLoadCpu

func GetMinLoadCpu(cpus []CPULoad, cpuset *int) *CPULoad

func (*CPULoad) AddProcess

func (c *CPULoad) AddProcess(proc *ProcessCPUinfo)

func (*CPULoad) GetWeight

func (c *CPULoad) GetWeight() float64

func (*CPULoad) Sort

func (c *CPULoad) Sort()

type ICGroupTask

type ICGroupTask interface {
	InitTask(hand ICGroupTask, coreNum int, pid, name string)
	SetPid(string)
	SetName(string)
	SetWeight(coreNum int)
	SetHand(hand ICGroupTask)

	GetStaticConfig() map[string]string
	GetConfig() map[string]string
	Module() string
	RemoveTask() bool
	SetTask() bool
	Configure() bool
	// contains filtered or unexported methods
}

type ProcessCPUinfo

type ProcessCPUinfo struct {
	Pid    int
	Share  *float64
	Cpuset *int
	Util   float64
	Weight float64
}

func GetProcessesCpuinfo

func GetProcessesCpuinfo(pids []string) ([]*ProcessCPUinfo, error)

func NewProcessCPUinfo

func NewProcessCPUinfo(pid int) (*ProcessCPUinfo, error)

func (*ProcessCPUinfo) String

func (p *ProcessCPUinfo) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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