...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package cgroups
17
18 import (
19 "os"
20
21 "github.com/containerd/cgroups"
22 )
23
24
25 func defaults(root string) ([]cgroups.Subsystem, error) {
26 h, err := cgroups.NewHugetlb(root)
27 if err != nil && !os.IsNotExist(err) {
28 return nil, err
29 }
30 s := []cgroups.Subsystem{
31 cgroups.NewNamed(root, "systemd"),
32 cgroups.NewFreezer(root),
33 cgroups.NewPids(root),
34 cgroups.NewNetCls(root),
35 cgroups.NewNetPrio(root),
36 cgroups.NewPerfEvent(root),
37 cgroups.NewCpuset(root),
38 cgroups.NewCpu(root),
39 cgroups.NewCpuacct(root),
40 cgroups.NewMemory(root),
41 cgroups.NewBlkio(root),
42 cgroups.NewRdma(root),
43 }
44
45
46 if !cgroups.RunningInUserNS() {
47 s = append(s, cgroups.NewDevices(root))
48 }
49
50
51 if err == nil {
52 s = append(s, h)
53 }
54 return s, nil
55 }
56
57 type pather interface {
58 cgroups.Subsystem
59 Path(path string) string
60 }
61
62 func pathers(subystems []cgroups.Subsystem) []pather {
63 var out []pather
64 for _, s := range subystems {
65 if p, ok := s.(pather); ok {
66 out = append(out, p)
67 }
68 }
69 return out
70 }
71