Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libct/cgroup: rm GetClosestMountpointAncestor using moby/sys/mountinfo parser #2401

Merged
merged 2 commits into from
May 18, 2020

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented May 14, 2020

The function GetClosestMountpointAncestor is not very efficient,
does not really belong to cgroup package, and is only used once
(from fs/cpuset.go).

The removal is done in two stages/commits:

1

Prepare to remove it by replacing with the implementation based on
the github.com/moby/sys/mountinfo parser.

This commit is here to make sure the proposed replacement passes the
unit test.

Funny, but the unit test need to be slightly modified since it
supplies the wrong mountinfo (space as the first character, empty line
at the end).

Validated by

 $ go test -v -run Ance
 === RUN   TestGetClosestMountpointAncestor
 --- PASS: TestGetClosestMountpointAncestor (0.00s)
 PASS
 ok  	github.com/opencontainers/runc/libcontainer/cgroups	0.002s

2

Actually remove GetClosestMountpointAncestor, move the replacement
code to libcontainer/cgroups/fs/cpuset.go.

This function is not very efficient, does not really belong to cgroup
package, and is only used once (from fs/cpuset.go).

Prepare to remove it by replacing with the implementation based on
the parser from github.com/moby/sys/mountinfo parser.

This commit is here to make sure the proposed replacement passes the
unit test.

Funny, but the unit test need to be slightly modified since it
supplies the wrong mountinfo (space as the first character, empty line
at the end).

Validated by

 $ go test -v -run Ance
 === RUN   TestGetClosestMountpointAncestor
 --- PASS: TestGetClosestMountpointAncestor (0.00s)
 PASS
 ok  	github.com/opencontainers/runc/libcontainer/cgroups	0.002s

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
The function GetClosestMountpointAncestor is not very efficient,
does not really belong to cgroup package, and is only used once
(from fs/cpuset.go).

Remove it, replacing with the implementation based on moby/sys/mountinfo
parser.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Contributor Author

OK, CI passed, adding the second commit

@AkihiroSuda AkihiroSuda added the kind/refactor refactoring label May 14, 2020
@kolyshkin kolyshkin marked this pull request as ready for review May 14, 2020 23:37
@kolyshkin
Copy link
Contributor Author

I quickly checked Docker and libpod sources -- this function is not used in there.

@kolyshkin
Copy link
Contributor Author

@AkihiroSuda @mrunalp PTAL

@AkihiroSuda
Copy link
Member

AkihiroSuda commented May 16, 2020

LGTM, but I guess we may eventually move back the function to libct/cg .

Approved with PullApprove

@kolyshkin
Copy link
Contributor Author

I guess we may eventually move back the function to libct/cg

There is no need to mess with mountinfo for cgroup v2 case, and I don't think we'll make any major changes to cgroup v1 (except I'm still tinkering with how to decrease the ridiculous number of times we parse /proc/self/mountinfo).

@mrunalp
Copy link
Contributor

mrunalp commented May 18, 2020

LGTM

Approved with PullApprove

@mrunalp mrunalp merged commit 53a4649 into opencontainers:master May 18, 2020
AkihiroSuda added a commit to AkihiroSuda/runc that referenced this pull request May 19, 2020
The compilation error had ocurred because of a bad rebase during opencontainers#2401 and opencontainers#2413

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/refactor refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants