mirror of
https://github.com/suyu-emu/horinux.git
synced 2026-09-21 14:15:21 -07:00
Merge branch 'mm-rst' into docs-next
Mike Rapoport says: These patches convert files in Documentation/vm to ReST format, add an initial index and link it to the top level documentation. There are no contents changes in the documentation, except few spelling fixes. The relatively large diffstat stems from the indentation and paragraph wrapping changes. I've tried to keep the formatting as consistent as possible, but I could miss some places that needed markup and add some markup where it was not necessary. [jc: significant conflicts in vm/hmm.rst]
This commit is contained in:
@@ -90,4 +90,4 @@ Date: December 2009
|
||||
Contact: Lee Schermerhorn <lee.schermerhorn@hp.com>
|
||||
Description:
|
||||
The node's huge page size control/query attributes.
|
||||
See Documentation/vm/hugetlbpage.txt
|
||||
See Documentation/vm/hugetlbpage.rst
|
||||
@@ -12,4 +12,4 @@ Description:
|
||||
free_hugepages
|
||||
surplus_hugepages
|
||||
resv_hugepages
|
||||
See Documentation/vm/hugetlbpage.txt for details.
|
||||
See Documentation/vm/hugetlbpage.rst for details.
|
||||
|
||||
@@ -40,7 +40,7 @@ Description: Kernel Samepage Merging daemon sysfs interface
|
||||
sleep_millisecs: how many milliseconds ksm should sleep between
|
||||
scans.
|
||||
|
||||
See Documentation/vm/ksm.txt for more information.
|
||||
See Documentation/vm/ksm.rst for more information.
|
||||
|
||||
What: /sys/kernel/mm/ksm/merge_across_nodes
|
||||
Date: January 2013
|
||||
|
||||
@@ -37,7 +37,7 @@ Description:
|
||||
The alloc_calls file is read-only and lists the kernel code
|
||||
locations from which allocations for this cache were performed.
|
||||
The alloc_calls file only contains information if debugging is
|
||||
enabled for that cache (see Documentation/vm/slub.txt).
|
||||
enabled for that cache (see Documentation/vm/slub.rst).
|
||||
|
||||
What: /sys/kernel/slab/cache/alloc_fastpath
|
||||
Date: February 2008
|
||||
@@ -219,7 +219,7 @@ Contact: Pekka Enberg <penberg@cs.helsinki.fi>,
|
||||
Description:
|
||||
The free_calls file is read-only and lists the locations of
|
||||
object frees if slab debugging is enabled (see
|
||||
Documentation/vm/slub.txt).
|
||||
Documentation/vm/slub.rst).
|
||||
|
||||
What: /sys/kernel/slab/cache/free_fastpath
|
||||
Date: February 2008
|
||||
|
||||
@@ -3915,7 +3915,7 @@
|
||||
cache (risks via metadata attacks are mostly
|
||||
unchanged). Debug options disable merging on their
|
||||
own.
|
||||
For more information see Documentation/vm/slub.txt.
|
||||
For more information see Documentation/vm/slub.rst.
|
||||
|
||||
slab_max_order= [MM, SLAB]
|
||||
Determines the maximum allowed order for slabs.
|
||||
@@ -3929,7 +3929,7 @@
|
||||
slub_debug can create guard zones around objects and
|
||||
may poison objects when not in use. Also tracks the
|
||||
last alloc / free. For more information see
|
||||
Documentation/vm/slub.txt.
|
||||
Documentation/vm/slub.rst.
|
||||
|
||||
slub_memcg_sysfs= [MM, SLUB]
|
||||
Determines whether to enable sysfs directories for
|
||||
@@ -3943,7 +3943,7 @@
|
||||
Determines the maximum allowed order for slabs.
|
||||
A high setting may cause OOMs due to memory
|
||||
fragmentation. For more information see
|
||||
Documentation/vm/slub.txt.
|
||||
Documentation/vm/slub.rst.
|
||||
|
||||
slub_min_objects= [MM, SLUB]
|
||||
The minimum number of objects per slab. SLUB will
|
||||
@@ -3952,12 +3952,12 @@
|
||||
the number of objects indicated. The higher the number
|
||||
of objects the smaller the overhead of tracking slabs
|
||||
and the less frequently locks need to be acquired.
|
||||
For more information see Documentation/vm/slub.txt.
|
||||
For more information see Documentation/vm/slub.rst.
|
||||
|
||||
slub_min_order= [MM, SLUB]
|
||||
Determines the minimum page order for slabs. Must be
|
||||
lower than slub_max_order.
|
||||
For more information see Documentation/vm/slub.txt.
|
||||
For more information see Documentation/vm/slub.rst.
|
||||
|
||||
slub_nomerge [MM, SLUB]
|
||||
Same with slab_nomerge. This is supported for legacy.
|
||||
@@ -4313,7 +4313,7 @@
|
||||
Format: [always|madvise|never]
|
||||
Can be used to control the default behavior of the system
|
||||
with respect to transparent hugepages.
|
||||
See Documentation/vm/transhuge.txt for more details.
|
||||
See Documentation/vm/transhuge.rst for more details.
|
||||
|
||||
tsc= Disable clocksource stability checks for TSC.
|
||||
Format: <string>
|
||||
|
||||
@@ -120,7 +120,7 @@ A typical out of bounds access report looks like this::
|
||||
|
||||
The header of the report discribe what kind of bug happened and what kind of
|
||||
access caused it. It's followed by the description of the accessed slub object
|
||||
(see 'SLUB Debug output' section in Documentation/vm/slub.txt for details) and
|
||||
(see 'SLUB Debug output' section in Documentation/vm/slub.rst for details) and
|
||||
the description of the accessed memory page.
|
||||
|
||||
In the last section the report shows memory state around the accessed address.
|
||||
|
||||
@@ -515,7 +515,7 @@ guarantees:
|
||||
|
||||
The /proc/PID/clear_refs is used to reset the PG_Referenced and ACCESSED/YOUNG
|
||||
bits on both physical and virtual pages associated with a process, and the
|
||||
soft-dirty bit on pte (see Documentation/vm/soft-dirty.txt for details).
|
||||
soft-dirty bit on pte (see Documentation/vm/soft-dirty.rst for details).
|
||||
To clear the bits for all the pages associated with the process
|
||||
> echo 1 > /proc/PID/clear_refs
|
||||
|
||||
@@ -536,7 +536,7 @@ Any other value written to /proc/PID/clear_refs will have no effect.
|
||||
|
||||
The /proc/pid/pagemap gives the PFN, which can be used to find the pageflags
|
||||
using /proc/kpageflags and number of times a page is mapped using
|
||||
/proc/kpagecount. For detailed explanation, see Documentation/vm/pagemap.txt.
|
||||
/proc/kpagecount. For detailed explanation, see Documentation/vm/pagemap.rst.
|
||||
|
||||
The /proc/pid/numa_maps is an extension based on maps, showing the memory
|
||||
locality and binding policy, as well as the memory usage (in pages) of
|
||||
|
||||
@@ -105,7 +105,7 @@ policy for the file will revert to "default" policy.
|
||||
NUMA memory allocation policies have optional flags that can be used in
|
||||
conjunction with their modes. These optional flags can be specified
|
||||
when tmpfs is mounted by appending them to the mode before the NodeList.
|
||||
See Documentation/vm/numa_memory_policy.txt for a list of all available
|
||||
See Documentation/vm/numa_memory_policy.rst for a list of all available
|
||||
memory allocation policy mode flags and their effect on memory policy.
|
||||
|
||||
=static is equivalent to MPOL_F_STATIC_NODES
|
||||
|
||||
@@ -45,7 +45,7 @@ the kernel interface as seen by application developers.
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
userspace-api/index
|
||||
userspace-api/index
|
||||
|
||||
|
||||
Introduction to kernel development
|
||||
@@ -89,6 +89,7 @@ needed).
|
||||
sound/index
|
||||
crypto/index
|
||||
filesystems/index
|
||||
vm/index
|
||||
|
||||
Architecture-specific documentation
|
||||
-----------------------------------
|
||||
|
||||
@@ -515,7 +515,7 @@ nr_hugepages
|
||||
|
||||
Change the minimum size of the hugepage pool.
|
||||
|
||||
See Documentation/vm/hugetlbpage.txt
|
||||
See Documentation/vm/hugetlbpage.rst
|
||||
|
||||
==============================================================
|
||||
|
||||
@@ -524,7 +524,7 @@ nr_overcommit_hugepages
|
||||
Change the maximum size of the hugepage pool. The maximum is
|
||||
nr_hugepages + nr_overcommit_hugepages.
|
||||
|
||||
See Documentation/vm/hugetlbpage.txt
|
||||
See Documentation/vm/hugetlbpage.rst
|
||||
|
||||
==============================================================
|
||||
|
||||
@@ -667,7 +667,7 @@ and don't use much of it.
|
||||
|
||||
The default value is 0.
|
||||
|
||||
See Documentation/vm/overcommit-accounting and
|
||||
See Documentation/vm/overcommit-accounting.rst and
|
||||
mm/mmap.c::__vm_enough_memory() for more information.
|
||||
|
||||
==============================================================
|
||||
|
||||
+29
-29
@@ -1,62 +1,62 @@
|
||||
00-INDEX
|
||||
- this file.
|
||||
active_mm.txt
|
||||
active_mm.rst
|
||||
- An explanation from Linus about tsk->active_mm vs tsk->mm.
|
||||
balance
|
||||
balance.rst
|
||||
- various information on memory balancing.
|
||||
cleancache.txt
|
||||
cleancache.rst
|
||||
- Intro to cleancache and page-granularity victim cache.
|
||||
frontswap.txt
|
||||
frontswap.rst
|
||||
- Outline frontswap, part of the transcendent memory frontend.
|
||||
highmem.txt
|
||||
highmem.rst
|
||||
- Outline of highmem and common issues.
|
||||
hmm.txt
|
||||
hmm.rst
|
||||
- Documentation of heterogeneous memory management
|
||||
hugetlbpage.txt
|
||||
hugetlbpage.rst
|
||||
- a brief summary of hugetlbpage support in the Linux kernel.
|
||||
hugetlbfs_reserv.txt
|
||||
hugetlbfs_reserv.rst
|
||||
- A brief overview of hugetlbfs reservation design/implementation.
|
||||
hwpoison.txt
|
||||
hwpoison.rst
|
||||
- explains what hwpoison is
|
||||
idle_page_tracking.txt
|
||||
idle_page_tracking.rst
|
||||
- description of the idle page tracking feature.
|
||||
ksm.txt
|
||||
ksm.rst
|
||||
- how to use the Kernel Samepage Merging feature.
|
||||
mmu_notifier.txt
|
||||
mmu_notifier.rst
|
||||
- a note about clearing pte/pmd and mmu notifications
|
||||
numa
|
||||
numa.rst
|
||||
- information about NUMA specific code in the Linux vm.
|
||||
numa_memory_policy.txt
|
||||
numa_memory_policy.rst
|
||||
- documentation of concepts and APIs of the 2.6 memory policy support.
|
||||
overcommit-accounting
|
||||
overcommit-accounting.rst
|
||||
- description of the Linux kernels overcommit handling modes.
|
||||
page_frags
|
||||
page_frags.rst
|
||||
- description of page fragments allocator
|
||||
page_migration
|
||||
page_migration.rst
|
||||
- description of page migration in NUMA systems.
|
||||
pagemap.txt
|
||||
pagemap.rst
|
||||
- pagemap, from the userspace perspective
|
||||
page_owner.txt
|
||||
page_owner.rst
|
||||
- tracking about who allocated each page
|
||||
remap_file_pages.txt
|
||||
remap_file_pages.rst
|
||||
- a note about remap_file_pages() system call
|
||||
slub.txt
|
||||
slub.rst
|
||||
- a short users guide for SLUB.
|
||||
soft-dirty.txt
|
||||
soft-dirty.rst
|
||||
- short explanation for soft-dirty PTEs
|
||||
split_page_table_lock
|
||||
split_page_table_lock.rst
|
||||
- Separate per-table lock to improve scalability of the old page_table_lock.
|
||||
swap_numa.txt
|
||||
swap_numa.rst
|
||||
- automatic binding of swap device to numa node
|
||||
transhuge.txt
|
||||
transhuge.rst
|
||||
- Transparent Hugepage Support, alternative way of using hugepages.
|
||||
unevictable-lru.txt
|
||||
unevictable-lru.rst
|
||||
- Unevictable LRU infrastructure
|
||||
userfaultfd.txt
|
||||
userfaultfd.rst
|
||||
- description of userfaultfd system call
|
||||
z3fold.txt
|
||||
- outline of z3fold allocator for storing compressed pages
|
||||
zsmalloc.txt
|
||||
zsmalloc.rst
|
||||
- outline of zsmalloc allocator for storing compressed pages
|
||||
zswap.txt
|
||||
zswap.rst
|
||||
- Intro to compressed cache for swap pages
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
.. _active_mm:
|
||||
|
||||
=========
|
||||
Active MM
|
||||
=========
|
||||
|
||||
::
|
||||
|
||||
List: linux-kernel
|
||||
Subject: Re: active_mm
|
||||
From: Linus Torvalds <torvalds () transmeta ! com>
|
||||
Date: 1999-07-30 21:36:24
|
||||
|
||||
Cc'd to linux-kernel, because I don't write explanations all that often,
|
||||
and when I do I feel better about more people reading them.
|
||||
|
||||
On Fri, 30 Jul 1999, David Mosberger wrote:
|
||||
>
|
||||
> Is there a brief description someplace on how "mm" vs. "active_mm" in
|
||||
> the task_struct are supposed to be used? (My apologies if this was
|
||||
> discussed on the mailing lists---I just returned from vacation and
|
||||
> wasn't able to follow linux-kernel for a while).
|
||||
|
||||
Basically, the new setup is:
|
||||
|
||||
- we have "real address spaces" and "anonymous address spaces". The
|
||||
difference is that an anonymous address space doesn't care about the
|
||||
user-level page tables at all, so when we do a context switch into an
|
||||
anonymous address space we just leave the previous address space
|
||||
active.
|
||||
|
||||
The obvious use for a "anonymous address space" is any thread that
|
||||
doesn't need any user mappings - all kernel threads basically fall into
|
||||
this category, but even "real" threads can temporarily say that for
|
||||
some amount of time they are not going to be interested in user space,
|
||||
and that the scheduler might as well try to avoid wasting time on
|
||||
switching the VM state around. Currently only the old-style bdflush
|
||||
sync does that.
|
||||
|
||||
- "tsk->mm" points to the "real address space". For an anonymous process,
|
||||
tsk->mm will be NULL, for the logical reason that an anonymous process
|
||||
really doesn't _have_ a real address space at all.
|
||||
|
||||
- however, we obviously need to keep track of which address space we
|
||||
"stole" for such an anonymous user. For that, we have "tsk->active_mm",
|
||||
which shows what the currently active address space is.
|
||||
|
||||
The rule is that for a process with a real address space (ie tsk->mm is
|
||||
non-NULL) the active_mm obviously always has to be the same as the real
|
||||
one.
|
||||
|
||||
For a anonymous process, tsk->mm == NULL, and tsk->active_mm is the
|
||||
"borrowed" mm while the anonymous process is running. When the
|
||||
anonymous process gets scheduled away, the borrowed address space is
|
||||
returned and cleared.
|
||||
|
||||
To support all that, the "struct mm_struct" now has two counters: a
|
||||
"mm_users" counter that is how many "real address space users" there are,
|
||||
and a "mm_count" counter that is the number of "lazy" users (ie anonymous
|
||||
users) plus one if there are any real users.
|
||||
|
||||
Usually there is at least one real user, but it could be that the real
|
||||
user exited on another CPU while a lazy user was still active, so you do
|
||||
actually get cases where you have a address space that is _only_ used by
|
||||
lazy users. That is often a short-lived state, because once that thread
|
||||
gets scheduled away in favour of a real thread, the "zombie" mm gets
|
||||
released because "mm_users" becomes zero.
|
||||
|
||||
Also, a new rule is that _nobody_ ever has "init_mm" as a real MM any
|
||||
more. "init_mm" should be considered just a "lazy context when no other
|
||||
context is available", and in fact it is mainly used just at bootup when
|
||||
no real VM has yet been created. So code that used to check
|
||||
|
||||
if (current->mm == &init_mm)
|
||||
|
||||
should generally just do
|
||||
|
||||
if (!current->mm)
|
||||
|
||||
instead (which makes more sense anyway - the test is basically one of "do
|
||||
we have a user context", and is generally done by the page fault handler
|
||||
and things like that).
|
||||
|
||||
Anyway, I put a pre-patch-2.3.13-1 on ftp.kernel.org just a moment ago,
|
||||
because it slightly changes the interfaces to accommodate the alpha (who
|
||||
would have thought it, but the alpha actually ends up having one of the
|
||||
ugliest context switch codes - unlike the other architectures where the MM
|
||||
and register state is separate, the alpha PALcode joins the two, and you
|
||||
need to switch both together).
|
||||
|
||||
(From http://marc.info/?l=linux-kernel&m=93337278602211&w=2)
|
||||
@@ -1,83 +0,0 @@
|
||||
List: linux-kernel
|
||||
Subject: Re: active_mm
|
||||
From: Linus Torvalds <torvalds () transmeta ! com>
|
||||
Date: 1999-07-30 21:36:24
|
||||
|
||||
Cc'd to linux-kernel, because I don't write explanations all that often,
|
||||
and when I do I feel better about more people reading them.
|
||||
|
||||
On Fri, 30 Jul 1999, David Mosberger wrote:
|
||||
>
|
||||
> Is there a brief description someplace on how "mm" vs. "active_mm" in
|
||||
> the task_struct are supposed to be used? (My apologies if this was
|
||||
> discussed on the mailing lists---I just returned from vacation and
|
||||
> wasn't able to follow linux-kernel for a while).
|
||||
|
||||
Basically, the new setup is:
|
||||
|
||||
- we have "real address spaces" and "anonymous address spaces". The
|
||||
difference is that an anonymous address space doesn't care about the
|
||||
user-level page tables at all, so when we do a context switch into an
|
||||
anonymous address space we just leave the previous address space
|
||||
active.
|
||||
|
||||
The obvious use for a "anonymous address space" is any thread that
|
||||
doesn't need any user mappings - all kernel threads basically fall into
|
||||
this category, but even "real" threads can temporarily say that for
|
||||
some amount of time they are not going to be interested in user space,
|
||||
and that the scheduler might as well try to avoid wasting time on
|
||||
switching the VM state around. Currently only the old-style bdflush
|
||||
sync does that.
|
||||
|
||||
- "tsk->mm" points to the "real address space". For an anonymous process,
|
||||
tsk->mm will be NULL, for the logical reason that an anonymous process
|
||||
really doesn't _have_ a real address space at all.
|
||||
|
||||
- however, we obviously need to keep track of which address space we
|
||||
"stole" for such an anonymous user. For that, we have "tsk->active_mm",
|
||||
which shows what the currently active address space is.
|
||||
|
||||
The rule is that for a process with a real address space (ie tsk->mm is
|
||||
non-NULL) the active_mm obviously always has to be the same as the real
|
||||
one.
|
||||
|
||||
For a anonymous process, tsk->mm == NULL, and tsk->active_mm is the
|
||||
"borrowed" mm while the anonymous process is running. When the
|
||||
anonymous process gets scheduled away, the borrowed address space is
|
||||
returned and cleared.
|
||||
|
||||
To support all that, the "struct mm_struct" now has two counters: a
|
||||
"mm_users" counter that is how many "real address space users" there are,
|
||||
and a "mm_count" counter that is the number of "lazy" users (ie anonymous
|
||||
users) plus one if there are any real users.
|
||||
|
||||
Usually there is at least one real user, but it could be that the real
|
||||
user exited on another CPU while a lazy user was still active, so you do
|
||||
actually get cases where you have a address space that is _only_ used by
|
||||
lazy users. That is often a short-lived state, because once that thread
|
||||
gets scheduled away in favour of a real thread, the "zombie" mm gets
|
||||
released because "mm_users" becomes zero.
|
||||
|
||||
Also, a new rule is that _nobody_ ever has "init_mm" as a real MM any
|
||||
more. "init_mm" should be considered just a "lazy context when no other
|
||||
context is available", and in fact it is mainly used just at bootup when
|
||||
no real VM has yet been created. So code that used to check
|
||||
|
||||
if (current->mm == &init_mm)
|
||||
|
||||
should generally just do
|
||||
|
||||
if (!current->mm)
|
||||
|
||||
instead (which makes more sense anyway - the test is basically one of "do
|
||||
we have a user context", and is generally done by the page fault handler
|
||||
and things like that).
|
||||
|
||||
Anyway, I put a pre-patch-2.3.13-1 on ftp.kernel.org just a moment ago,
|
||||
because it slightly changes the interfaces to accommodate the alpha (who
|
||||
would have thought it, but the alpha actually ends up having one of the
|
||||
ugliest context switch codes - unlike the other architectures where the MM
|
||||
and register state is separate, the alpha PALcode joins the two, and you
|
||||
need to switch both together).
|
||||
|
||||
(From http://marc.info/?l=linux-kernel&m=93337278602211&w=2)
|
||||
@@ -1,3 +1,9 @@
|
||||
.. _balance:
|
||||
|
||||
================
|
||||
Memory Balancing
|
||||
================
|
||||
|
||||
Started Jan 2000 by Kanoj Sarcar <kanoj@sgi.com>
|
||||
|
||||
Memory balancing is needed for !__GFP_ATOMIC and !__GFP_KSWAPD_RECLAIM as
|
||||
@@ -62,11 +68,11 @@ for non-sleepable allocations. Second, the HIGHMEM zone is also balanced,
|
||||
so as to give a fighting chance for replace_with_highmem() to get a
|
||||
HIGHMEM page, as well as to ensure that HIGHMEM allocations do not
|
||||
fall back into regular zone. This also makes sure that HIGHMEM pages
|
||||
are not leaked (for example, in situations where a HIGHMEM page is in
|
||||
are not leaked (for example, in situations where a HIGHMEM page is in
|
||||
the swapcache but is not being used by anyone)
|
||||
|
||||
kswapd also needs to know about the zones it should balance. kswapd is
|
||||
primarily needed in a situation where balancing can not be done,
|
||||
primarily needed in a situation where balancing can not be done,
|
||||
probably because all allocation requests are coming from intr context
|
||||
and all process contexts are sleeping. For 2.3, kswapd does not really
|
||||
need to balance the highmem zone, since intr context does not request
|
||||
@@ -89,7 +95,8 @@ pages is below watermark[WMARK_LOW]; in which case zone_wake_kswapd is also set.
|
||||
|
||||
|
||||
(Good) Ideas that I have heard:
|
||||
|
||||
1. Dynamic experience should influence balancing: number of failed requests
|
||||
for a zone can be tracked and fed into the balancing scheme (jalvo@mbay.net)
|
||||
for a zone can be tracked and fed into the balancing scheme (jalvo@mbay.net)
|
||||
2. Implement a replace_with_highmem()-like replace_with_regular() to preserve
|
||||
dma pages. (lkd@tantalophile.demon.co.uk)
|
||||
dma pages. (lkd@tantalophile.demon.co.uk)
|
||||
@@ -1,4 +1,11 @@
|
||||
MOTIVATION
|
||||
.. _cleancache:
|
||||
|
||||
==========
|
||||
Cleancache
|
||||
==========
|
||||
|
||||
Motivation
|
||||
==========
|
||||
|
||||
Cleancache is a new optional feature provided by the VFS layer that
|
||||
potentially dramatically increases page cache effectiveness for
|
||||
@@ -21,9 +28,10 @@ Transcendent memory "drivers" for cleancache are currently implemented
|
||||
in Xen (using hypervisor memory) and zcache (using in-kernel compressed
|
||||
memory) and other implementations are in development.
|
||||
|
||||
FAQs are included below.
|
||||
:ref:`FAQs <faq>` are included below.
|
||||
|
||||
IMPLEMENTATION OVERVIEW
|
||||
Implementation Overview
|
||||
=======================
|
||||
|
||||
A cleancache "backend" that provides transcendent memory registers itself
|
||||
to the kernel's cleancache "frontend" by calling cleancache_register_ops,
|
||||
@@ -80,22 +88,33 @@ different Linux threads are simultaneously putting and invalidating a page
|
||||
with the same handle, the results are indeterminate. Callers must
|
||||
lock the page to ensure serial behavior.
|
||||
|
||||
CLEANCACHE PERFORMANCE METRICS
|
||||
Cleancache Performance Metrics
|
||||
==============================
|
||||
|
||||
If properly configured, monitoring of cleancache is done via debugfs in
|
||||
the /sys/kernel/debug/cleancache directory. The effectiveness of cleancache
|
||||
the `/sys/kernel/debug/cleancache` directory. The effectiveness of cleancache
|
||||
can be measured (across all filesystems) with:
|
||||
|
||||
succ_gets - number of gets that were successful
|
||||
failed_gets - number of gets that failed
|
||||
puts - number of puts attempted (all "succeed")
|
||||
invalidates - number of invalidates attempted
|
||||
``succ_gets``
|
||||
number of gets that were successful
|
||||
|
||||
``failed_gets``
|
||||
number of gets that failed
|
||||
|
||||
``puts``
|
||||
number of puts attempted (all "succeed")
|
||||
|
||||
``invalidates``
|
||||
number of invalidates attempted
|
||||
|
||||
A backend implementation may provide additional metrics.
|
||||
|
||||
FAQ
|
||||
.. _faq:
|
||||
|
||||
1) Where's the value? (Andrew Morton)
|
||||
FAQ
|
||||
===
|
||||
|
||||
* Where's the value? (Andrew Morton)
|
||||
|
||||
Cleancache provides a significant performance benefit to many workloads
|
||||
in many environments with negligible overhead by improving the
|
||||
@@ -137,8 +156,8 @@ device that stores pages of data in a compressed state. And
|
||||
the proposed "RAMster" driver shares RAM across multiple physical
|
||||
systems.
|
||||
|
||||
2) Why does cleancache have its sticky fingers so deep inside the
|
||||
filesystems and VFS? (Andrew Morton and Christoph Hellwig)
|
||||
* Why does cleancache have its sticky fingers so deep inside the
|
||||
filesystems and VFS? (Andrew Morton and Christoph Hellwig)
|
||||
|
||||
The core hooks for cleancache in VFS are in most cases a single line
|
||||
and the minimum set are placed precisely where needed to maintain
|
||||
@@ -168,9 +187,9 @@ filesystems in the future.
|
||||
The total impact of the hooks to existing fs and mm files is only
|
||||
about 40 lines added (not counting comments and blank lines).
|
||||
|
||||
3) Why not make cleancache asynchronous and batched so it can
|
||||
more easily interface with real devices with DMA instead
|
||||
of copying each individual page? (Minchan Kim)
|
||||
* Why not make cleancache asynchronous and batched so it can more
|
||||
easily interface with real devices with DMA instead of copying each
|
||||
individual page? (Minchan Kim)
|
||||
|
||||
The one-page-at-a-time copy semantics simplifies the implementation
|
||||
on both the frontend and backend and also allows the backend to
|
||||
@@ -182,8 +201,8 @@ are avoided. While the interface seems odd for a "real device"
|
||||
or for real kernel-addressable RAM, it makes perfect sense for
|
||||
transcendent memory.
|
||||
|
||||
4) Why is non-shared cleancache "exclusive"? And where is the
|
||||
page "invalidated" after a "get"? (Minchan Kim)
|
||||
* Why is non-shared cleancache "exclusive"? And where is the
|
||||
page "invalidated" after a "get"? (Minchan Kim)
|
||||
|
||||
The main reason is to free up space in transcendent memory and
|
||||
to avoid unnecessary cleancache_invalidate calls. If you want inclusive,
|
||||
@@ -193,7 +212,7 @@ be easily extended to add a "get_no_invalidate" call.
|
||||
|
||||
The invalidate is done by the cleancache backend implementation.
|
||||
|
||||
5) What's the performance impact?
|
||||
* What's the performance impact?
|
||||
|
||||
Performance analysis has been presented at OLS'09 and LCA'10.
|
||||
Briefly, performance gains can be significant on most workloads,
|
||||
@@ -206,7 +225,7 @@ single-core systems with slow memory-copy speeds, cleancache
|
||||
has little value, but in newer multicore machines, especially
|
||||
consolidated/virtualized machines, it has great value.
|
||||
|
||||
6) How do I add cleancache support for filesystem X? (Boaz Harrash)
|
||||
* How do I add cleancache support for filesystem X? (Boaz Harrash)
|
||||
|
||||
Filesystems that are well-behaved and conform to certain
|
||||
restrictions can utilize cleancache simply by making a call to
|
||||
@@ -217,26 +236,26 @@ not enable the optional cleancache.
|
||||
|
||||
Some points for a filesystem to consider:
|
||||
|
||||
- The FS should be block-device-based (e.g. a ram-based FS such
|
||||
as tmpfs should not enable cleancache)
|
||||
- To ensure coherency/correctness, the FS must ensure that all
|
||||
file removal or truncation operations either go through VFS or
|
||||
add hooks to do the equivalent cleancache "invalidate" operations
|
||||
- To ensure coherency/correctness, either inode numbers must
|
||||
be unique across the lifetime of the on-disk file OR the
|
||||
FS must provide an "encode_fh" function.
|
||||
- The FS must call the VFS superblock alloc and deactivate routines
|
||||
or add hooks to do the equivalent cleancache calls done there.
|
||||
- To maximize performance, all pages fetched from the FS should
|
||||
go through the do_mpag_readpage routine or the FS should add
|
||||
hooks to do the equivalent (cf. btrfs)
|
||||
- Currently, the FS blocksize must be the same as PAGESIZE. This
|
||||
is not an architectural restriction, but no backends currently
|
||||
support anything different.
|
||||
- A clustered FS should invoke the "shared_init_fs" cleancache
|
||||
hook to get best performance for some backends.
|
||||
- The FS should be block-device-based (e.g. a ram-based FS such
|
||||
as tmpfs should not enable cleancache)
|
||||
- To ensure coherency/correctness, the FS must ensure that all
|
||||
file removal or truncation operations either go through VFS or
|
||||
add hooks to do the equivalent cleancache "invalidate" operations
|
||||
- To ensure coherency/correctness, either inode numbers must
|
||||
be unique across the lifetime of the on-disk file OR the
|
||||
FS must provide an "encode_fh" function.
|
||||
- The FS must call the VFS superblock alloc and deactivate routines
|
||||
or add hooks to do the equivalent cleancache calls done there.
|
||||
- To maximize performance, all pages fetched from the FS should
|
||||
go through the do_mpag_readpage routine or the FS should add
|
||||
hooks to do the equivalent (cf. btrfs)
|
||||
- Currently, the FS blocksize must be the same as PAGESIZE. This
|
||||
is not an architectural restriction, but no backends currently
|
||||
support anything different.
|
||||
- A clustered FS should invoke the "shared_init_fs" cleancache
|
||||
hook to get best performance for some backends.
|
||||
|
||||
7) Why not use the KVA of the inode as the key? (Christoph Hellwig)
|
||||
* Why not use the KVA of the inode as the key? (Christoph Hellwig)
|
||||
|
||||
If cleancache would use the inode virtual address instead of
|
||||
inode/filehandle, the pool id could be eliminated. But, this
|
||||
@@ -251,7 +270,7 @@ of cleancache would be lost because the cache of pages in cleanache
|
||||
is potentially much larger than the kernel pagecache and is most
|
||||
useful if the pages survive inode cache removal.
|
||||
|
||||
8) Why is a global variable required?
|
||||
* Why is a global variable required?
|
||||
|
||||
The cleancache_enabled flag is checked in all of the frequently-used
|
||||
cleancache hooks. The alternative is a function call to check a static
|
||||
@@ -262,14 +281,14 @@ global variable allows cleancache to be enabled by default at compile
|
||||
time, but have insignificant performance impact when cleancache remains
|
||||
disabled at runtime.
|
||||
|
||||
9) Does cleanache work with KVM?
|
||||
* Does cleanache work with KVM?
|
||||
|
||||
The memory model of KVM is sufficiently different that a cleancache
|
||||
backend may have less value for KVM. This remains to be tested,
|
||||
especially in an overcommitted system.
|
||||
|
||||
10) Does cleancache work in userspace? It sounds useful for
|
||||
memory hungry caches like web browsers. (Jamie Lokier)
|
||||
* Does cleancache work in userspace? It sounds useful for
|
||||
memory hungry caches like web browsers. (Jamie Lokier)
|
||||
|
||||
No plans yet, though we agree it sounds useful, at least for
|
||||
apps that bypass the page cache (e.g. O_DIRECT).
|
||||
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8; mode: python -*-
|
||||
|
||||
project = "Linux Memory Management Documentation"
|
||||
|
||||
tags.add("subproject")
|
||||
|
||||
latex_documents = [
|
||||
('index', 'memory-management.tex', project,
|
||||
'The kernel development community', 'manual'),
|
||||
]
|
||||
@@ -1,13 +1,20 @@
|
||||
.. _frontswap:
|
||||
|
||||
=========
|
||||
Frontswap
|
||||
=========
|
||||
|
||||
Frontswap provides a "transcendent memory" interface for swap pages.
|
||||
In some environments, dramatic performance savings may be obtained because
|
||||
swapped pages are saved in RAM (or a RAM-like device) instead of a swap disk.
|
||||
|
||||
(Note, frontswap -- and cleancache (merged at 3.0) -- are the "frontends"
|
||||
(Note, frontswap -- and :ref:`cleancache` (merged at 3.0) -- are the "frontends"
|
||||
and the only necessary changes to the core kernel for transcendent memory;
|
||||
all other supporting code -- the "backends" -- is implemented as drivers.
|
||||
See the LWN.net article "Transcendent memory in a nutshell" for a detailed
|
||||
overview of frontswap and related kernel parts:
|
||||
https://lwn.net/Articles/454795/ )
|
||||
See the LWN.net article `Transcendent memory in a nutshell`_
|
||||
for a detailed overview of frontswap and related kernel parts)
|
||||
|
||||
.. _Transcendent memory in a nutshell: https://lwn.net/Articles/454795/
|
||||
|
||||
Frontswap is so named because it can be thought of as the opposite of
|
||||
a "backing" store for a swap device. The storage is assumed to be
|
||||
@@ -50,19 +57,27 @@ or the store fails AND the page is invalidated. This ensures stale data may
|
||||
never be obtained from frontswap.
|
||||
|
||||
If properly configured, monitoring of frontswap is done via debugfs in
|
||||
the /sys/kernel/debug/frontswap directory. The effectiveness of
|
||||
the `/sys/kernel/debug/frontswap` directory. The effectiveness of
|
||||
frontswap can be measured (across all swap devices) with:
|
||||
|
||||
failed_stores - how many store attempts have failed
|
||||
loads - how many loads were attempted (all should succeed)
|
||||
succ_stores - how many store attempts have succeeded
|
||||
invalidates - how many invalidates were attempted
|
||||
``failed_stores``
|
||||
how many store attempts have failed
|
||||
|
||||
``loads``
|
||||
how many loads were attempted (all should succeed)
|
||||
|
||||
``succ_stores``
|
||||
how many store attempts have succeeded
|
||||
|
||||
``invalidates``
|
||||
how many invalidates were attempted
|
||||
|
||||
A backend implementation may provide additional metrics.
|
||||
|
||||
FAQ
|
||||
===
|
||||
|
||||
1) Where's the value?
|
||||
* Where's the value?
|
||||
|
||||
When a workload starts swapping, performance falls through the floor.
|
||||
Frontswap significantly increases performance in many such workloads by
|
||||
@@ -117,8 +132,8 @@ A KVM implementation is underway and has been RFC'ed to lkml. And,
|
||||
using frontswap, investigation is also underway on the use of NVM as
|
||||
a memory extension technology.
|
||||
|
||||
2) Sure there may be performance advantages in some situations, but
|
||||
what's the space/time overhead of frontswap?
|
||||
* Sure there may be performance advantages in some situations, but
|
||||
what's the space/time overhead of frontswap?
|
||||
|
||||
If CONFIG_FRONTSWAP is disabled, every frontswap hook compiles into
|
||||
nothingness and the only overhead is a few extra bytes per swapon'ed
|
||||
@@ -148,8 +163,8 @@ pressure that can potentially outweigh the other advantages. A
|
||||
backend, such as zcache, must implement policies to carefully (but
|
||||
dynamically) manage memory limits to ensure this doesn't happen.
|
||||
|
||||
3) OK, how about a quick overview of what this frontswap patch does
|
||||
in terms that a kernel hacker can grok?
|
||||
* OK, how about a quick overview of what this frontswap patch does
|
||||
in terms that a kernel hacker can grok?
|
||||
|
||||
Let's assume that a frontswap "backend" has registered during
|
||||
kernel initialization; this registration indicates that this
|
||||
@@ -188,9 +203,9 @@ and (potentially) a swap device write are replaced by a "frontswap backend
|
||||
store" and (possibly) a "frontswap backend loads", which are presumably much
|
||||
faster.
|
||||
|
||||
4) Can't frontswap be configured as a "special" swap device that is
|
||||
just higher priority than any real swap device (e.g. like zswap,
|
||||
or maybe swap-over-nbd/NFS)?
|
||||
* Can't frontswap be configured as a "special" swap device that is
|
||||
just higher priority than any real swap device (e.g. like zswap,
|
||||
or maybe swap-over-nbd/NFS)?
|
||||
|
||||
No. First, the existing swap subsystem doesn't allow for any kind of
|
||||
swap hierarchy. Perhaps it could be rewritten to accommodate a hierarchy,
|
||||
@@ -240,9 +255,9 @@ installation, frontswap is useless. Swapless portable devices
|
||||
can still use frontswap but a backend for such devices must configure
|
||||
some kind of "ghost" swap device and ensure that it is never used.
|
||||
|
||||
5) Why this weird definition about "duplicate stores"? If a page
|
||||
has been previously successfully stored, can't it always be
|
||||
successfully overwritten?
|
||||
* Why this weird definition about "duplicate stores"? If a page
|
||||
has been previously successfully stored, can't it always be
|
||||
successfully overwritten?
|
||||
|
||||
Nearly always it can, but no, sometimes it cannot. Consider an example
|
||||
where data is compressed and the original 4K page has been compressed
|
||||
@@ -254,7 +269,7 @@ the old data and ensure that it is no longer accessible. Since the
|
||||
swap subsystem then writes the new data to the read swap device,
|
||||
this is the correct course of action to ensure coherency.
|
||||
|
||||
6) What is frontswap_shrink for?
|
||||
* What is frontswap_shrink for?
|
||||
|
||||
When the (non-frontswap) swap subsystem swaps out a page to a real
|
||||
swap device, that page is only taking up low-value pre-allocated disk
|
||||
@@ -267,7 +282,7 @@ to "repatriate" pages sent to a remote machine back to the local machine;
|
||||
this is driven using the frontswap_shrink mechanism when memory pressure
|
||||
subsides.
|
||||
|
||||
7) Why does the frontswap patch create the new include file swapfile.h?
|
||||
* Why does the frontswap patch create the new include file swapfile.h?
|
||||
|
||||
The frontswap code depends on some swap-subsystem-internal data
|
||||
structures that have, over the years, moved back and forth between
|
||||
@@ -1,25 +1,14 @@
|
||||
.. _highmem:
|
||||
|
||||
====================
|
||||
HIGH MEMORY HANDLING
|
||||
====================
|
||||
====================
|
||||
High Memory Handling
|
||||
====================
|
||||
|
||||
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
|
||||
@@ -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.
|
||||
|
||||
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
|
||||
| Kernel |
|
||||
@@ -58,40 +47,38 @@ and user maps. Some hardware (like some ARMs), however, have limited virtual
|
||||
space when they use mm context tags.
|
||||
|
||||
|
||||
==========================
|
||||
TEMPORARY VIRTUAL MAPPINGS
|
||||
Temporary Virtual Mappings
|
||||
==========================
|
||||
|
||||
The kernel contains several ways of creating temporary mappings:
|
||||
|
||||
(*) vmap(). This can be used to make a long duration mapping of multiple
|
||||
physical pages into a contiguous virtual space. It needs global
|
||||
synchronization to unmap.
|
||||
* vmap(). This can be used to make a long duration mapping of multiple
|
||||
physical pages into a contiguous virtual space. It needs global
|
||||
synchronization to unmap.
|
||||
|
||||
(*) kmap(). This permits a short duration mapping of a single page. It needs
|
||||
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
|
||||
new code.
|
||||
* kmap(). This permits a short duration mapping of a single page. It needs
|
||||
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
|
||||
new code.
|
||||
|
||||
(*) 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
|
||||
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.
|
||||
* 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
|
||||
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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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
|
||||
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
|
||||
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. */
|
||||
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
|
||||
not the argument.
|
||||
|
||||
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);
|
||||
vaddr2 = kmap_atomic(page2);
|
||||
@@ -120,8 +107,7 @@ another you need to keep the kmap_atomic calls strictly nested, like:
|
||||
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
|
||||
@@ -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.
|
||||
|
||||
|
||||
========
|
||||
i386 PAE
|
||||
========
|
||||
|
||||
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:
|
||||
|
||||
(*) Linux needs a page-frame structure for each page in the system and the
|
||||
pageframes need to live in the permanent mapping, which means:
|
||||
* Linux needs a page-frame structure for each page in the system and the
|
||||
pageframes need to live in the permanent mapping, which means:
|
||||
|
||||
(*) 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
|
||||
worth of pages; the kernel, however, needs to store more than just
|
||||
page-frames in that memory...
|
||||
* 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
|
||||
worth of pages; the kernel, however, needs to store more than just
|
||||
page-frames in that memory...
|
||||
|
||||
(*) 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
|
||||
advantage is that PAE has more PTE bits and can provide advanced features
|
||||
like NX and PAT.
|
||||
* 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
|
||||
advantage is that PAE has more PTE bits and can provide advanced features
|
||||
like NX and PAT.
|
||||
|
||||
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
|
||||
@@ -1,4 +1,8 @@
|
||||
.. hmm:
|
||||
|
||||
=====================================
|
||||
Heterogeneous Memory Management (HMM)
|
||||
=====================================
|
||||
|
||||
Provide infrastructure and helpers to integrate non-conventional memory (device
|
||||
memory like GPU on board memory) into regular kernel path, with the cornerstone
|
||||
@@ -6,10 +10,10 @@ of this being specialized struct page for such memory (see sections 5 to 7 of
|
||||
this document).
|
||||
|
||||
HMM also provides optional helpers for SVM (Share Virtual Memory), i.e.,
|
||||
allowing a device to transparently access program address coherently with the
|
||||
CPU meaning that any valid pointer on the CPU is also a valid pointer for the
|
||||
device. This is becoming mandatory to simplify the use of advanced hetero-
|
||||
geneous computing where GPU, DSP, or FPGA are used to perform various
|
||||
allowing a device to transparently access program address coherently with
|
||||
the CPU meaning that any valid pointer on the CPU is also a valid pointer
|
||||
for the device. This is becoming mandatory to simplify the use of advanced
|
||||
heterogeneous computing where GPU, DSP, or FPGA are used to perform various
|
||||
computations on behalf of a process.
|
||||
|
||||
This document is divided as follows: in the first section I expose the problems
|
||||
@@ -21,19 +25,10 @@ fifth section deals with how device memory is represented inside the kernel.
|
||||
Finally, the last section presents a new migration helper that allows lever-
|
||||
aging the device DMA engine.
|
||||
|
||||
.. contents:: :local:
|
||||
|
||||
1) Problems of using a device specific memory allocator:
|
||||
2) I/O bus, device memory characteristics
|
||||
3) Shared address space and migration
|
||||
4) Address space mirroring implementation and API
|
||||
5) Represent and manage device memory from core kernel point of view
|
||||
6) Migration to and from device memory
|
||||
7) Memory cgroup (memcg) and rss accounting
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
1) Problems of using a device specific memory allocator:
|
||||
Problems of using a device specific memory allocator
|
||||
====================================================
|
||||
|
||||
Devices with a large amount of on board memory (several gigabytes) like GPUs
|
||||
have historically managed their memory through dedicated driver specific APIs.
|
||||
@@ -77,9 +72,8 @@ are only do-able with a shared address space. It is also more reasonable to use
|
||||
a shared address space for all other patterns.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
2) I/O bus, device memory characteristics
|
||||
I/O bus, device memory characteristics
|
||||
======================================
|
||||
|
||||
I/O buses cripple shared address spaces due to a few limitations. Most I/O
|
||||
buses only allow basic memory access from device to main memory; even cache
|
||||
@@ -109,9 +103,8 @@ access any memory but we must also permit any memory to be migrated to device
|
||||
memory while device is using it (blocking CPU access while it happens).
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
3) Shared address space and migration
|
||||
Shared address space and migration
|
||||
==================================
|
||||
|
||||
HMM intends to provide two main features. First one is to share the address
|
||||
space by duplicating the CPU page table in the device page table so the same
|
||||
@@ -148,23 +141,23 @@ ages device memory by migrating the part of the data set that is actively being
|
||||
used by the device.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
4) Address space mirroring implementation and API
|
||||
Address space mirroring implementation and API
|
||||
==============================================
|
||||
|
||||
Address space mirroring's main objective is to allow duplication of a range of
|
||||
CPU page table into a device page table; HMM helps keep both synchronized. A
|
||||
device driver that wants to mirror a process address space must start with the
|
||||
registration of an hmm_mirror struct:
|
||||
registration of an hmm_mirror struct::
|
||||
|
||||
int hmm_mirror_register(struct hmm_mirror *mirror,
|
||||
struct mm_struct *mm);
|
||||
int hmm_mirror_register_locked(struct hmm_mirror *mirror,
|
||||
struct mm_struct *mm);
|
||||
|
||||
|
||||
The locked variant is to be used when the driver is already holding mmap_sem
|
||||
of the mm in write mode. The mirror struct has a set of callbacks that are used
|
||||
to propagate CPU page tables:
|
||||
to propagate CPU page tables::
|
||||
|
||||
struct hmm_mirror_ops {
|
||||
/* sync_cpu_device_pagetables() - synchronize page tables
|
||||
@@ -193,10 +186,10 @@ The device driver must perform the update action to the range (mark range
|
||||
read only, or fully unmap, ...). The device must be done with the update before
|
||||
the driver callback returns.
|
||||
|
||||
|
||||
When the device driver wants to populate a range of virtual addresses, it can
|
||||
use either:
|
||||
int hmm_vma_get_pfns(struct vm_area_struct *vma,
|
||||
use either::
|
||||
|
||||
int hmm_vma_get_pfns(struct vm_area_struct *vma,
|
||||
struct hmm_range *range,
|
||||
unsigned long start,
|
||||
unsigned long end,
|
||||
@@ -221,7 +214,7 @@ provides a set of flags to help the driver identify special CPU page table
|
||||
entries.
|
||||
|
||||
Locking with the update() callback is the most important aspect the driver must
|
||||
respect in order to keep things properly synchronized. The usage pattern is:
|
||||
respect in order to keep things properly synchronized. The usage pattern is::
|
||||
|
||||
int driver_populate_range(...)
|
||||
{
|
||||
@@ -262,9 +255,8 @@ report commands as executed is serialized (there is no point in doing this
|
||||
concurrently).
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
5) Represent and manage device memory from core kernel point of view
|
||||
Represent and manage device memory from core kernel point of view
|
||||
=================================================================
|
||||
|
||||
Several different designs were tried to support device memory. First one used
|
||||
a device specific data structure to keep information about migrated memory and
|
||||
@@ -280,14 +272,14 @@ unaware of the difference. We only need to make sure that no one ever tries to
|
||||
map those pages from the CPU side.
|
||||
|
||||
HMM provides a set of helpers to register and hotplug device memory as a new
|
||||
region needing a struct page. This is offered through a very simple API:
|
||||
region needing a struct page. This is offered through a very simple API::
|
||||
|
||||
struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops,
|
||||
struct device *device,
|
||||
unsigned long size);
|
||||
void hmm_devmem_remove(struct hmm_devmem *devmem);
|
||||
|
||||
The hmm_devmem_ops is where most of the important things are:
|
||||
The hmm_devmem_ops is where most of the important things are::
|
||||
|
||||
struct hmm_devmem_ops {
|
||||
void (*free)(struct hmm_devmem *devmem, struct page *page);
|
||||
@@ -306,13 +298,12 @@ which it cannot do. This second callback must trigger a migration back to
|
||||
system memory.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
6) Migration to and from device memory
|
||||
Migration to and from device memory
|
||||
===================================
|
||||
|
||||
Because the CPU cannot access device memory, migration must use the device DMA
|
||||
engine to perform copy from and to device memory. For this we need a new
|
||||
migration helper:
|
||||
migration helper::
|
||||
|
||||
int migrate_vma(const struct migrate_vma_ops *ops,
|
||||
struct vm_area_struct *vma,
|
||||
@@ -331,7 +322,7 @@ migration might be for a range of addresses the device is actively accessing.
|
||||
|
||||
The migrate_vma_ops struct defines two callbacks. First one (alloc_and_copy())
|
||||
controls destination memory allocation and copy operation. Second one is there
|
||||
to allow the device driver to perform cleanup operations after migration.
|
||||
to allow the device driver to perform cleanup operations after migration::
|
||||
|
||||
struct migrate_vma_ops {
|
||||
void (*alloc_and_copy)(struct vm_area_struct *vma,
|
||||
@@ -365,9 +356,8 @@ bandwidth but this is considered as a rare event and a price that we are
|
||||
willing to pay to keep all the code simpler.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
7) Memory cgroup (memcg) and rss accounting
|
||||
Memory cgroup (memcg) and rss accounting
|
||||
========================================
|
||||
|
||||
For now device memory is accounted as any regular page in rss counters (either
|
||||
anonymous if device page is used for anonymous, file if device page is used for
|
||||
@@ -1,6 +1,13 @@
|
||||
Hugetlbfs Reservation Overview
|
||||
------------------------------
|
||||
Huge pages as described at 'Documentation/vm/hugetlbpage.txt' are typically
|
||||
.. _hugetlbfs_reserve:
|
||||
|
||||
=====================
|
||||
Hugetlbfs Reservation
|
||||
=====================
|
||||
|
||||
Overview
|
||||
========
|
||||
|
||||
Huge pages as described at :ref:`hugetlbpage` are typically
|
||||
preallocated for application use. These huge pages are instantiated in a
|
||||
task's address space at page fault time if the VMA indicates huge pages are
|
||||
to be used. If no huge page exists at page fault time, the task is sent
|
||||
@@ -17,47 +24,55 @@ describe how huge page reserve processing is done in the v4.10 kernel.
|
||||
|
||||
|
||||
Audience
|
||||
--------
|
||||
========
|
||||
This description is primarily targeted at kernel developers who are modifying
|
||||
hugetlbfs code.
|
||||
|
||||
|
||||
The Data Structures
|
||||
-------------------
|
||||
===================
|
||||
|
||||
resv_huge_pages
|
||||
This is a global (per-hstate) count of reserved huge pages. Reserved
|
||||
huge pages are only available to the task which reserved them.
|
||||
Therefore, the number of huge pages generally available is computed
|
||||
as (free_huge_pages - resv_huge_pages).
|
||||
as (``free_huge_pages - resv_huge_pages``).
|
||||
Reserve Map
|
||||
A reserve map is described by the structure:
|
||||
struct resv_map {
|
||||
struct kref refs;
|
||||
spinlock_t lock;
|
||||
struct list_head regions;
|
||||
long adds_in_progress;
|
||||
struct list_head region_cache;
|
||||
long region_cache_count;
|
||||
};
|
||||
A reserve map is described by the structure::
|
||||
|
||||
struct resv_map {
|
||||
struct kref refs;
|
||||
spinlock_t lock;
|
||||
struct list_head regions;
|
||||
long adds_in_progress;
|
||||
struct list_head region_cache;
|
||||
long region_cache_count;
|
||||
};
|
||||
|
||||
There is one reserve map for each huge page mapping in the system.
|
||||
The regions list within the resv_map describes the regions within
|
||||
the mapping. A region is described as:
|
||||
struct file_region {
|
||||
struct list_head link;
|
||||
long from;
|
||||
long to;
|
||||
};
|
||||
the mapping. A region is described as::
|
||||
|
||||
struct file_region {
|
||||
struct list_head link;
|
||||
long from;
|
||||
long to;
|
||||
};
|
||||
|
||||
The 'from' and 'to' fields of the file region structure are huge page
|
||||
indices into the mapping. Depending on the type of mapping, a
|
||||
region in the reserv_map may indicate reservations exist for the
|
||||
range, or reservations do not exist.
|
||||
Flags for MAP_PRIVATE Reservations
|
||||
These are stored in the bottom bits of the reservation map pointer.
|
||||
#define HPAGE_RESV_OWNER (1UL << 0) Indicates this task is the
|
||||
owner of the reservations associated with the mapping.
|
||||
#define HPAGE_RESV_UNMAPPED (1UL << 1) Indicates task originally
|
||||
mapping this range (and creating reserves) has unmapped a
|
||||
page from this task (the child) due to a failed COW.
|
||||
|
||||
``#define HPAGE_RESV_OWNER (1UL << 0)``
|
||||
Indicates this task is the owner of the reservations
|
||||
associated with the mapping.
|
||||
``#define HPAGE_RESV_UNMAPPED (1UL << 1)``
|
||||
Indicates task originally mapping this range (and creating
|
||||
reserves) has unmapped a page from this task (the child)
|
||||
due to a failed COW.
|
||||
Page Flags
|
||||
The PagePrivate page flag is used to indicate that a huge page
|
||||
reservation must be restored when the huge page is freed. More
|
||||
@@ -65,12 +80,14 @@ Page Flags
|
||||
|
||||
|
||||
Reservation Map Location (Private or Shared)
|
||||
--------------------------------------------
|
||||
============================================
|
||||
|
||||
A huge page mapping or segment is either private or shared. If private,
|
||||
it is typically only available to a single address space (task). If shared,
|
||||
it can be mapped into multiple address spaces (tasks). The location and
|
||||
semantics of the reservation map is significantly different for two types
|
||||
of mappings. Location differences are:
|
||||
|
||||
- For private mappings, the reservation map hangs off the the VMA structure.
|
||||
Specifically, vma->vm_private_data. This reserve map is created at the
|
||||
time the mapping (mmap(MAP_PRIVATE)) is created.
|
||||
@@ -82,15 +99,15 @@ of mappings. Location differences are:
|
||||
|
||||
|
||||
Creating Reservations
|
||||
---------------------
|
||||
=====================
|
||||
Reservations are created when a huge page backed shared memory segment is
|
||||
created (shmget(SHM_HUGETLB)) or a mapping is created via mmap(MAP_HUGETLB).
|
||||
These operations result in a call to the routine hugetlb_reserve_pages()
|
||||
These operations result in a call to the routine hugetlb_reserve_pages()::
|
||||
|
||||
int hugetlb_reserve_pages(struct inode *inode,
|
||||
long from, long to,
|
||||
struct vm_area_struct *vma,
|
||||
vm_flags_t vm_flags)
|
||||
int hugetlb_reserve_pages(struct inode *inode,
|
||||
long from, long to,
|
||||
struct vm_area_struct *vma,
|
||||
vm_flags_t vm_flags)
|
||||
|
||||
The first thing hugetlb_reserve_pages() does is check for the NORESERVE
|
||||
flag was specified in either the shmget() or mmap() call. If NORESERVE
|
||||
@@ -105,6 +122,7 @@ the 'from' and 'to' arguments have been adjusted by this offset.
|
||||
|
||||
One of the big differences between PRIVATE and SHARED mappings is the way
|
||||
in which reservations are represented in the reservation map.
|
||||
|
||||
- For shared mappings, an entry in the reservation map indicates a reservation
|
||||
exists or did exist for the corresponding page. As reservations are
|
||||
consumed, the reservation map is not modified.
|
||||
@@ -121,12 +139,13 @@ to indicate this VMA owns the reservations.
|
||||
The reservation map is consulted to determine how many huge page reservations
|
||||
are needed for the current mapping/segment. For private mappings, this is
|
||||
always the value (to - from). However, for shared mappings it is possible that some reservations may already exist within the range (to - from). See the
|
||||
section "Reservation Map Modifications" for details on how this is accomplished.
|
||||
section :ref:`Reservation Map Modifications <resv_map_modifications>`
|
||||
for details on how this is accomplished.
|
||||
|
||||
The mapping may be associated with a subpool. If so, the subpool is consulted
|
||||
to ensure there is sufficient space for the mapping. It is possible that the
|
||||
subpool has set aside reservations that can be used for the mapping. See the
|
||||
section "Subpool Reservations" for more details.
|
||||
section :ref:`Subpool Reservations <sub_pool_resv>` for more details.
|
||||
|
||||
After consulting the reservation map and subpool, the number of needed new
|
||||
reservations is known. The routine hugetlb_acct_memory() is called to check
|
||||
@@ -135,9 +154,11 @@ calls into routines that potentially allocate and adjust surplus page counts.
|
||||
However, within those routines the code is simply checking to ensure there
|
||||
are enough free huge pages to accommodate the reservation. If there are,
|
||||
the global reservation count resv_huge_pages is adjusted something like the
|
||||
following.
|
||||
following::
|
||||
|
||||
if (resv_needed <= (resv_huge_pages - free_huge_pages))
|
||||
resv_huge_pages += resv_needed;
|
||||
|
||||
Note that the global lock hugetlb_lock is held when checking and adjusting
|
||||
these counters.
|
||||
|
||||
@@ -152,14 +173,18 @@ If hugetlb_reserve_pages() was successful, the global reservation count and
|
||||
reservation map associated with the mapping will be modified as required to
|
||||
ensure reservations exist for the range 'from' - 'to'.
|
||||
|
||||
.. _consume_resv:
|
||||
|
||||
Consuming Reservations/Allocating a Huge Page
|
||||
---------------------------------------------
|
||||
=============================================
|
||||
|
||||
Reservations are consumed when huge pages associated with the reservations
|
||||
are allocated and instantiated in the corresponding mapping. The allocation
|
||||
is performed within the routine alloc_huge_page().
|
||||
struct page *alloc_huge_page(struct vm_area_struct *vma,
|
||||
unsigned long addr, int avoid_reserve)
|
||||
is performed within the routine alloc_huge_page()::
|
||||
|
||||
struct page *alloc_huge_page(struct vm_area_struct *vma,
|
||||
unsigned long addr, int avoid_reserve)
|
||||
|
||||
alloc_huge_page is passed a VMA pointer and a virtual address, so it can
|
||||
consult the reservation map to determine if a reservation exists. In addition,
|
||||
alloc_huge_page takes the argument avoid_reserve which indicates reserves
|
||||
@@ -170,8 +195,9 @@ page are being allocated.
|
||||
|
||||
The helper routine vma_needs_reservation() is called to determine if a
|
||||
reservation exists for the address within the mapping(vma). See the section
|
||||
"Reservation Map Helper Routines" for detailed information on what this
|
||||
routine does. The value returned from vma_needs_reservation() is generally
|
||||
:ref:`Reservation Map Helper Routines <resv_map_helpers>` for detailed
|
||||
information on what this routine does.
|
||||
The value returned from vma_needs_reservation() is generally
|
||||
0 or 1. 0 if a reservation exists for the address, 1 if no reservation exists.
|
||||
If a reservation does not exist, and there is a subpool associated with the
|
||||
mapping the subpool is consulted to determine if it contains reservations.
|
||||
@@ -180,21 +206,25 @@ However, in every case the avoid_reserve argument overrides the use of
|
||||
a reservation for the allocation. After determining whether a reservation
|
||||
exists and can be used for the allocation, the routine dequeue_huge_page_vma()
|
||||
is called. This routine takes two arguments related to reservations:
|
||||
|
||||
- avoid_reserve, this is the same value/argument passed to alloc_huge_page()
|
||||
- chg, even though this argument is of type long only the values 0 or 1 are
|
||||
passed to dequeue_huge_page_vma. If the value is 0, it indicates a
|
||||
reservation exists (see the section "Memory Policy and Reservations" for
|
||||
possible issues). If the value is 1, it indicates a reservation does not
|
||||
exist and the page must be taken from the global free pool if possible.
|
||||
|
||||
The free lists associated with the memory policy of the VMA are searched for
|
||||
a free page. If a page is found, the value free_huge_pages is decremented
|
||||
when the page is removed from the free list. If there was a reservation
|
||||
associated with the page, the following adjustments are made:
|
||||
associated with the page, the following adjustments are made::
|
||||
|
||||
SetPagePrivate(page); /* Indicates allocating this page consumed
|
||||
* a reservation, and if an error is
|
||||
* encountered such that the page must be
|
||||
* freed, the reservation will be restored. */
|
||||
resv_huge_pages--; /* Decrement the global reservation count */
|
||||
|
||||
Note, if no huge page can be found that satisfies the VMA's memory policy
|
||||
an attempt will be made to allocate one using the buddy allocator. This
|
||||
brings up the issue of surplus huge pages and overcommit which is beyond
|
||||
@@ -222,12 +252,14 @@ mapping. In such cases, the reservation count and subpool free page count
|
||||
will be off by one. This rare condition can be identified by comparing the
|
||||
return value from vma_needs_reservation and vma_commit_reservation. If such
|
||||
a race is detected, the subpool and global reserve counts are adjusted to
|
||||
compensate. See the section "Reservation Map Helper Routines" for more
|
||||
compensate. See the section
|
||||
:ref:`Reservation Map Helper Routines <resv_map_helpers>` for more
|
||||
information on these routines.
|
||||
|
||||
|
||||
Instantiate Huge Pages
|
||||
----------------------
|
||||
======================
|
||||
|
||||
After huge page allocation, the page is typically added to the page tables
|
||||
of the allocating task. Before this, pages in a shared mapping are added
|
||||
to the page cache and pages in private mappings are added to an anonymous
|
||||
@@ -237,7 +269,8 @@ to the global reservation count (resv_huge_pages).
|
||||
|
||||
|
||||
Freeing Huge Pages
|
||||
------------------
|
||||
==================
|
||||
|
||||
Huge page freeing is performed by the routine free_huge_page(). This routine
|
||||
is the destructor for hugetlbfs compound pages. As a result, it is only
|
||||
passed a pointer to the page struct. When a huge page is freed, reservation
|
||||
@@ -247,7 +280,8 @@ on an error path where a global reserve count must be restored.
|
||||
|
||||
The page->private field points to any subpool associated with the page.
|
||||
If the PagePrivate flag is set, it indicates the global reserve count should
|
||||
be adjusted (see the section "Consuming Reservations/Allocating a Huge Page"
|
||||
be adjusted (see the section
|
||||
:ref:`Consuming Reservations/Allocating a Huge Page <consume_resv>`
|
||||
for information on how these are set).
|
||||
|
||||
The routine first calls hugepage_subpool_put_pages() for the page. If this
|
||||
@@ -259,9 +293,11 @@ Therefore, the global resv_huge_pages counter is incremented in this case.
|
||||
If the PagePrivate flag was set in the page, the global resv_huge_pages counter
|
||||
will always be incremented.
|
||||
|
||||
.. _sub_pool_resv:
|
||||
|
||||
Subpool Reservations
|
||||
--------------------
|
||||
====================
|
||||
|
||||
There is a struct hstate associated with each huge page size. The hstate
|
||||
tracks all huge pages of the specified size. A subpool represents a subset
|
||||
of pages within a hstate that is associated with a mounted hugetlbfs
|
||||
@@ -295,7 +331,8 @@ the global pools.
|
||||
|
||||
|
||||
COW and Reservations
|
||||
--------------------
|
||||
====================
|
||||
|
||||
Since shared mappings all point to and use the same underlying pages, the
|
||||
biggest reservation concern for COW is private mappings. In this case,
|
||||
two tasks can be pointing at the same previously allocated page. One task
|
||||
@@ -326,30 +363,36 @@ faults on a non-present page. But, the original owner of the
|
||||
mapping/reservation will behave as expected.
|
||||
|
||||
|
||||
.. _resv_map_modifications:
|
||||
|
||||
Reservation Map Modifications
|
||||
-----------------------------
|
||||
=============================
|
||||
|
||||
The following low level routines are used to make modifications to a
|
||||
reservation map. Typically, these routines are not called directly. Rather,
|
||||
a reservation map helper routine is called which calls one of these low level
|
||||
routines. These low level routines are fairly well documented in the source
|
||||
code (mm/hugetlb.c). These routines are:
|
||||
long region_chg(struct resv_map *resv, long f, long t);
|
||||
long region_add(struct resv_map *resv, long f, long t);
|
||||
void region_abort(struct resv_map *resv, long f, long t);
|
||||
long region_count(struct resv_map *resv, long f, long t);
|
||||
code (mm/hugetlb.c). These routines are::
|
||||
|
||||
long region_chg(struct resv_map *resv, long f, long t);
|
||||
long region_add(struct resv_map *resv, long f, long t);
|
||||
void region_abort(struct resv_map *resv, long f, long t);
|
||||
long region_count(struct resv_map *resv, long f, long t);
|
||||
|
||||
Operations on the reservation map typically involve two operations:
|
||||
|
||||
1) region_chg() is called to examine the reserve map and determine how
|
||||
many pages in the specified range [f, t) are NOT currently represented.
|
||||
|
||||
The calling code performs global checks and allocations to determine if
|
||||
there are enough huge pages for the operation to succeed.
|
||||
|
||||
2a) If the operation can succeed, region_add() is called to actually modify
|
||||
the reservation map for the same range [f, t) previously passed to
|
||||
region_chg().
|
||||
2b) If the operation can not succeed, region_abort is called for the same range
|
||||
[f, t) to abort the operation.
|
||||
2)
|
||||
a) If the operation can succeed, region_add() is called to actually modify
|
||||
the reservation map for the same range [f, t) previously passed to
|
||||
region_chg().
|
||||
b) If the operation can not succeed, region_abort is called for the same
|
||||
range [f, t) to abort the operation.
|
||||
|
||||
Note that this is a two step process where region_add() and region_abort()
|
||||
are guaranteed to succeed after a prior call to region_chg() for the same
|
||||
@@ -371,6 +414,7 @@ and make the appropriate adjustments.
|
||||
|
||||
The routine region_del() is called to remove regions from a reservation map.
|
||||
It is typically called in the following situations:
|
||||
|
||||
- When a file in the hugetlbfs filesystem is being removed, the inode will
|
||||
be released and the reservation map freed. Before freeing the reservation
|
||||
map, all the individual file_region structures must be freed. In this case
|
||||
@@ -384,6 +428,7 @@ It is typically called in the following situations:
|
||||
removed, region_del() is called to remove the corresponding entry from the
|
||||
reservation map. In this case, region_del is passed the range
|
||||
[page_idx, page_idx + 1).
|
||||
|
||||
In every case, region_del() will return the number of pages removed from the
|
||||
reservation map. In VERY rare cases, region_del() can fail. This can only
|
||||
happen in the hole punch case where it has to split an existing file_region
|
||||
@@ -403,9 +448,11 @@ outstanding (outstanding = (end - start) - region_count(resv, start, end)).
|
||||
Since the mapping is going away, the subpool and global reservation counts
|
||||
are decremented by the number of outstanding reservations.
|
||||
|
||||
.. _resv_map_helpers:
|
||||
|
||||
Reservation Map Helper Routines
|
||||
-------------------------------
|
||||
===============================
|
||||
|
||||
Several helper routines exist to query and modify the reservation maps.
|
||||
These routines are only interested with reservations for a specific huge
|
||||
page, so they just pass in an address instead of a range. In addition,
|
||||
@@ -414,32 +461,40 @@ or shared) and the location of the reservation map (inode or VMA) can be
|
||||
determined. These routines simply call the underlying routines described
|
||||
in the section "Reservation Map Modifications". However, they do take into
|
||||
account the 'opposite' meaning of reservation map entries for private and
|
||||
shared mappings and hide this detail from the caller.
|
||||
shared mappings and hide this detail from the caller::
|
||||
|
||||
long vma_needs_reservation(struct hstate *h,
|
||||
struct vm_area_struct *vma,
|
||||
unsigned long addr)
|
||||
|
||||
long vma_needs_reservation(struct hstate *h,
|
||||
struct vm_area_struct *vma, unsigned long addr)
|
||||
This routine calls region_chg() for the specified page. If no reservation
|
||||
exists, 1 is returned. If a reservation exists, 0 is returned.
|
||||
exists, 1 is returned. If a reservation exists, 0 is returned::
|
||||
|
||||
long vma_commit_reservation(struct hstate *h,
|
||||
struct vm_area_struct *vma,
|
||||
unsigned long addr)
|
||||
|
||||
long vma_commit_reservation(struct hstate *h,
|
||||
struct vm_area_struct *vma, unsigned long addr)
|
||||
This calls region_add() for the specified page. As in the case of region_chg
|
||||
and region_add, this routine is to be called after a previous call to
|
||||
vma_needs_reservation. It will add a reservation entry for the page. It
|
||||
returns 1 if the reservation was added and 0 if not. The return value should
|
||||
be compared with the return value of the previous call to
|
||||
vma_needs_reservation. An unexpected difference indicates the reservation
|
||||
map was modified between calls.
|
||||
map was modified between calls::
|
||||
|
||||
void vma_end_reservation(struct hstate *h,
|
||||
struct vm_area_struct *vma,
|
||||
unsigned long addr)
|
||||
|
||||
void vma_end_reservation(struct hstate *h,
|
||||
struct vm_area_struct *vma, unsigned long addr)
|
||||
This calls region_abort() for the specified page. As in the case of region_chg
|
||||
and region_abort, this routine is to be called after a previous call to
|
||||
vma_needs_reservation. It will abort/end the in progress reservation add
|
||||
operation.
|
||||
operation::
|
||||
|
||||
long vma_add_reservation(struct hstate *h,
|
||||
struct vm_area_struct *vma,
|
||||
unsigned long addr)
|
||||
|
||||
long vma_add_reservation(struct hstate *h,
|
||||
struct vm_area_struct *vma, unsigned long addr)
|
||||
This is a special wrapper routine to help facilitate reservation cleanup
|
||||
on error paths. It is only called from the routine restore_reserve_on_error().
|
||||
This routine is used in conjunction with vma_needs_reservation in an attempt
|
||||
@@ -453,8 +508,10 @@ be done on error paths.
|
||||
|
||||
|
||||
Reservation Cleanup in Error Paths
|
||||
----------------------------------
|
||||
As mentioned in the section "Reservation Map Helper Routines", reservation
|
||||
==================================
|
||||
|
||||
As mentioned in the section
|
||||
:ref:`Reservation Map Helper Routines <resv_map_helpers>`, reservation
|
||||
map modifications are performed in two steps. First vma_needs_reservation
|
||||
is called before a page is allocated. If the allocation is successful,
|
||||
then vma_commit_reservation is called. If not, vma_end_reservation is called.
|
||||
@@ -494,13 +551,14 @@ so that a reservation will not be leaked when the huge page is freed.
|
||||
|
||||
|
||||
Reservations and Memory Policy
|
||||
------------------------------
|
||||
==============================
|
||||
Per-node huge page lists existed in struct hstate when git was first used
|
||||
to manage Linux code. The concept of reservations was added some time later.
|
||||
When reservations were added, no attempt was made to take memory policy
|
||||
into account. While cpusets are not exactly the same as memory policy, this
|
||||
comment in hugetlb_acct_memory sums up the interaction between reservations
|
||||
and cpusets/memory policy.
|
||||
and cpusets/memory policy::
|
||||
|
||||
/*
|
||||
* When cpuset is configured, it breaks the strict hugetlb page
|
||||
* reservation as the accounting is done on a global variable. Such
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user