Bläddra i källkod

pkg/sysinfo.applyPIDSCgroupInfo: optimize

For some reason, commit 69cf03700fed7 chose not to use information
already fetched, and called cgroups.FindCgroupMountpoint() instead.
This is not a cheap call, as it has to parse the whole nine yards
of /proc/self/mountinfo, and the info which it tries to get (whether
the pids controller is present) is already available from cgMounts map.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Kir Kolyshkin 5 år sedan
förälder
incheckning
f02a53d6b9
1 ändrade filer med 4 tillägg och 4 borttagningar
  1. 4 4
      pkg/sysinfo/sysinfo_linux.go

+ 4 - 4
pkg/sysinfo/sysinfo_linux.go

@@ -239,11 +239,11 @@ func applyCPUSetCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
 }
 
 // applyPIDSCgroupInfo reads the pids information from the pids cgroup mount point.
-func applyPIDSCgroupInfo(info *SysInfo, _ map[string]string) []string {
+func applyPIDSCgroupInfo(info *SysInfo, cgMounts map[string]string) []string {
 	var warnings []string
-	_, err := cgroups.FindCgroupMountpoint("", "pids")
-	if err != nil {
-		warnings = append(warnings, err.Error())
+	_, ok := cgMounts["pids"]
+	if !ok {
+		warnings = append(warnings, "Unable to find pids cgroup in mounts")
 		return warnings
 	}
 	info.PidsLimit = true