]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tools/cgclassify: add support for default systemd delegation slice/scope
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 10 Jan 2023 14:13:43 +0000 (14:13 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 10 Feb 2023 21:44:25 +0000 (14:44 -0700)
commit08ee9e36dee97bd32b0e648090b2e7570a1935fb
tree63ee319e6df642a904d88c87fd9663ba764d0e9d
parenteb7ece5f1e3c6ad0f48d5f7c67726e64d7db1b35
tools/cgclassify: add support for default systemd delegation slice/scope

Enhance the cgclassify tool to support default systemd delegation
slice/scope, if set in the cgconfig.conf's systemd setting.  Parse the
configuration file and read the systemd::delegate setting, if
any, and set it as the default systemd slice/scope in
systemd_default_cgroup. Setting it appends the slice/scope
name to the constructed default cgroup mount path.

When the user passes the relative cgroup name, its appends to the
sub-tree (delegated slice/scope) by default and if the user wishes to
create a cgroup in another subtree or cgroup root hierarchy, they need
to use the absolute path. For example:

                      cgroup_root
                     /          \
                    /            \
             systemd.slice*      cgrp1
                    |
             systemd.scope
                    |
                cgrp-d1

* default system delegation slice/scope - read from cgconfig.conf
$ sudo cgclassify -g cpu:cgrp-d1 1379 (pid)

will create the cgroup under the cpu controller hirearchy
cgroup_root:systemd_default_cgroup:cgrp-d1

and for creating a cgroup cgrp1, the user can use:
$ sudo cgclassify -g cpu:/cgrp1 1379 (pid)

or use the newly introduced -b switch to ignore the systemd slice/scope:
$ sudo cgclassify -b -g cpu:cgrp1 1379 (pid)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/tools/cgclassify.c