From ed4e505639cd9d64da48871ec9630249eda0ac2a Mon Sep 17 00:00:00 2001 From: Ma Shimiao Date: Fri, 12 Jun 2015 08:34:20 +0800 Subject: [PATCH] Add support for blkio.weight_device Signed-off-by: Ma Shimiao --- blkiodev/blkiodev.go | 15 +++++++++++++++ sysinfo/sysinfo.go | 3 +++ sysinfo/sysinfo_linux.go | 14 +++++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 blkiodev/blkiodev.go diff --git a/blkiodev/blkiodev.go b/blkiodev/blkiodev.go new file mode 100644 index 0000000..84cdbd7 --- /dev/null +++ b/blkiodev/blkiodev.go @@ -0,0 +1,15 @@ +package blkiodev + +import ( + "fmt" +) + +// WeightDevice is a structure that hold device:weight pair +type WeightDevice struct { + Path string + Weight uint16 +} + +func (w *WeightDevice) String() string { + return fmt.Sprintf("%s:%d", w.Path, w.Weight) +} diff --git a/sysinfo/sysinfo.go b/sysinfo/sysinfo.go index 851d176..580b6ba 100644 --- a/sysinfo/sysinfo.go +++ b/sysinfo/sysinfo.go @@ -60,6 +60,9 @@ type cgroupCPUInfo struct { type cgroupBlkioInfo struct { // Whether Block IO weight is supported or not BlkioWeight bool + + // Whether Block IO weight_device is supported or not + BlkioWeightDevice bool } type cgroupCpusetInfo struct { diff --git a/sysinfo/sysinfo_linux.go b/sysinfo/sysinfo_linux.go index 0ef3fbd..a93e781 100644 --- a/sysinfo/sysinfo_linux.go +++ b/sysinfo/sysinfo_linux.go @@ -117,11 +117,19 @@ func checkCgroupBlkioInfo(quiet bool) cgroupBlkioInfo { return cgroupBlkioInfo{} } - w := cgroupEnabled(mountPoint, "blkio.weight") - if !quiet && !w { + weight := cgroupEnabled(mountPoint, "blkio.weight") + if !quiet && !weight { logrus.Warn("Your kernel does not support cgroup blkio weight") } - return cgroupBlkioInfo{BlkioWeight: w} + + weightDevice := cgroupEnabled(mountPoint, "blkio.weight_device") + if !quiet && !weightDevice { + logrus.Warn("Your kernel does not support cgroup blkio weight_device") + } + return cgroupBlkioInfo{ + BlkioWeight: weight, + BlkioWeightDevice: weightDevice, + } } // checkCgroupCpusetInfo reads the cpuset information from the cpuset cgroup mount point.