Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SubsystemIns = []SubSystemer{ &CPUSubsystem{}, &MemorySubSystem{}, }
SubsystemIns subsystem instances
Functions ¶
func FindCgroupMountPoint ¶
FindCgroupMountPoint 通过/proc/self/mountinfo找出挂载了某个subsystem的hierarchy cgroup所在的目录 example: FindCgroupMountPoint("memory") mountinfo: 41 25 0:33 / /sys/fs/cgroup/memory rw,relatime - cgroup cgroup rw,memory
Types ¶
type CPUSetSubSystem ¶
type CPUSetSubSystem struct { }
CPUSetSubSystem .
func (*CPUSetSubSystem) Apply ¶
func (cs *CPUSetSubSystem) Apply(cgroupPath string, pid int) error
Apply 将进程添加到某个cgroup中
func (*CPUSetSubSystem) Name ¶
func (cs *CPUSetSubSystem) Name() string
Name 返回subsystem的名字,比如cpu memory
func (*CPUSetSubSystem) Remove ¶
func (cs *CPUSetSubSystem) Remove(cgroupPath string) error
Remove 移除某个cgroup
func (*CPUSetSubSystem) Set ¶
func (cs *CPUSetSubSystem) Set(cgroupPath string, res *ResourceConfig) error
Set 设置某个cgroup在这个Subsystem中的资源限制
type CPUSubsystem ¶
type CPUSubsystem struct { }
CPUSubsystem .
func (*CPUSubsystem) Apply ¶
func (c *CPUSubsystem) Apply(cgroupPath string, pid int) error
Apply 将进程添加到某个cgroup中
func (*CPUSubsystem) Remove ¶
func (c *CPUSubsystem) Remove(cgroupPath string) error
Remove 移除某个cgroup
func (*CPUSubsystem) Set ¶
func (c *CPUSubsystem) Set(cgroupPath string, res *ResourceConfig) error
Set 设置某个cgroup在这个Subsystem中的资源限制
type MemorySubSystem ¶
type MemorySubSystem struct { }
MemorySubSystem 是 memory subsystem的实现
func (*MemorySubSystem) Apply ¶
func (m *MemorySubSystem) Apply(cgroupPath string, pid int) error
将进程添加到某个cgroup中
func (*MemorySubSystem) Remove ¶
func (m *MemorySubSystem) Remove(cgroupPath string) error
移除某个cgroup
func (*MemorySubSystem) Set ¶
func (m *MemorySubSystem) Set(cgroupPath string, res *ResourceConfig) error
设置某个cgroup在这个Subsystem中的资源限制
type ResourceConfig ¶
ResourceConfig 用于传递资源配置的结构体,包含内存限制,cpu时间片权重,cpu核心数
type SubSystemer ¶
type SubSystemer interface { // 返回subsystem的名字,比如cpu memory Name() string // 设置某个cgroup在这个Subsystem中的资源限制 Set(path string, res *ResourceConfig) error // 将进程添加到某个cgroup中 Apply(path string, pid int) error // 移除某个cgroup Remove(path string) error }
SubSystemer 接口,每个Subsystem可以实现下面4个接口 这里将cgroup抽象成path,原因是cgroup在hierarchy的路径,便是虚拟 文件系统中的虚拟路径