subsystems

package
v0.0.0-...-ae7f4bf Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type CpuSubsystem

type CpuSubsystem struct {
}

func (*CpuSubsystem) Apply

func (s *CpuSubsystem) Apply(cgroupPath string, pid int, res *ResourceConfig) error

func (*CpuSubsystem) CgroupFileName

func (s *CpuSubsystem) CgroupFileName() string

func (*CpuSubsystem) Name

func (s *CpuSubsystem) Name() string

func (*CpuSubsystem) Remove

func (s *CpuSubsystem) Remove(cgroupPath string) error

func (*CpuSubsystem) Set

func (s *CpuSubsystem) Set(cgroupPath string, res *ResourceConfig) error

type CpusetSubsystem

type CpusetSubsystem struct {
}

func (*CpusetSubsystem) Apply

func (s *CpusetSubsystem) Apply(cgroupPath string, pid int, res *ResourceConfig) error

func (*CpusetSubsystem) CgroupFileName

func (s *CpusetSubsystem) CgroupFileName() string

func (*CpusetSubsystem) Name

func (s *CpusetSubsystem) Name() string

func (*CpusetSubsystem) Remove

func (s *CpusetSubsystem) Remove(cgroupPath string) error

func (*CpusetSubsystem) Set

func (s *CpusetSubsystem) Set(cgroupPath string, res *ResourceConfig) error

type MemorySubsystem

type MemorySubsystem struct {
}

func (*MemorySubsystem) Apply

func (s *MemorySubsystem) Apply(cgroupPath string, pid int, res *ResourceConfig) error

func (*MemorySubsystem) CgroupFileName

func (s *MemorySubsystem) CgroupFileName() string

func (*MemorySubsystem) Name

func (s *MemorySubsystem) Name() string

func (*MemorySubsystem) Remove

func (s *MemorySubsystem) Remove(cgroupPath string) error

func (*MemorySubsystem) Set

func (s *MemorySubsystem) Set(cgroupPath string, res *ResourceConfig) error

type ResourceConfig

type ResourceConfig struct {
	MemoryLimit string
	CpuShare    string
	CpuSet      string
}

ResourceConfig 用于传递资源限制配置的结构体,包含内存限制,CPU 时间片权重,CPU核心数

type Subsystem

type Subsystem interface {
	// Name 返回子系统的名称,如cpu、memory
	Name() string
	// Set 设置某个cgroup在这个子系统的资源限制
	Set(cgroupPath string, res *ResourceConfig) error
	// Apply 将进程添加到某个cgroup中
	Apply(cgroupPath string, pid int, res *ResourceConfig) error
	// Remove 移除某个cgroup
	Remove(cgroupPath string) error
	// CgroupFileName 返回控制子系统资源的cgroup文件名
	CgroupFileName() string
}

Subsystem 接口,每个Subsystem可以实现下面的4个接口, 这里将cgroup抽象成了path,原因是cgroup在hierarchy的路径,便是虚拟文件系统中的虚拟路径

Jump to

Keyboard shortcuts

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