|
@@ -1694,51 +1694,32 @@ func setupOOMScoreAdj(score int) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
-func (daemon *Daemon) initCgroupsPath(path string) error {
|
|
|
+func (daemon *Daemon) initCPURtController(mnt, path string) error {
|
|
|
if path == "/" || path == "." {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- if daemon.configStore.CPURealtimePeriod == 0 && daemon.configStore.CPURealtimeRuntime == 0 {
|
|
|
- return nil
|
|
|
- }
|
|
|
-
|
|
|
- if cgroups.IsCgroup2UnifiedMode() {
|
|
|
- return fmt.Errorf("daemon-scoped cpu-rt-period and cpu-rt-runtime are not implemented for cgroup v2")
|
|
|
- }
|
|
|
-
|
|
|
// Recursively create cgroup to ensure that the system and all parent cgroups have values set
|
|
|
// for the period and runtime as this limits what the children can be set to.
|
|
|
- daemon.initCgroupsPath(filepath.Dir(path))
|
|
|
-
|
|
|
- mnt, root, err := cgroups.FindCgroupMountpointAndRoot("", "cpu")
|
|
|
- if err != nil {
|
|
|
+ if err := daemon.initCPURtController(mnt, filepath.Dir(path)); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- // When docker is run inside docker, the root is based of the host cgroup.
|
|
|
- // Should this be handled in runc/libcontainer/cgroups ?
|
|
|
- if strings.HasPrefix(root, "/docker/") {
|
|
|
- root = "/"
|
|
|
- }
|
|
|
|
|
|
- path = filepath.Join(mnt, root, path)
|
|
|
- sysInfo := daemon.RawSysInfo(true)
|
|
|
- if err := maybeCreateCPURealTimeFile(sysInfo.CPURealtime, daemon.configStore.CPURealtimePeriod, "cpu.rt_period_us", path); err != nil {
|
|
|
+ path = filepath.Join(mnt, path)
|
|
|
+ if err := os.MkdirAll(path, 0755); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- return maybeCreateCPURealTimeFile(sysInfo.CPURealtime, daemon.configStore.CPURealtimeRuntime, "cpu.rt_runtime_us", path)
|
|
|
+ if err := maybeCreateCPURealTimeFile(daemon.configStore.CPURealtimePeriod, "cpu.rt_period_us", path); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ return maybeCreateCPURealTimeFile(daemon.configStore.CPURealtimeRuntime, "cpu.rt_runtime_us", path)
|
|
|
}
|
|
|
|
|
|
-func maybeCreateCPURealTimeFile(sysinfoPresent bool, configValue int64, file string, path string) error {
|
|
|
- if sysinfoPresent && configValue != 0 {
|
|
|
- if err := os.MkdirAll(path, 0755); err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- if err := ioutil.WriteFile(filepath.Join(path, file), []byte(strconv.FormatInt(configValue, 10)), 0700); err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
+func maybeCreateCPURealTimeFile(configValue int64, file string, path string) error {
|
|
|
+ if configValue == 0 {
|
|
|
+ return nil
|
|
|
}
|
|
|
- return nil
|
|
|
+ return ioutil.WriteFile(filepath.Join(path, file), []byte(strconv.FormatInt(configValue, 10)), 0700)
|
|
|
}
|
|
|
|
|
|
func (daemon *Daemon) setupSeccompProfile() error {
|