8.6 About the cgroups Configuration File

The cgroups configuration file, /etc/cgconfig.conf, contains a mount definition and one or more group definitions.

mount Definitions

A mount definition specifies the virtual file systems that you use to mount resource subsystems before you attach them to cgroups. The configuration file can contain only one mount definition.

The mount entry takes the following form:

mount {
    subsystem1 = /cgroup/resource_path1;
    [subsystem2 = /cgroup/resource_path2;]
.
.
.
}

For example, the following mount definition combines the cpu, cpuset, and memory subsystems under the /cgroup/cpumem subsystem hierarchy, and also creates entries for the blkio and devices subsystems under /cgroup/iolimit and /cgroup/devlist. You cannot include a subsystem in more than one subsystem hierarchy.

mount {
    cpu = /cgroup/cpumem;
    cpuset = /cgroup/cpumem;
    memory = /cgroup/cpumem;
    blkio = /cgroup/iolimit;
    devices = /cgroup/devlist;
}

group Definitions

A group definition specifies a cgroup, its access permissions, the resource subsystems that it uses, and the parameter values for those subsystems. The configuration file can contain more than one group definition.

A group entry takes the following form:

group cgroup_name {
    [perm {
        task {
            uid = task_user;
            gid = task_group;
        }
        admin {
            uid = admin_user;
            gid = admin_group;
        }
    }]
    subsystem {
        subsystem.parameter1 = value1;
        [subsystem.parameter2 = value2;]
        .
        .
        .
    }
    .
    .
    .
}

The cgroup_name argument defines the name of the cgroup. The task section of the optional perm (permissions) section defines the user and group combination that can add tasks to the cgroup. The admin section defines the user and group combination that can modify subsystem parameters and create subgroups. Whatever settings exist under perm, the root user always has permission to make any admin or task change.

One or more subsystem sections define the parameter settings for the cgroup. You can associate only one virtual subsystem hierarchy from /cgroup with a cgroup. If a several subsystems are grouped in the same hierarchy, you must include definitions for all the subsystems. For example, if the /cgroup/cpumem hierarchy includes the cpu, cpuset, and memory subsystems, you must include definitions for all of these subsystems.

For example, the following group definition defines the cgroup dbgrp for database processes, allows the oracle user to add tasks, and sets various parameters for CPU and memory usage:

group dbgrp {
    perm {
        task {
            uid = oracle;
            gid = dba;
        }
        admin {
            uid = root;
            gid = root;
        }
    }
    cpu {
#       Reallocate CPU resources once per second
        cpu.rt_period_us="1000000";
#       Allocate 50% of runtime to tasks in the cgroup
        cpu.rt_runtime_us="500000";
    }
    cpuset {
        cpuset.mems="0";
#       Allocate CPU cores 4 through 7 to tasks in the cgroup
        cpuset.cpus="4-7";
    }
    memory {
#       Allocate at most 4 GB of memory to tasks
        memory.limit_in_bytes="4G";
#       Allocate at most 8 GB of memory plus swap to tasks
        memory.memsw.limit_in_bytes="8G";
#       Apply a soft limit of 2 GB to tasks
        memory.soft_limit_in_bytes="2G"; 
    }
}

You can include comments in the file by preceding them with a # character, which must be at the start of a line.