Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 86ba98b

Browse files
committed
Merge pull request #4 from crosbymichael/cgroup-enter
Cleanup systemd cgroup code
2 parents 97de9a4 + 781855b commit 86ba98b

File tree

3 files changed

+112
-206
lines changed

3 files changed

+112
-206
lines changed

cgroups/fs/cpuset.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,10 @@ func (s *CpusetGroup) Set(d *data) error {
2020
if err != nil {
2121
return err
2222
}
23-
if err := s.ensureParent(dir); err != nil {
24-
return err
25-
}
2623

27-
// because we are not using d.join we need to place the pid into the procs file
28-
// unlike the other subsystems
29-
if err := writeFile(dir, "cgroup.procs", strconv.Itoa(d.pid)); err != nil {
30-
return err
31-
}
32-
if err := writeFile(dir, "cpuset.cpus", d.c.CpusetCpus); err != nil {
33-
return err
34-
}
24+
return s.SetDir(dir, d.c.CpusetCpus, d.pid)
3525
}
26+
3627
return nil
3728
}
3829

@@ -44,6 +35,24 @@ func (s *CpusetGroup) GetStats(path string, stats *cgroups.Stats) error {
4435
return nil
4536
}
4637

38+
func (s *CpusetGroup) SetDir(dir, value string, pid int) error {
39+
if err := s.ensureParent(dir); err != nil {
40+
return err
41+
}
42+
43+
// because we are not using d.join we need to place the pid into the procs file
44+
// unlike the other subsystems
45+
if err := writeFile(dir, "cgroup.procs", strconv.Itoa(pid)); err != nil {
46+
return err
47+
}
48+
49+
if err := writeFile(dir, "cpuset.cpus", value); err != nil {
50+
return err
51+
}
52+
53+
return nil
54+
}
55+
4756
func (s *CpusetGroup) getSubsystemSettings(parent string) (cpus []byte, mems []byte, err error) {
4857
if cpus, err = ioutil.ReadFile(filepath.Join(parent, "cpuset.cpus")); err != nil {
4958
return

0 commit comments

Comments
 (0)