From f02a53d6b9808c87b05f93b586fc5a1441bd64cb Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 19 May 2020 16:46:44 -0700 Subject: [PATCH] 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 --- pkg/sysinfo/sysinfo_linux.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/sysinfo/sysinfo_linux.go b/pkg/sysinfo/sysinfo_linux.go index 9fe2d68d16..b21b7e9149 100644 --- a/pkg/sysinfo/sysinfo_linux.go +++ b/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