Home > front end >  Does each process have its own cgroup?
Does each process have its own cgroup?

Time:12-27

I have tried to understand how cgroups work in linux and read this: https://man7.org/linux/man-pages/man7/cgroups.7.html.

In the manual, it says the following :

A cgroup is a collection of processes that are bound to a set of limits or parameters defined via the cgroup filesystem.

Is it right to say that each process receives its own cgroup and that additional processes are added to that cgroup only if they are child processes of the first one ?

For example, we start the system with INIT, which gets the PID of 1 and from then on, we add new child processes related to INIT and each of these processes themselves can have child processes and so on. Does each new process receive its own cgroup that is related to the limit of its parent's process cgroup and each time a new process that gets a cgroup and creates a child process, that child process will again receive its own cgroup while being related to its parent's cgroup and the limits of the resources are set by the subsystems available in the distribution in use ?

CodePudding user response:

No, per default each process is started in the current cgroup. You have to explicitly create a new cgroup if you want a process to have a distinct cgroup from the parent. Systemd does this with each service, for examgle. This is also how Docker and LXC works. Each containers in explicit, new cgroup.

This is a comprehensive overview:

  • Related