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

docs/vm: highmem.txt: convert to ReST format

Signed-off-by: default avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 76b387bd
.. _highmem:
==================== ====================
HIGH MEMORY HANDLING High Memory Handling
==================== ====================
By: Peter Zijlstra <a.p.zijlstra@chello.nl> By: Peter Zijlstra <a.p.zijlstra@chello.nl>
Contents: .. contents:: :local:
(*) What is high memory?
(*) Temporary virtual mappings.
(*) Using kmap_atomic.
(*) Cost of temporary mappings.
(*) i386 PAE.
What Is High Memory?
====================
WHAT IS HIGH MEMORY?
==================== ====================
High memory (highmem) is used when the size of physical memory approaches or High memory (highmem) is used when the size of physical memory approaches or
...@@ -38,7 +27,7 @@ kernel entry/exit. This means the available virtual memory space (4GiB on ...@@ -38,7 +27,7 @@ kernel entry/exit. This means the available virtual memory space (4GiB on
i386) has to be divided between user and kernel space. i386) has to be divided between user and kernel space.
The traditional split for architectures using this approach is 3:1, 3GiB for The traditional split for architectures using this approach is 3:1, 3GiB for
userspace and the top 1GiB for kernel space: userspace and the top 1GiB for kernel space::
+--------+ 0xffffffff +--------+ 0xffffffff
| Kernel | | Kernel |
...@@ -58,40 +47,38 @@ and user maps. Some hardware (like some ARMs), however, have limited virtual ...@@ -58,40 +47,38 @@ and user maps. Some hardware (like some ARMs), however, have limited virtual
space when they use mm context tags. space when they use mm context tags.
========================== Temporary Virtual Mappings
TEMPORARY VIRTUAL MAPPINGS
========================== ==========================
The kernel contains several ways of creating temporary mappings: The kernel contains several ways of creating temporary mappings:
(*) vmap(). This can be used to make a long duration mapping of multiple * vmap(). This can be used to make a long duration mapping of multiple
physical pages into a contiguous virtual space. It needs global physical pages into a contiguous virtual space. It needs global
synchronization to unmap. synchronization to unmap.
(*) kmap(). This permits a short duration mapping of a single page. It needs * kmap(). This permits a short duration mapping of a single page. It needs
global synchronization, but is amortized somewhat. It is also prone to global synchronization, but is amortized somewhat. It is also prone to
deadlocks when using in a nested fashion, and so it is not recommended for deadlocks when using in a nested fashion, and so it is not recommended for
new code. new code.
(*) kmap_atomic(). This permits a very short duration mapping of a single * kmap_atomic(). This permits a very short duration mapping of a single
page. Since the mapping is restricted to the CPU that issued it, it page. Since the mapping is restricted to the CPU that issued it, it
performs well, but the issuing task is therefore required to stay on that performs well, but the issuing task is therefore required to stay on that
CPU until it has finished, lest some other task displace its mappings. CPU until it has finished, lest some other task displace its mappings.
kmap_atomic() may also be used by interrupt contexts, since it is does not kmap_atomic() may also be used by interrupt contexts, since it is does not
sleep and the caller may not sleep until after kunmap_atomic() is called. sleep and the caller may not sleep until after kunmap_atomic() is called.
It may be assumed that k[un]map_atomic() won't fail. It may be assumed that k[un]map_atomic() won't fail.
================= Using kmap_atomic
USING KMAP_ATOMIC
================= =================
When and where to use kmap_atomic() is straightforward. It is used when code When and where to use kmap_atomic() is straightforward. It is used when code
wants to access the contents of a page that might be allocated from high memory wants to access the contents of a page that might be allocated from high memory
(see __GFP_HIGHMEM), for example a page in the pagecache. The API has two (see __GFP_HIGHMEM), for example a page in the pagecache. The API has two
functions, and they can be used in a manner similar to the following: functions, and they can be used in a manner similar to the following::
/* Find the page of interest. */ /* Find the page of interest. */
struct page *page = find_get_page(mapping, offset); struct page *page = find_get_page(mapping, offset);
...@@ -109,7 +96,7 @@ Note that the kunmap_atomic() call takes the result of the kmap_atomic() call ...@@ -109,7 +96,7 @@ Note that the kunmap_atomic() call takes the result of the kmap_atomic() call
not the argument. not the argument.
If you need to map two pages because you want to copy from one page to If you need to map two pages because you want to copy from one page to
another you need to keep the kmap_atomic calls strictly nested, like: another you need to keep the kmap_atomic calls strictly nested, like::
vaddr1 = kmap_atomic(page1); vaddr1 = kmap_atomic(page1);
vaddr2 = kmap_atomic(page2); vaddr2 = kmap_atomic(page2);
...@@ -120,8 +107,7 @@ another you need to keep the kmap_atomic calls strictly nested, like: ...@@ -120,8 +107,7 @@ another you need to keep the kmap_atomic calls strictly nested, like:
kunmap_atomic(vaddr1); kunmap_atomic(vaddr1);
========================== Cost of Temporary Mappings
COST OF TEMPORARY MAPPINGS
========================== ==========================
The cost of creating temporary mappings can be quite high. The arch has to The cost of creating temporary mappings can be quite high. The arch has to
...@@ -136,25 +122,24 @@ If CONFIG_MMU is not set, then there can be no temporary mappings and no ...@@ -136,25 +122,24 @@ If CONFIG_MMU is not set, then there can be no temporary mappings and no
highmem. In such a case, the arithmetic approach will also be used. highmem. In such a case, the arithmetic approach will also be used.
========
i386 PAE i386 PAE
======== ========
The i386 arch, under some circumstances, will permit you to stick up to 64GiB The i386 arch, under some circumstances, will permit you to stick up to 64GiB
of RAM into your 32-bit machine. This has a number of consequences: of RAM into your 32-bit machine. This has a number of consequences:
(*) Linux needs a page-frame structure for each page in the system and the * Linux needs a page-frame structure for each page in the system and the
pageframes need to live in the permanent mapping, which means: pageframes need to live in the permanent mapping, which means:
(*) you can have 896M/sizeof(struct page) page-frames at most; with struct * you can have 896M/sizeof(struct page) page-frames at most; with struct
page being 32-bytes that would end up being something in the order of 112G page being 32-bytes that would end up being something in the order of 112G
worth of pages; the kernel, however, needs to store more than just worth of pages; the kernel, however, needs to store more than just
page-frames in that memory... page-frames in that memory...
(*) PAE makes your page tables larger - which slows the system down as more * PAE makes your page tables larger - which slows the system down as more
data has to be accessed to traverse in TLB fills and the like. One data has to be accessed to traverse in TLB fills and the like. One
advantage is that PAE has more PTE bits and can provide advanced features advantage is that PAE has more PTE bits and can provide advanced features
like NX and PAT. like NX and PAT.
The general recommendation is that you don't use more than 8GiB on a 32-bit The general recommendation is that you don't use more than 8GiB on a 32-bit
machine - although more might work for you and your workload, you're pretty machine - although more might work for you and your workload, you're pretty
......
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