Skip to content

Commit 8a68de5

Browse files
authored
Merge pull request #187 from zhsj/fix-hugetlb
Only append Hugetlb in Subsystems list when available
2 parents 4cbc285 + 777a0cb commit 8a68de5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

subsystem.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package cgroups
1818

1919
import (
2020
"fmt"
21+
"os"
2122

2223
v1 "github.com/containerd/cgroups/stats/v1"
2324
specs "github.com/opencontainers/runtime-spec/specs-go"
@@ -46,7 +47,6 @@ const (
4647
// available on most linux systems
4748
func Subsystems() []Name {
4849
n := []Name{
49-
Hugetlb,
5050
Freezer,
5151
Pids,
5252
NetCLS,
@@ -62,6 +62,9 @@ func Subsystems() []Name {
6262
if !RunningInUserNS() {
6363
n = append(n, Devices)
6464
}
65+
if _, err := os.Stat("/sys/kernel/mm/hugepages"); err == nil {
66+
n = append(n, Hugetlb)
67+
}
6568
return n
6669
}
6770

0 commit comments

Comments
 (0)