LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Mike Rapoport <rppt@linux.vnet.ibm.com>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Andrea Arcangeli <aarcange@redhat.com>,
	linux-doc <linux-doc@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Mike Rapoport <rppt@linux.vnet.ibm.com>
Subject: [PATCH 1/7] mm/ksm: docs: extend overview comment and make it "DOC:"
Date: Tue, 24 Apr 2018 09:40:22 +0300	[thread overview]
Message-ID: <1524552028-7017-2-git-send-email-rppt@linux.vnet.ibm.com> (raw)
In-Reply-To: <1524552028-7017-1-git-send-email-rppt@linux.vnet.ibm.com>

The existing comment provides a good overview of KSM implementation. Let's
update it to reflect recent additions of "chain" and "dup" variants of the
stable tree nodes and mark it as "DOC:" for inclusion into the KSM
documentation.

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
---
 mm/ksm.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/mm/ksm.c b/mm/ksm.c
index 58c2741..54155b1 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -51,7 +51,9 @@
 #define DO_NUMA(x)	do { } while (0)
 #endif
 
-/*
+/**
+ * DOC: Overview
+ *
  * A few notes about the KSM scanning process,
  * to make it easier to understand the data structures below:
  *
@@ -67,6 +69,21 @@
  * this tree is fully assured to be working (except when pages are unmapped),
  * and therefore this tree is called the stable tree.
  *
+ * The stable tree node includes information required for reverse
+ * mapping from a KSM page to virtual addresses that map this page.
+ *
+ * In order to avoid large latencies of the rmap walks on KSM pages,
+ * KSM maintains two types of nodes in the stable tree:
+ *
+ * * the regular nodes that keep the reverse mapping structures in a
+ *   linked list
+ * * the "chains" that link nodes ("dups") that represent the same
+ *   write protected memory content, but each "dup" corresponds to a
+ *   different KSM page copy of that content
+ *
+ * Internally, the regular nodes, "dups" and "chains" are represented
+ * using the same :c:type:`struct stable_node` structure.
+ *
  * In addition to the stable tree, KSM uses a second data structure called the
  * unstable tree: this tree holds pointers to pages which have been found to
  * be "unchanged for a period of time".  The unstable tree sorts these pages
-- 
2.7.4

  reply	other threads:[~2018-04-24  6:43 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 ` Mike Rapoport [this message]
2018-04-24  6:40 ` [PATCH 2/7] docs/vm: ksm: (mostly) formatting updates Mike Rapoport
2018-04-24  6:40 ` [PATCH 3/7] docs/vm: ksm: add "Design" section Mike Rapoport
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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=1524552028-7017-2-git-send-email-rppt@linux.vnet.ibm.com \
    --to=rppt@linux.vnet.ibm.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --subject='Re: [PATCH 1/7] mm/ksm: docs: extend overview comment and make it "DOC:"' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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).