cgroups

cgroups (control groups) is a Linux kernel feature to limit, account and isolate resource usage (CPU, memory, disk I/O, etc.) of process groups. This work was started by Rohit Seth in 2006 under the name "process containers";[1] in late 2007 it was renamed to cgroups and merged to kernel version 2.6.24.[2] Since then, many new features and controllers have been added.

Contents

Features

One of the design goals of cgroups was to provide a unified interface to many different use cases, from controlling single processes (like nice) to whole operating system-level virtualization (like OpenVZ, Linux-VServer). Cgroups provides:

Usage

A control group is a collection of processes that are bound by the same criteria. These groups can be hierarchical, where each group inherits limits from its parent group. The kernel provides access to multiple controllers (subsystems) through the cgroup interface.[2] For instance, the "memory" controller limits memory use, the "ns" controller separates processes into isolated namespaces, "cpuacct" accounts CPU usage, etc.

Control groups can be used in multiple ways:

Namespace isolation

While not technically part of the cgroups work, a related feature is namespace isolation, where groups of processes are separated such that they cannot "see" resources in other groups. For example, a PID namespace provides a separate enumeration of process identifiers within each namespace. Also available are mount, UTS, network and SysV IPC namespaces. If the "ns" cgroup is mounted, each namespace will also create a new group in the cgroup hierarchy.

Namespaces are created with the "unshare" command or syscall, or as new flags in a "clone" syscall.[12]

See also

References

  1. ^ Jonathan Corbet (2007-05-29). "Process containers". LWN.net. http://lwn.net/Articles/236038/. 
  2. ^ a b c Jonathan Corbet (2007-10-29). "Notes from a container". LWN.net. http://lwn.net/Articles/256389/. 
  3. ^ Jonathan Corbet (2007-07-31). "Controlling memory use in containers". LWN. http://lwn.net/Articles/243795/. 
  4. ^ Balbir Singh, Vaidynathan Srinivasan (July 2007). Ottawa Linux Symposium. http://www.kernel.org/doc/ols/2007/ols2007v2-pages-209-222.pdf. 
  5. ^ Jonathan Corbet (2007-10-23). "Kernel space: Fair user scheduling for Linux". Network World. http://www.linuxworld.com/news/2007/101207-kernel.html. 
  6. ^ Kamkamezawa Hiroyu (2008-11-19). "Cgroup and Memory Resource Controller" (PDF presentation slides). Japan Linux Symposium. http://www.linuxfoundation.jp/jp_uploads/seminar20081119/CgroupMemcgMaster.pdf. 
  7. ^ a b Dave Hansen. "Resource Management" (PDF presentation slides). Linux Foundation. http://events.linuxfoundation.org/slides/lfcs09_hansen2.pdf. 
  8. ^ Matt Helsley (2009-02-03). "LXC: Linux container tools". IBM developerWorks. http://www.ibm.com/developerworks/linux/library/l-lxc-containers/. 
  9. ^ Pavel Emelyanov, Kir Kolyshkin (2007-11-19). "PID namespaces in the 2.6.24 kernel". LWN.net. http://lwn.net/Articles/259217/. 
  10. ^ Jonathan Corbet (2007-01-30). "Network namespaces". LWN.net. http://lwn.net/Articles/219794/. 
  11. ^ Serge E. Hallyn, Ram Pai (2007-09-17). "Applying mount namespaces". IBM developerWorks. http://www.ibm.com/developerworks/linux/library/l-mount-namespaces.html. 
  12. ^ Janak Desai (2006-01-11). "Linux kernel documentation on unshare". http://www.mjmwired.net/kernel/Documentation/unshare.txt. 

External links