mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
264dc8a46b
Docker-DCO-1.1-Signed-off-by: Rohit Jnagal <jnagal@google.com> (github: rjnagal)
43 lines
957 B
Go
43 lines
957 B
Go
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
|
|
}
|
|
}
|
|
if d.c.CpuPeriod != 0 {
|
|
if err := writeFile(dir, "cpu.cfs_period_us", strconv.FormatInt(d.c.CpuPeriod, 10)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if d.c.CpuQuota != 0 {
|
|
if err := writeFile(dir, "cpu.cfs_quota_us", strconv.FormatInt(d.c.CpuQuota, 10)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (s *cpuGroup) Remove(d *data) error {
|
|
return removePath(d.path("cpu"))
|
|
}
|
|
|
|
func (s *cpuGroup) Stats(d *data) (map[string]float64, error) {
|
|
// we can reuse the cpuacct subsystem to get the cpu stats
|
|
sys := subsystems["cpuacct"]
|
|
return sys.Stats(d)
|
|
}
|