1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
From: Shengjing Zhu <i@zhsj.me>
Date: Sat, 28 Nov 2020 21:45:38 +0800
Subject: Only append Hugetlb in Subsystems list when available
Forwarded: https://github.com/containerd/cgroups/pull/187
---
subsystem.go | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/subsystem.go b/subsystem.go
index f089ea4..b2f4185 100644
--- a/subsystem.go
+++ b/subsystem.go
@@ -18,6 +18,7 @@ package cgroups
import (
"fmt"
+ "os"
v1 "github.com/containerd/cgroups/stats/v1"
specs "github.com/opencontainers/runtime-spec/specs-go"
@@ -46,7 +47,6 @@ const (
// available on most linux systems
func Subsystems() []Name {
n := []Name{
- Hugetlb,
Freezer,
Pids,
NetCLS,
@@ -62,6 +62,9 @@ func Subsystems() []Name {
if !RunningInUserNS() {
n = append(n, Devices)
}
+ if _, err := os.Stat("/sys/kernel/mm/hugepages"); err == nil {
+ n = append(n, Hugetlb)
+ }
return n
}
|