Commit cf17e50a authored by Mike Rapoport's avatar Mike Rapoport Committed by Jonathan Corbet

docs/admin-guide/mm/concepts.rst: grammar and style fixups

Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Reviewed-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 3870a237
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
Concepts overview Concepts overview
================= =================
The memory management in Linux is complex system that evolved over the The memory management in Linux is a complex system that evolved over the
years and included more and more functionality to support variety of years and included more and more functionality to support a variety of
systems from MMU-less microcontrollers to supercomputers. The memory systems from MMU-less microcontrollers to supercomputers. The memory
management for systems without MMU is called ``nommu`` and it management for systems without an MMU is called ``nommu`` and it
definitely deserves a dedicated document, which hopefully will be definitely deserves a dedicated document, which hopefully will be
eventually written. Yet, although some of the concepts are the same, eventually written. Yet, although some of the concepts are the same,
here we assume that MMU is available and CPU can translate a virtual here we assume that an MMU is available and a CPU can translate a virtual
address to a physical address. address to a physical address.
.. contents:: :local: .. contents:: :local:
...@@ -21,10 +21,10 @@ Virtual Memory Primer ...@@ -21,10 +21,10 @@ Virtual Memory Primer
The physical memory in a computer system is a limited resource and The physical memory in a computer system is a limited resource and
even for systems that support memory hotplug there is a hard limit on even for systems that support memory hotplug there is a hard limit on
the amount of memory that can be installed. The physical memory is not the amount of memory that can be installed. The physical memory is not
necessary contiguous, it might be accessible as a set of distinct necessarily contiguous; it might be accessible as a set of distinct
address ranges. Besides, different CPU architectures, and even address ranges. Besides, different CPU architectures, and even
different implementations of the same architecture have different view different implementations of the same architecture have different views
how these address ranges defined. of how these address ranges are defined.
All this makes dealing directly with physical memory quite complex and All this makes dealing directly with physical memory quite complex and
to avoid this complexity a concept of virtual memory was developed. to avoid this complexity a concept of virtual memory was developed.
...@@ -48,8 +48,8 @@ appropriate kernel configuration option. ...@@ -48,8 +48,8 @@ appropriate kernel configuration option.
Each physical memory page can be mapped as one or more virtual Each physical memory page can be mapped as one or more virtual
pages. These mappings are described by page tables that allow pages. These mappings are described by page tables that allow
translation from virtual address used by programs to real address in translation from a virtual address used by programs to the physical
the physical memory. The page tables organized hierarchically. memory address. The page tables are organized hierarchically.
The tables at the lowest level of the hierarchy contain physical The tables at the lowest level of the hierarchy contain physical
addresses of actual pages used by the software. The tables at higher addresses of actual pages used by the software. The tables at higher
...@@ -121,8 +121,8 @@ Nodes ...@@ -121,8 +121,8 @@ Nodes
Many multi-processor machines are NUMA - Non-Uniform Memory Access - Many multi-processor machines are NUMA - Non-Uniform Memory Access -
systems. In such systems the memory is arranged into banks that have systems. In such systems the memory is arranged into banks that have
different access latency depending on the "distance" from the different access latency depending on the "distance" from the
processor. Each bank is referred as `node` and for each node Linux processor. Each bank is referred to as a `node` and for each node Linux
constructs an independent memory management subsystem. A node has it's constructs an independent memory management subsystem. A node has its
own set of zones, lists of free and used pages and various statistics own set of zones, lists of free and used pages and various statistics
counters. You can find more details about NUMA in counters. You can find more details about NUMA in
:ref:`Documentation/vm/numa.rst <numa>` and in :ref:`Documentation/vm/numa.rst <numa>` and in
...@@ -149,9 +149,9 @@ for program's stack and heap or by explicit calls to mmap(2) system ...@@ -149,9 +149,9 @@ for program's stack and heap or by explicit calls to mmap(2) system
call. Usually, the anonymous mappings only define virtual memory areas call. Usually, the anonymous mappings only define virtual memory areas
that the program is allowed to access. The read accesses will result that the program is allowed to access. The read accesses will result
in creation of a page table entry that references a special physical in creation of a page table entry that references a special physical
page filled with zeroes. When the program performs a write, regular page filled with zeroes. When the program performs a write, a regular
physical page will be allocated to hold the written data. The page physical page will be allocated to hold the written data. The page
will be marked dirty and if the kernel will decide to repurpose it, will be marked dirty and if the kernel decides to repurpose it,
the dirty page will be swapped out. the dirty page will be swapped out.
Reclaim Reclaim
...@@ -181,8 +181,8 @@ pressure. ...@@ -181,8 +181,8 @@ pressure.
The process of freeing the reclaimable physical memory pages and The process of freeing the reclaimable physical memory pages and
repurposing them is called (surprise!) `reclaim`. Linux can reclaim repurposing them is called (surprise!) `reclaim`. Linux can reclaim
pages either asynchronously or synchronously, depending on the state pages either asynchronously or synchronously, depending on the state
of the system. When system is not loaded, most of the memory is free of the system. When the system is not loaded, most of the memory is free
and allocation request will be satisfied immediately from the free and allocation requests will be satisfied immediately from the free
pages supply. As the load increases, the amount of the free pages goes pages supply. As the load increases, the amount of the free pages goes
down and when it reaches a certain threshold (high watermark), an down and when it reaches a certain threshold (high watermark), an
allocation request will awaken the ``kswapd`` daemon. It will allocation request will awaken the ``kswapd`` daemon. It will
...@@ -190,7 +190,7 @@ asynchronously scan memory pages and either just free them if the data ...@@ -190,7 +190,7 @@ asynchronously scan memory pages and either just free them if the data
they contain is available elsewhere, or evict to the backing storage they contain is available elsewhere, or evict to the backing storage
device (remember those dirty pages?). As memory usage increases even device (remember those dirty pages?). As memory usage increases even
more and reaches another threshold - min watermark - an allocation more and reaches another threshold - min watermark - an allocation
will trigger the `direct reclaim`. In this case allocation is stalled will trigger `direct reclaim`. In this case allocation is stalled
until enough memory pages are reclaimed to satisfy the request. until enough memory pages are reclaimed to satisfy the request.
Compaction Compaction
...@@ -200,7 +200,7 @@ As the system runs, tasks allocate and free the memory and it becomes ...@@ -200,7 +200,7 @@ As the system runs, tasks allocate and free the memory and it becomes
fragmented. Although with virtual memory it is possible to present fragmented. Although with virtual memory it is possible to present
scattered physical pages as virtually contiguous range, sometimes it is scattered physical pages as virtually contiguous range, sometimes it is
necessary to allocate large physically contiguous memory areas. Such necessary to allocate large physically contiguous memory areas. Such
need may arise, for instance, when a device driver requires large need may arise, for instance, when a device driver requires a large
buffer for DMA, or when THP allocates a huge page. Memory `compaction` buffer for DMA, or when THP allocates a huge page. Memory `compaction`
addresses the fragmentation issue. This mechanism moves occupied pages addresses the fragmentation issue. This mechanism moves occupied pages
from the lower part of a memory zone to free pages in the upper part from the lower part of a memory zone to free pages in the upper part
...@@ -208,15 +208,16 @@ of the zone. When a compaction scan is finished free pages are grouped ...@@ -208,15 +208,16 @@ of the zone. When a compaction scan is finished free pages are grouped
together at the beginning of the zone and allocations of large together at the beginning of the zone and allocations of large
physically contiguous areas become possible. physically contiguous areas become possible.
Like reclaim, the compaction may happen asynchronously in ``kcompactd`` Like reclaim, the compaction may happen asynchronously in the ``kcompactd``
daemon or synchronously as a result of memory allocation request. daemon or synchronously as a result of a memory allocation request.
OOM killer OOM killer
========== ==========
It may happen, that on a loaded machine memory will be exhausted. When It is possible that on a loaded machine memory will be exhausted and the
the kernel detects that the system runs out of memory (OOM) it invokes kernel will be unable to reclaim enough memory to continue to operate. In
`OOM killer`. Its mission is simple: all it has to do is to select a order to save the rest of the system, it invokes the `OOM killer`.
task to sacrifice for the sake of the overall system health. The
selected task is killed in a hope that after it exits enough memory The `OOM killer` selects a task to sacrifice for the sake of the overall
will be freed to continue normal operation. system health. The selected task is killed in a hope that after it exits
enough memory will be freed to continue normal operation.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment