Documentation/admin-guide/cgroup-v1/memory.rst

Source file repositories/reference/linux-study-clean/Documentation/admin-guide/cgroup-v1/memory.rst

File Facts

System
Linux kernel
Corpus path
Documentation/admin-guide/cgroup-v1/memory.rst
Extension
.rst
Size
39463 bytes
Lines
964
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

==========================
Memory Resource Controller
==========================

.. caution::
      This document is hopelessly outdated and it asks for a complete
      rewrite. It still contains a useful information so we are keeping it
      here but make sure to check the current code if you need a deeper
      understanding.

.. note::
      The Memory Resource Controller has generically been referred to as the
      memory controller in this document. Do not confuse memory controller
      used here with the memory controller that is used in hardware.

.. hint::
      When we mention a cgroup (cgroupfs's directory) with memory controller,
      we call it "memory cgroup". When you see git-log and source code, you'll
      see patch's title and function names tend to use "memcg".
      In this document, we avoid using it.

Benefits and Purpose of the memory controller
=============================================

The memory controller isolates the memory behaviour of a group of tasks
from the rest of the system. The article on LWN [12]_ mentions some probable
uses of the memory controller. The memory controller can be used to

a. Isolate an application or a group of applications
   Memory-hungry applications can be isolated and limited to a smaller
   amount of memory.
b. Create a cgroup with a limited amount of memory; this can be used
   as a good alternative to booting with mem=XXXX.
c. Virtualization solutions can control the amount of memory they want
   to assign to a virtual machine instance.
d. A CD/DVD burner could control the amount of memory used by the
   rest of the system to ensure that burning does not fail due to lack
   of available memory.
e. There are several other use cases; find one or use the controller just
   for fun (to learn and hack on the VM subsystem).

Current Status: linux-2.6.34-mmotm(development version of 2010/April)

Features:

 - accounting anonymous pages, file caches, swap caches usage and limiting them.
 - pages are linked to per-memcg LRU exclusively, and there is no global LRU.
 - optionally, memory+swap usage can be accounted and limited.
 - hierarchical accounting
 - soft limit
 - moving (recharging) account at moving a task is selectable.
 - usage threshold notifier
 - memory pressure notifier
 - oom-killer disable knob and oom-notifier
 - Root cgroup has no limit controls.

 Kernel memory support is a work in progress, and the current version provides
 basically functionality. (See :ref:`section 2.7
 <cgroup-v1-memory-kernel-extension>`)

Brief summary of control files.

==================================== ==========================================
 tasks				     attach a task(thread) and show list of
				     threads
 cgroup.procs			     show list of processes
 cgroup.event_control		     an interface for event_fd()
				     This knob is not available on CONFIG_PREEMPT_RT systems.
 memory.usage_in_bytes		     show current usage for memory
				     (See 5.5 for details)

Annotation

Implementation Notes