aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiberiu A Georgescu <[email protected]>2021-09-23 06:46:18 +0000
committerJonathan Corbet <[email protected]>2021-09-27 11:27:20 -0600
commit5b32e44e8b885e673b1a1a748f4dfb33208d7f08 (patch)
tree96e7e6655da2dc77a3f74897785485749a4e916f
parent92a19d809829e33ca544031902bf367f0431bb30 (diff)
Documentation: update pagemap with shmem exceptions
Mentioning the current missing information in the pagemap and alternatives on how to retrieve it, in case someone stumbles upon unexpected behaviour. Signed-off-by: Tiberiu A Georgescu <[email protected]> Reviewed-by: Ivan Teterevkov <[email protected]> Reviewed-by: Florian Schmidt <[email protected]> Reviewed-by: Carl Waldspurger <[email protected]> Reviewed-by: Jonathan Davies <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Reviewed-by: Peter Xu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Corbet <[email protected]>
-rw-r--r--Documentation/admin-guide/mm/pagemap.rst22
1 files changed, 22 insertions, 0 deletions
diff --git a/Documentation/admin-guide/mm/pagemap.rst b/Documentation/admin-guide/mm/pagemap.rst
index fb578fbbb76c..4581527c07ae 100644
--- a/Documentation/admin-guide/mm/pagemap.rst
+++ b/Documentation/admin-guide/mm/pagemap.rst
@@ -196,6 +196,28 @@ you can go through every map in the process, find the PFNs, look those up
in kpagecount, and tally up the number of pages that are only referenced
once.
+Exceptions for Shared Memory
+============================
+
+Page table entries for shared pages are cleared when the pages are zapped or
+swapped out. This makes swapped out pages indistinguishable from never-allocated
+ones.
+
+In kernel space, the swap location can still be retrieved from the page cache.
+However, values stored only on the normal PTE get lost irretrievably when the
+page is swapped out (i.e. SOFT_DIRTY).
+
+In user space, whether the page is present, swapped or none can be deduced with
+the help of lseek and/or mincore system calls.
+
+lseek() can differentiate between accessed pages (present or swapped out) and
+holes (none/non-allocated) by specifying the SEEK_DATA flag on the file where
+the pages are backed. For anonymous shared pages, the file can be found in
+``/proc/pid/map_files/``.
+
+mincore() can differentiate between pages in memory (present, including swap
+cache) and out of memory (swapped out or none/non-allocated).
+
Other notes
===========