The cgroups configuration file, /etc/cgconfig.conf, contains a mount
definition and one or more group 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;
} 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:
groupcgroup_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 {
cpu.rt_period_us="1000000"; # Reallocate CPU resources once per second
cpu.rt_runtime_us="500000"; # Allocate 50% of runtime to tasks in the cgroup
}
cpuset {
cpuset.mems="0";
cpuset.cpus="4-7"; # Allocate CPU cores 4 through 7 to tasks in the cgroup
}
memory {
memory.limit_in_bytes="4G"; # Allocate at most 4GB of memory to tasks
memory.memsw.limit_in_bytes="8G"; # Allocate at most 8GB of memory plus swap to tasks
memory.soft_limit_in_bytes="2G"; # Apply a soft limit of 2GB to tasks
}
}
You can include comments in the file by preceding them with a
# character.