Este contenido no está disponible en el idioma seleccionado.
3.12. Common Tunable Parameters
The following parameters are present in every created cgroup, regardless of the subsystem that the cgroup is using:
- tasks
- contains a list of processes, represented by their PIDs, that are running in a cgroup. The list of PIDs is not guaranteed to be ordered or unique (that is, it may contain duplicate entries). Writing a PID into the
tasksfile of a cgroup moves that process into that cgroup. - cgroup.procs
- contains a list of thread groups, represented by their TGIDs, that are running in a cgroup. The list of TGIDs is not guaranteed to be ordered or unique (that is, it may contain duplicate entries). Writing a TGID into the
cgroup.procsfile of a cgroup moves that thread group into that cgroup. - cgroup.event_control
- along with the cgroup notification API, allows notifications to be sent about a changing status of a cgroup.
- notify_on_release
- contains a Boolean value,
1or0, that either enables or disables the execution of the release agent. If thenotify_on_releaseparameter is enabled, the kernel executes the contents of therelease_agentfile when a cgroup no longer contains any tasks (that is, the cgroup'stasksfile contained some PIDs and those PIDs were removed, leaving the file empty). A path to the empty cgroup is provided as an argument to the release agent.The default value of thenotify_on_releaseparameter in the root cgroup is0. All non-root cgroups inherit the value innotify_on_releasefrom their parent cgroup. - release_agent (present in the root cgroup only)
- contains a command to be executed when a “notify on release” is triggered. Once a cgroup is emptied of all processes, and the
notify_on_releaseflag is enabled, the kernel runs the command in therelease_agentfile and supplies it with a relative path (relative to the root cgroup) to the emptied cgroup as an argument. The release agent can be used, for example, to automatically remove empty cgroups; for more information, see Example 3.4, “Automatically removing empty cgroups”.Example 3.4. Automatically removing empty cgroups
Follow these steps to configure automatic removal of any emptied cgroup from thecpucgroup:- Create a shell script that removes empty
cpucgroups, place it in, for example,/usr/local/bin, and make it executable.~]# cat /usr/local/bin/remove-empty-cpu-cgroup.sh #!/bin/sh rmdir /cgroup/cpu/$1 ~]# chmod +x /usr/local/bin/remove-empty-cpu-cgroup.sh
~]# cat /usr/local/bin/remove-empty-cpu-cgroup.sh #!/bin/sh rmdir /cgroup/cpu/$1 ~]# chmod +x /usr/local/bin/remove-empty-cpu-cgroup.shCopy to Clipboard Copied! Toggle word wrap Toggle overflow The$1variable contains a relative path to the emptied cgroup. - In the
cpucgroup, enable thenotify_on_releaseflag:echo 1 > /cgroup/cpu/notify_on_release
~]# echo 1 > /cgroup/cpu/notify_on_releaseCopy to Clipboard Copied! Toggle word wrap Toggle overflow - In the
cpucgroup, specify a release agent to be used:echo "/usr/local/bin/remove-empty-cpu-cgroup.sh" > /cgroup/cpu/release_agent
~]# echo "/usr/local/bin/remove-empty-cpu-cgroup.sh" > /cgroup/cpu/release_agentCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Test your configuration to make sure emptied cgroups are properly removed:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow