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/cgroups/systemd: don't set limits in Apply #2814

Merged
merged 1 commit into from
Feb 23, 2021

Conversation

kolyshkin
Copy link
Contributor

All cgroup managers has Apply() and Set() methods:

  • Apply is used to create a cgroup (and, in case of systemd,
    a systemd unit) and/or put a PID into the cgroup (and unit);

  • Set is used to set various cgroup resources and limits.

The fs/fs2 cgroup manager implements the functionality as described above.

The systemd v1/v2 manager deviate -- it sets most of cgroup limits
(those that can be projected to systemd unit properties) in Apply(),
and then again all cgroup limits in Set (first indirectly via systemd
properties -- same as in Apply, then via cgroupfs).

This commit removes setting the cgroup limits from Apply,
so now the systemd manager behaves the same way as the fs manager.

Fixes: #2813

All cgroup managers has Apply() and Set() methods:

 - Apply is used to create a cgroup (and, in case of systemd,
   a systemd unit) and/or put a PID into the cgroup (and unit);

 - Set is used to set various cgroup resources and limits.

The fs/fs2 cgroup manager implements the functionality as described above.

The systemd v1/v2 manager deviate -- it sets *most* of cgroup limits
(those that can be projected to systemd unit properties) in Apply(),
and then again *all* cgroup limits in Set (first indirectly via systemd
properties -- same as in Apply, then via cgroupfs).

This commit removes setting the cgroup limits from Apply,
so now the systemd manager behaves the same way as the fs manager.

Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin
Copy link
Contributor Author

I wanted to fix it half a year ago but did not quite understand the purpose of Apply and Set at the time.

Copy link
Contributor

@odinuge odinuge left a comment

Choose a reason for hiding this comment

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

/lgtm

I like this difference between Apply and Set! I think the reason for the previous behavior was that the slice/scope was created in Apply, and never updated in Set (only by writing to cgroup, aka. not correct). Now, i think this makes more sense.

@kolyshkin
Copy link
Contributor Author

@AkihiroSuda I would not call this a refactor -- this is a bug fix (#2813), although I agree the bug is kinda subtle.

@kolyshkin kolyshkin removed the kind/refactor refactoring label Feb 22, 2021
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.

Fix discrepancy between systemd and fs cgroup managers
5 participants