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 tasks file 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.procs file 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, 1 or 0, that either enables or disables the execution of the release agent. If the notify_on_release parameter is enabled, the kernel executes the contents of the release_agent file when a cgroup no longer contains any tasks (that is, the cgroup's tasks file 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 the notify_on_release parameter in the root cgroup is 0. All non-root cgroups inherit the value in notify_on_release from 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_release flag is enabled, the kernel runs the command in the release_agent file 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 the cpu cgroup:
  1. Create a shell script that removes empty cpu cgroups, 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
    The $1 variable contains a relative path to the emptied cgroup.
  2. In the cpu cgroup, enable the notify_on_release flag:
    ~]# echo 1 > /cgroup/cpu/notify_on_release
  3. In the cpu cgroup, specify a release agent to be used:
    ~]# echo "/usr/local/bin/remove-empty-cpu-cgroup.sh" > /cgroup/cpu/release_agent
  4. Test your configuration to make sure emptied cgroups are properly removed:
    cpu]# pwd; ls
    /cgroup/cpu
    cgroup.event_control  cgroup.procs  cpu.cfs_period_us  cpu.cfs_quota_us  cpu.rt_period_us  cpu.rt_runtime_us  cpu.shares  cpu.stat  libvirt  notify_on_release  release_agent  tasks
    cpu]# cat notify_on_release 
    1
    cpu]# cat release_agent 
    /usr/local/bin/remove-empty-cpu-cgroup.sh
    cpu]# mkdir blue; ls
    blue  cgroup.event_control  cgroup.procs  cpu.cfs_period_us  cpu.cfs_quota_us  cpu.rt_period_us  cpu.rt_runtime_us  cpu.shares  cpu.stat  libvirt  notify_on_release  release_agent  tasks
    cpu]# cat blue/notify_on_release 
    1
    cpu]# cgexec -g cpu:blue dd if=/dev/zero of=/dev/null bs=1024k &
    [1] 8623
    cpu]# cat blue/tasks 
    8623
    cpu]# kill -9 8623
    cpu]# ls
    cgroup.event_control  cgroup.procs  cpu.cfs_period_us  cpu.cfs_quota_us  cpu.rt_period_us  cpu.rt_runtime_us  cpu.shares  cpu.stat  libvirt  notify_on_release  release_agent  tasks
    
Red Hat logoGithubRedditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

© 2024 Red Hat, Inc.