kernel:control_groups
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
kernel:control_groups [2020/07/21 16:50] – old revision restored (2017/04/06 10:33) 91.121.7.147 | kernel:control_groups [2020/07/22 18:05] (current) – old revision restored (2020/07/20 16:09) 207.244.157.10 | ||
---|---|---|---|
Line 131: | Line 131: | ||
===== What does notify_on_release do? ===== | ===== What does notify_on_release do? ===== | ||
- | If the notify_on_release flag is enabled (1) in a cgroup, then whenever the last task in the cgroup leaves (exits or attaches to some other cgroup) and the last child cgroup of that cgroup is removed, then the kernel runs the command specified by the contents of the " | + | If the **notify_on_release** flag is enabled (1) in a cgroup, then whenever the last task in the cgroup leaves (exits or attaches to some other cgroup) and the last child cgroup of that cgroup is removed, then the kernel runs the command specified by the contents of the **" |
===== What does clone_children do? ===== | ===== What does clone_children do? ===== | ||
- | If the clone_children flag is enabled (1) in a cgroup, then all cgroups created beneath will call the post_clone callbacks for each subsystem of the newly created cgroup. Usually when this callback is implemented for a subsystem, it copies the values of the parent subsystem, this is the case for the cpuset. | + | If the **clone_children** flag is enabled (1) in a cgroup, then all cgroups created beneath will call the post_clone callbacks for each subsystem of the newly created cgroup. Usually when this callback is implemented for a subsystem, it copies the values of the parent subsystem, this is the case for the cpuset. |
Line 143: | Line 143: | ||
To start a new job that is to be contained within a cgroup, using the " | To start a new job that is to be contained within a cgroup, using the " | ||
- | | + | - mkdir / |
- | 2) mount -t cgroup -ocpuset cpuset / | + | |
- | 3) Create the new cgroup by doing mkdir' | + | |
- | | + | |
- | 4) Start a task that will be the " | + | |
- | 5) Attach that task to the new cgroup by writing its pid to the | + | |
- | | + | |
- | 6) fork, exec or clone the job tasks from this founding father task. | + | |
For example, the following sequence of commands will setup a cgroup named " | For example, the following sequence of commands will setup a cgroup named " | ||
Line 181: | Line 179: | ||
</ | </ | ||
- | The " | + | The " |
To mount a cgroup hierarchy with just the cpuset and memory subsystems, type: | To mount a cgroup hierarchy with just the cpuset and memory subsystems, type: | ||
Line 214: | Line 212: | ||
Note that changing the set of subsystems is currently only supported when the hierarchy consists of a single (root) cgroup. | Note that changing the set of subsystems is currently only supported when the hierarchy consists of a single (root) cgroup. | ||
- | Then under /dev/cgroup you can find a tree that corresponds to the tree of the cgroups in the system. For instance, /dev/cgroup is the cgroup that holds the whole system. | + | Then under **/dev/cgroup** you can find a tree that corresponds to the tree of the cgroups in the system. For instance, /dev/cgroup is the cgroup that holds the whole system. |
If you want to change the value of release_agent: | If you want to change the value of release_agent: | ||
Line 241: | Line 239: | ||
<code bash> | <code bash> | ||
ls | ls | ||
- | < | + | |
cgroup.procs notify_on_release tasks | cgroup.procs notify_on_release tasks | ||
(plus whatever files added by the attached subsystems) | (plus whatever files added by the attached subsystems) | ||
Line 275: | Line 273: | ||
</ | </ | ||
- | Note that it is PID, not PIDs. You can only attach ONE task at a time. If you have several tasks to attach, you have to do it one after another: | + | <WRAP info> |
+ | **NOTE: | ||
+ | </ | ||
<code bash> | <code bash> | ||
Line 299: | Line 299: | ||
When passing a name=< | When passing a name=< | ||
- | The name of the subsystem appears as part of the hierarchy description in / | + | The name of the subsystem appears as part of the hierarchy description in **/ |
==== Notification API ==== | ==== Notification API ==== | ||
Line 316: | Line 316: | ||
To unregister notification handler just close eventfd. | To unregister notification handler just close eventfd. | ||
- | NOTE: Support of notifications should be implemented for the control file. See documentation for the subsystem. | + | <WRAP info> |
+ | **NOTE**: Support of notifications should be implemented for the control file. See documentation for the subsystem. | ||
+ | </ | ||
===== Kernel API ===== | ===== Kernel API ===== | ||
Line 323: | Line 324: | ||
==== Overview ==== | ==== Overview ==== | ||
- | Each kernel subsystem that wants to hook into the generic cgroup system needs to create a cgroup_subsys object. | + | Each kernel subsystem that wants to hook into the generic cgroup system needs to create a **cgroup_subsys** object. |
Other fields in the cgroup_subsys object include: | Other fields in the cgroup_subsys object include: | ||
Line 336: | Line 337: | ||
==== Synchronization ==== | ==== Synchronization ==== | ||
- | There is a global mutex, cgroup_mutex, | + | There is a global mutex, |
See kernel/ | See kernel/ | ||
- | Subsystems can take/ | + | Subsystems can take/ |
Accessing a task's cgroup pointer may be done in the following ways: | Accessing a task's cgroup pointer may be done in the following ways: |
kernel/control_groups.1595350235.txt.gz · Last modified: 2020/07/21 16:50 by 91.121.7.147