Linux cgroups: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 6: Line 6:
* https://en.wikipedia.org/wiki/Cgroups
* https://en.wikipedia.org/wiki/Cgroups
* http://man7.org/linux/man-pages/man7/cgroups.7.html
* http://man7.org/linux/man-pages/man7/cgroups.7.html
* https://docs.docker.com/config/containers/runmetrics/#control-groups


=Internal=
=Internal=

Revision as of 20:17, 6 February 2018

External

Internal

Overview

cgroups is a Linux kernel feature that allows allocation of resources (CPU, system memory, network bandwidth, or a combination of these) among user-defined groups of processes running on the system. cgroups not only track groups of processes, but they also expose metrics about CPU, memory and block I/O usage.

cgroups are exposed through a pseudo-filesystem available at /sys/fs/cgroup (older systems expose it at /cgroup). The sub-directories of the cgroup pseudo-filesystem root correspond to different cgroups hierarchies: cpu, freezer, blkio.

This command returns a list of the cgroups that are mounted:

cat /proc/mounts | grep cgroup

The control groups subsystems known to the system are available in /proc/cgroups:

#subsys_name	hierarchy	num_cgroups	enabled
cpuset	6	13	1
cpu	4	89	1
cpuacct	4	89	1
memory	8	89	1
devices	3	83	1
freezer	10	13	1
net_cls	5	13	1
blkio	11	89	1
perf_event	2	13	1
hugetlb	9	13	1
pids	7	13	1
net_prio	5	13	1

cgroups are organized hierarchically, child cgroups inheriting certain attributes from their parent group. Many different hierarchies of cgroups can exist simultaneously on a system. Each hierarchy is attached to one or more subsystem, where a subsystem represents a single resource like CPU time or memory.

cgroups can be configured via the cgconfig service.

cgroups Subsystems

blkio

Sets limits on input/output access from and to block devices.

cpu

Uses the scheduler to provide cgroup tasks access to the CPU.

cpuacct

Generates automatic reports on CPU resources.

cpuset

Assigns individual CPUs and memory nodes to tasks in a cgroup.

devices

freezer

memory

net_cls

Tags network packets with a tag identifier (classid) that allow the Linux traffic controller (tc) to identify packets.

net_prio

ns

The namespace subsystem.

perf_event

Operations

The recommended location for cgroup hierarchies:

/sys/fs/cgroup