Skip to content

Commit ea5f8e0

Browse files
committed
join the cgroup after the initial setup finished
We should join the cgroup after the initial setup finished, but before runc init clone new children processes. (#4427) Because we should try our best to reduce the influence of memory cgroup accounting from all runc init processes before we start the container init process. Signed-off-by: lifubang <[email protected]> (cherry picked from commit 4f6000e) Signed-off-by: lifubang <[email protected]>
1 parent 0683379 commit ea5f8e0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

libcontainer/process_linux.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,13 @@ func (p *initProcess) start() (retErr error) {
407407
}
408408
}()
409409

410+
// We should join the cgroup after the initial setup finished,
411+
// but before runc init clone new children processes. (#4427)
412+
err = <-waitInit
413+
if err != nil {
414+
return err
415+
}
416+
410417
// Do this before syncing with child so that no children can escape the
411418
// cgroup. We don't need to worry about not doing this and not being root
412419
// because we'd be using the rootless cgroup manager in that case.
@@ -421,10 +428,6 @@ func (p *initProcess) start() (retErr error) {
421428
if _, err := io.Copy(p.messageSockPair.parent, p.bootstrapData); err != nil {
422429
return fmt.Errorf("can't copy bootstrap data to pipe: %w", err)
423430
}
424-
err = <-waitInit
425-
if err != nil {
426-
return err
427-
}
428431

429432
childPid, err := p.getChildPid()
430433
if err != nil {

0 commit comments

Comments
 (0)