aboutsummaryrefslogtreecommitdiffstats
path: root/mm/ksm.c
diff options
context:
space:
mode:
authorHugh Dickins <hughd@google.com>2013-02-22 19:36:03 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-23 20:50:23 -0500
commit8fdb3dbf02335d96bf170321381522709ba63a0c (patch)
tree5c81a212ef5960298ec4d284640c38f707f5dad6 /mm/ksm.c
parent49cd0a5c290f99deca3463d16c3c1c7240107889 (diff)
ksm: add some comments
Added slightly more detail to the Documentation of merge_across_nodes, a few comments in areas indicated by review, and renamed get_ksm_page()'s argument from "locked" to "lock_it". No functional change. Signed-off-by: Hugh Dickins <hughd@google.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Petr Holasek <pholasek@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Izik Eidus <izik.eidus@ravellosystems.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/ksm.c')
-rw-r--r--mm/ksm.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/mm/ksm.c b/mm/ksm.c
index 5ea0f64b8714..c067e8dbcc79 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -87,6 +87,9 @@
87 * take 10 attempts to find a page in the unstable tree, once it is found, 87 * take 10 attempts to find a page in the unstable tree, once it is found,
88 * it is secured in the stable tree. (When we scan a new page, we first 88 * it is secured in the stable tree. (When we scan a new page, we first
89 * compare it against the stable tree, and then against the unstable tree.) 89 * compare it against the stable tree, and then against the unstable tree.)
90 *
91 * If the merge_across_nodes tunable is unset, then KSM maintains multiple
92 * stable trees and multiple unstable trees: one of each for each NUMA node.
90 */ 93 */
91 94
92/** 95/**
@@ -526,7 +529,7 @@ static void remove_node_from_stable_tree(struct stable_node *stable_node)
526 * a page to put something that might look like our key in page->mapping. 529 * a page to put something that might look like our key in page->mapping.
527 * is on its way to being freed; but it is an anomaly to bear in mind. 530 * is on its way to being freed; but it is an anomaly to bear in mind.
528 */ 531 */
529static struct page *get_ksm_page(struct stable_node *stable_node, bool locked) 532static struct page *get_ksm_page(struct stable_node *stable_node, bool lock_it)
530{ 533{
531 struct page *page; 534 struct page *page;
532 void *expected_mapping; 535 void *expected_mapping;
@@ -575,7 +578,7 @@ again:
575 goto stale; 578 goto stale;
576 } 579 }
577 580
578 if (locked) { 581 if (lock_it) {
579 lock_page(page); 582 lock_page(page);
580 if (ACCESS_ONCE(page->mapping) != expected_mapping) { 583 if (ACCESS_ONCE(page->mapping) != expected_mapping) {
581 unlock_page(page); 584 unlock_page(page);
@@ -705,10 +708,17 @@ static int remove_stable_node(struct stable_node *stable_node)
705 return 0; 708 return 0;
706 } 709 }
707 710
708 if (WARN_ON_ONCE(page_mapped(page))) 711 if (WARN_ON_ONCE(page_mapped(page))) {
712 /*
713 * This should not happen: but if it does, just refuse to let
714 * merge_across_nodes be switched - there is no need to panic.
715 */
709 err = -EBUSY; 716 err = -EBUSY;
710 else { 717 } else {
711 /* 718 /*
719 * The stable node did not yet appear stale to get_ksm_page(),
720 * since that allows for an unmapped ksm page to be recognized
721 * right up until it is freed; but the node is safe to remove.
712 * This page might be in a pagevec waiting to be freed, 722 * This page might be in a pagevec waiting to be freed,
713 * or it might be PageSwapCache (perhaps under writeback), 723 * or it might be PageSwapCache (perhaps under writeback),
714 * or it might have been removed from swapcache a moment ago. 724 * or it might have been removed from swapcache a moment ago.