LKML Archive on
help / color / mirror / Atom feed
From: Mike Rapoport <>
To: Jonathan Corbet <>
Cc: Andrew Morton <>,
	Andrea Arcangeli <>,
	linux-doc <>,
	linux-mm <>,
	lkml <>,
	Mike Rapoport <>
Subject: [PATCH 3/7] docs/vm: ksm: add "Design" section
Date: Tue, 24 Apr 2018 09:40:24 +0300	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

Include the KSM description from the source code comment, add a subsection
about reverse mapping and include kernel-doc references for KSM data

Signed-off-by: Mike Rapoport <>
 Documentation/vm/ksm.rst | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/Documentation/vm/ksm.rst b/Documentation/vm/ksm.rst
index 786d460..0e5a085 100644
--- a/Documentation/vm/ksm.rst
+++ b/Documentation/vm/ksm.rst
@@ -206,6 +206,45 @@ stable_node "dups" with few rmap_items in them, but that may increase
 the ksmd CPU usage and possibly slowdown the readonly computations on
 the KSM pages of the applications.
+.. kernel-doc:: mm/ksm.c
+   :DOC: Overview
+Reverse mapping
+KSM maintains reverse mapping information for KSM pages in the stable
+If a KSM page is shared between less than ``max_page_sharing`` VMAs,
+the node of the stable tree that represents such KSM page points to a
+list of :c:type:`struct rmap_item` and the ``page->mapping`` of the
+KSM page points to the stable tree node.
+When the sharing passes this threshold, KSM adds a second dimension to
+the stable tree. The tree node becomes a "chain" that links one or
+more "dups". Each "dup" keeps reverse mapping information for a KSM
+page with ``page->mapping`` pointing to that "dup".
+Every "chain" and all "dups" linked into a "chain" enforce the
+invariant that they represent the same write protected memory content,
+even if each "dup" will be pointed by a different KSM page copy of
+that content.
+This way the stable tree lookup computational complexity is unaffected
+if compared to an unlimited list of reverse mappings. It is still
+enforced that there cannot be KSM page content duplicates in the
+stable tree itself.
+.. kernel-doc:: mm/ksm.c
+   :functions: mm_slot ksm_scan stable_node rmap_item
 Izik Eidus,
 Hugh Dickins, 17 Nov 2009

  parent reply	other threads:[~2018-04-24  6:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24  6:40 [PATCH 0/7] docs/vm: update KSM documentation Mike Rapoport
2018-04-24  6:40 ` [PATCH 1/7] mm/ksm: docs: extend overview comment and make it "DOC:" Mike Rapoport
2018-04-24  6:40 ` [PATCH 2/7] docs/vm: ksm: (mostly) formatting updates Mike Rapoport
2018-04-24  6:40 ` Mike Rapoport [this message]
2018-04-24  6:40 ` [PATCH 4/7] docs/vm: ksm: reshuffle text between "sysfs" and "design" sections Mike Rapoport
2018-04-24  6:40 ` [PATCH 5/7] docs/vm: ksm: update stable_node_chains_prune_millisecs description Mike Rapoport
2018-04-24  6:40 ` [PATCH 6/7] docs/vm: ksm: udpate description of stable_node_{dups,chains} Mike Rapoport
2018-04-24  6:40 ` [PATCH 7/7] docs/vm: ksm: split userspace interface to admin-guide/mm/ksm.rst Mike Rapoport
2018-04-27 23:25 ` [PATCH 0/7] docs/vm: update KSM documentation Jonathan Corbet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH 3/7] docs/vm: ksm: add "Design" section' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).