Skip to content

cgroupv1/FindCgroupMountpoint: add a fast path#2499

Merged
AkihiroSuda merged 1 commit into
opencontainers:masterfrom
kolyshkin:find-cgroup-mountpoint-fastpath
Aug 4, 2020
Merged

cgroupv1/FindCgroupMountpoint: add a fast path#2499
AkihiroSuda merged 1 commit into
opencontainers:masterfrom
kolyshkin:find-cgroup-mountpoint-fastpath

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

this is separated out from #2438 in order to make review easier

In case cgroupPath is under the default cgroup prefix, let's try to
guess the mount point by adding the subsystem name to the default
prefix, and resolving the resulting path in case it's a symlink.

In most cases, given the default cgroup setup, this trick
should result in returning the same result faster, and avoiding
/proc/self/mountinfo parsing which is relatively slow and problematic.

Be very careful with the default path, checking it is

  • a directory;
  • a mount point;
  • has cgroup fstype.

If something is not right, fall back to parsing mountinfo.

While at it, remove the obsoleted comment about mountinfo parsing. The
comment belongs to findCgroupMountpointAndRootFromReader(), but rather
than moving it there, let's just remove it, since it does not add any
value in understanding the current code.

Signed-off-by: Kir Kolyshkin kolyshkin@gmail.com

Comment thread libcontainer/cgroups/v1_utils.go
Comment thread libcontainer/cgroups/v1_utils.go Outdated
In case cgroupPath is under the default cgroup prefix, let's try to
guess the mount point by adding the subsystem name to the default
prefix, and resolving the resulting path in case it's a symlink.

In most cases, given the default cgroup setup, this trick
should result in returning the same result faster, and avoiding
/proc/self/mountinfo parsing which is relatively slow and problematic.

Be very careful with the default path, checking it is
 - a directory;
 - a mount point;
 - has cgroup fstype.

If something is not right, fall back to parsing mountinfo.

While at it, remove the obsoleted comment about mountinfo parsing.  The
comment belongs to findCgroupMountpointAndRootFromReader(), but rather
than moving it there, let's just remove it, since it does not add any
value in understanding the current code.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin force-pushed the find-cgroup-mountpoint-fastpath branch from 18c07e9 to a73ce38 Compare July 7, 2020 20:57
@kolyshkin
Copy link
Copy Markdown
Contributor Author

CI is green but apparently github lost the notification. Restarted travis build.

@kolyshkin
Copy link
Copy Markdown
Contributor Author

@AkihiroSuda @cyphar PTAL

@AkihiroSuda AkihiroSuda merged commit f668854 into opencontainers:master Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants