Check sysinfo for Cpuset cpu.shares and blkio
Carried: #14015 If kernel is compiled with CONFIG_FAIR_GROUP_SCHED disabled cpu.shares doesn't exist. If kernel is compiled with CONFIG_CFQ_GROUP_IOSCHED disabled blkio.weight doesn't exist. If kernel is compiled with CONFIG_CPUSETS disabled cpuset won't be supported. We need to handle these conditions by checking sysinfo and verifying them. Signed-off-by: Zefan Li <lizefan@huawei.com> Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
parent
4c56c9f9ba
commit
3ed5407e61
2 changed files with 53 additions and 0 deletions
|
@ -8,6 +8,8 @@ type SysInfo struct {
|
|||
|
||||
*cgroupMemInfo
|
||||
*cgroupCPUInfo
|
||||
*cgroupBlkioInfo
|
||||
*cgroupCpusetInfo
|
||||
|
||||
// Whether IPv4 forwarding is supported or not, if this was disabled, networking will not work
|
||||
IPv4ForwardingDisabled bool
|
||||
|
@ -37,9 +39,22 @@ type cgroupMemInfo struct {
|
|||
}
|
||||
|
||||
type cgroupCPUInfo struct {
|
||||
// Whether CPU shares is supported or not
|
||||
CPUShares bool
|
||||
|
||||
// Whether CPU CFS(Completely Fair Scheduler) period is supported or not
|
||||
CPUCfsPeriod bool
|
||||
|
||||
// Whether CPU CFS(Completely Fair Scheduler) quota is supported or not
|
||||
CPUCfsQuota bool
|
||||
}
|
||||
|
||||
type cgroupBlkioInfo struct {
|
||||
// Whether Block IO weight is supported or not
|
||||
BlkioWeight bool
|
||||
}
|
||||
|
||||
type cgroupCpusetInfo struct {
|
||||
// Whether Cpuset is supported or not
|
||||
Cpuset bool
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ func New(quiet bool) *SysInfo {
|
|||
sysInfo := &SysInfo{}
|
||||
sysInfo.cgroupMemInfo = checkCgroupMem(quiet)
|
||||
sysInfo.cgroupCPUInfo = checkCgroupCPU(quiet)
|
||||
sysInfo.cgroupBlkioInfo = checkCgroupBlkioInfo(quiet)
|
||||
sysInfo.cgroupCpusetInfo = checkCgroupCpusetInfo(quiet)
|
||||
|
||||
_, err := cgroups.FindCgroupMountpoint("devices")
|
||||
sysInfo.CgroupDevicesEnabled = err == nil
|
||||
|
@ -68,6 +70,11 @@ func checkCgroupCPU(quiet bool) *cgroupCPUInfo {
|
|||
return info
|
||||
}
|
||||
|
||||
info.CPUShares = cgroupEnabled(mountPoint, "cpu.shares")
|
||||
if !quiet && !info.CPUShares {
|
||||
logrus.Warn("Your kernel does not support cgroup cpu shares")
|
||||
}
|
||||
|
||||
info.CPUCfsPeriod = cgroupEnabled(mountPoint, "cpu.cfs_period_us")
|
||||
if !quiet && !info.CPUCfsPeriod {
|
||||
logrus.Warn("Your kernel does not support cgroup cfs period")
|
||||
|
@ -80,6 +87,37 @@ func checkCgroupCPU(quiet bool) *cgroupCPUInfo {
|
|||
return info
|
||||
}
|
||||
|
||||
func checkCgroupBlkioInfo(quiet bool) *cgroupBlkioInfo {
|
||||
info := &cgroupBlkioInfo{}
|
||||
mountPoint, err := cgroups.FindCgroupMountpoint("blkio")
|
||||
if err != nil {
|
||||
if !quiet {
|
||||
logrus.Warn(err)
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
info.BlkioWeight = cgroupEnabled(mountPoint, "blkio.weight")
|
||||
if !quiet && !info.BlkioWeight {
|
||||
logrus.Warn("Your kernel does not support cgroup blkio weight")
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func checkCgroupCpusetInfo(quiet bool) *cgroupCpusetInfo {
|
||||
info := &cgroupCpusetInfo{}
|
||||
_, err := cgroups.FindCgroupMountpoint("cpuset")
|
||||
if err != nil {
|
||||
if !quiet {
|
||||
logrus.Warn(err)
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
info.Cpuset = true
|
||||
return info
|
||||
}
|
||||
|
||||
func cgroupEnabled(mountPoint, name string) bool {
|
||||
_, err := os.Stat(path.Join(mountPoint, name))
|
||||
return err == nil
|
||||
|
|
Loading…
Reference in a new issue