Chapter 3. Using libcgroup Tools The libcgroup package, which was the main tool for cgroup management in versions of Red Hat Enterprise Linux, is now deprecated. To avoid conflicts, do not use libcgroup tools for default resource controllers (listed in Available Controllers in Red Hat Enterprise Linux 7 ) that are now an exclusive domain of systemd . This leaves a limited space for applying libcgroup tools, use it only when you need to manage controllers not currently supported by systemd , such as net_prio . The following sections describe how to use libcgroup tools in relevant scenarios without conflicting with the default system of hierarchy. Note In order to use libcgroup tools, first ensure the libcgroup and libcgroup-tools packages are installed on your system. To install them, run as root : Note The net_prio controller is not compiled in the kernel like the rest of the controllers, rather it is a module that has to be loaded before attempting to mount it. To load this module, type as root : 3.1. Mounting a Hierarchy To use a kernel resource controller that is not mounted automatically, you have to create a hierarchy that will contain this controller. Add or detach the hierarchy by editing the mount section of the /etc/cgconfig.conf configuration file. This method makes the controller attachment persistent, which means your settings will be preserved after system reboot. As an alternative, use the mount command to create a transient mount only for the current session. Using the cgconfig Service The cgconfig service installed with the libcgroup-tools package provides a way to mount hierarchies for additional resource controllers. By default, this service is not started automatically. When you start cgconfig , it applies the settings from the /etc/cgconfig.conf configuration file. The configuration is therefore recreated from session to session and becomes persistent. Note that if you stop cgconfig , it unmounts all the hierarchies that it mounted. The default /etc/cgconfig.conf file installed with the libcgroup package does not contain any configuration settings, only information that systemd mounts the main resource controllers automatically. Entries of three types can be created in /etc/cgconfig.conf - mount , group , and template . Mount entries are used to create and mount hierarchies as virtual file systems, and attach controllers to those hierarchies. In Red Hat Enterprise Linux 7, default hierarchies are mounted automatically to the /sys/fs/cgroup/ directory, cgconfig is therefore used solely to attach non-default controllers. Mount entries are defined using the following syntax: Replace controller_name with a name of the kernel resource controller you wish to mount to the hierarchy. See Example 3.1, "Creating a mount entry" for an example. Example 3.1. Creating a mount entry To attach the net_prio controller to the default cgroup tree, add the following text to the /etc/cgconfig.conf configuration file: Then restart the cgconfig service to apply the setting: Group entries in /etc/cgconfig.conf can be used to set the parameters of resource controllers. See Section 3.5, "Setting Cgroup Parameters" for more information about group entries. Template entries in /etc/cgconfig.conf can be used to create a group definition applied to all processes. Using the mount Command Use the mount command to temporarily mount a hierarchy. To do so, first create a mount point in the /sys/fs/cgroup/ directory where systemd mounts the main resource controllers. Type as root : Replace name with a name of the new mount destination, usually the name of the controller is used. , execute the mount command to mount the hierarchy and simultaneously attach one or more subsystems. Type as root : Replace controller_name with a name of the controller to specify both the device to be mounted as well as the destination folder. The -t cgroup parameter specifies the type of mount. Example 3.2. Using the mount command to attach controllers To mount a hierarchy for the net_prio controller with use of the mount command, first create the mount point: Then mount net_prio to the destination you created in the step: You can verify whether you attached the hierarchy correctly by listing all available hierarchies along with their current mount points using the lssubsys command (see the section called "Listing Controllers" ):

Commands:
~]# yum install libcgroup ~]# yum install libcgroup-tools
~]# modprobe netprio_cgroup
mount { controller_name = /sys/fs/cgroup/ controller_name ; ... }
mount { net_prio = /sys/fs/cgroup/net_prio; }
~]# systemctl restart cgconfig.service
~]# mkdir /sys/fs/cgroup/ name
~]# mount -t cgroup -o controller_name none /sys/fs/cgroup/ controller_name
~]# mkdir /sys/fs/cgroup/net_prio
~]# mount -t cgroup -o net_prio none /sys/fs/cgroup/net_prio
~]# lssubsys -am cpuset /sys/fs/cgroup/cpuset cpu,cpuacct /sys/fs/cgroup/cpu,cpuacct memory /sys/fs/cgroup/memory devices /sys/fs/cgroup/devices freezer /sys/fs/cgroup/freezer net_cls /sys/fs/cgroup/net_cls blkio /sys/fs/cgroup/blkio perf_event /sys/fs/cgroup/perf_event hugetlb /sys/fs/cgroup/hugetlb net_prio /sys/fs/cgroup/net_prio