2014-04-19 00:55:06 -04:00
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
type cpuGroup struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *cpuGroup) Set(d *data) error {
|
|
|
|
// We always want to join the cpu group, to allow fair cpu scheduling
|
|
|
|
// on a container basis
|
|
|
|
dir, err := d.join("cpu")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if d.c.CpuShares != 0 {
|
|
|
|
if err := writeFile(dir, "cpu.shares", strconv.FormatInt(d.c.CpuShares, 10)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2014-04-19 01:17:31 -04:00
|
|
|
|
|
|
|
func (s *cpuGroup) Remove(d *data) error {
|
|
|
|
return removePath(d.path("cpu"))
|
|
|
|
}
|
2014-04-20 15:02:39 -04:00
|
|
|
|
|
|
|
func (s *cpuGroup) Stats(d *data) (map[string]float64, error) {
|
2014-04-20 21:20:44 -04:00
|
|
|
// we can reuse the cpuacct subsystem to get the cpu stats
|
|
|
|
sys := subsystems["cpuacct"]
|
|
|
|
return sys.Stats(d)
|
2014-04-20 15:02:39 -04:00
|
|
|
}
|