-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
(*initProcess).start: rm second Apply #2446
Conversation
The thing I do not understand is why Apply() is called twice here: runc/libcontainer/process_linux.go Lines 322 to 358 in dbe5aca
Presumably it is to fix #1884, and I might buy into adding the second pid, but can't understand why we need to say create the systemd slice for the second time, set all limits for the second time etc. |
I noticed the double- In fact, unless I'm misunderstanding the code (which is quite possible -- I didn't get much sleep), all of the |
Looks like it is. Trying to remove the second |
Apply() determines and creates cgroup path(s), configures parent cgroups (for some v1 controllers), and creates a systemd unit (in case of a systemd cgroup manager), then adds a pid specified to the cgroup for all configured controllers. This is a relatively heavy procedure (in particular, for cgroups v1 it involves parsing /proc/self/mountinfo about a dozen times), and it seems there is no need to do it twice. More to say, even merely adding the child pid to the same cgroup seems redundant, as we added the parent pid to the cgroup before sending the data to the child (runc init process), and it waits for the data before doing clone(), so its children will be in the same cgroup anyway. Signed-off-by: Kir Kolyshkin <[email protected]>
Hmm, OTOH it was the same was at the time of commit df3fa11, and even at the time of commit 69663f0 (mentioned in #1884) so again I am not sure what am I missing here :( BTW, #1884 (comment) says
So, my current (and rather weak) theory is that the second |
OK, I found out that #1184 was not adding the second |
I read the code through a few times and am pretty confident the second apply is useless. |
@AkihiroSuda @cyphar ptal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the second Allow isn't necessary. As I said, I'm also fairly sure that the CREATECGROUPNS
synchronisation is also unnecessary -- but I'll submit a follow-up PR which removes that.
Commit df3fa11 adds a second call to cgroupManager.Apply() method in
order to add a second pid to the cgroup.
While I admit I don't understand the reason why it was added
(even after reading #1916, #1184, and #1884), it seems that
going through all the steps (configure cgroup parameters, figure
out paths to all controllers, create a systemd unit) twice is excessive
and should not be done.
More to say, even merely adding the child pid to the same cgroup seems
redundant, as we added the parent pid to the cgroup before sending the
data to the child (runc init process), and it waits for the data before
doing clone(), so its children will be in the same cgroup anyway.
Needs a very careful review.