Skip to content

cgroups/fs2: make removeCgroupPath faster#2437

Merged
AkihiroSuda merged 2 commits into
opencontainers:masterfrom
kolyshkin:remove-faster
May 29, 2020
Merged

cgroups/fs2: make removeCgroupPath faster#2437
AkihiroSuda merged 2 commits into
opencontainers:masterfrom
kolyshkin:remove-faster

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

@kolyshkin kolyshkin commented May 28, 2020

  1. In case there are no sub-cgroups (which is probably a common case), a single rmdir should be faster than iterating through the list of files (as suggested at remove cgroup path recursively in cgroup v2 #2412 (comment))

  2. Use unix.Rmdir() to save one more syscall since os.Remove() tries unlink(2) first which fails on a directory, and only then tries rmdir(2).

  3. Re-use rmdir in the second remove attempt.

And some test case fixups:

  1. __runc does not set $status, so the check is misleading.

  2. Add set +eux to the nest.sh script so we can error out early, and see
    what is going on.

  3. Doing "echo +io" > cgroup.controllers is giving an error on my
    machine ("sh: write error: Operation not supported"). It is probably
    fine to just enable pids controller.

  4. Add status check for runc exec nest.sh

  5. Remove the second check for cgroup.threads contents -- it was already
    checked earlier (the output of nest.sh script).

@lifubang PTAL

kolyshkin added 2 commits May 28, 2020 11:15
1. In cases there are no sub-cgroups, a single rmdir should be faster
than iterating through the list of files.

2. Use unix.Rmdir() to save one more syscall since os.Remove() tries
unlink(2) first which fails on a directory, and only then tries
rmdir(2).

3. Re-use rmdir.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1. __runc does not set $status, so the check is misleading.

2. Add set +eux to the nest.sh script so we can error out early, and see
   what is going on.

3. Doing "echo +io" > cgroup.controllers is giving an error on my
   machine ("sh: write error: Operation not supported"). It is probably
   fine to just enable pids controller.

4. Add status check for runc exec nest.sh

5. Remove the second check for cgroup.threads contents -- it was already
   checked earlier (the output of nest.sh script).

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

@shadow90210 shadow90210 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete all

@mrunalp
Copy link
Copy Markdown
Contributor

mrunalp commented May 28, 2020

LGTM

Approved with PullApprove

Copy link
Copy Markdown
Member

@lifubang lifubang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@AkihiroSuda
Copy link
Copy Markdown
Member

AkihiroSuda commented May 29, 2020

LGTM

Approved with PullApprove

@AkihiroSuda AkihiroSuda merged commit 64dbdb8 into opencontainers:master May 29, 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.

5 participants