1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

pkg/sysinfo.applyPIDSCgroupInfo: optimize

For some reason, commit 69cf03700f 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>
This commit is contained in:
Kir Kolyshkin 2020-05-19 16:46:44 -07:00
parent 07e6b84359
commit f02a53d6b9

View file

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