Commit b599cbdf1c2d88eac7caed00854ee4eecb119a6b

Authored by Hugh Dickins
Committed by Linus Torvalds
1 parent 8fdb3dbf02

ksm: treat unstable nid like in stable tree

An inconsistency emerged in reviewing the NUMA node changes to KSM: when
meeting a page from the wrong NUMA node in a stable tree, we say that
it's okay for comparisons, but not as a leaf for merging; whereas when
meeting a page from the wrong NUMA node in an unstable tree, we bail out
immediately.

Now, it might be that a wrong NUMA node in an unstable tree is more
likely to correlate with instablility (different content, with rbnode
now misplaced) than page migration; but even so, we are accustomed to
instablility in the unstable tree.

Without strong evidence for which strategy is generally better, I'd
rather be consistent with what's done in the stable tree: accept a page
from the wrong NUMA node for comparison, but not as a leaf for merging.

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>

Showing 1 changed file with 9 additions and 10 deletions Side-by-side Diff

... ... @@ -1342,16 +1342,6 @@
1342 1342 return NULL;
1343 1343 }
1344 1344  
1345   - /*
1346   - * If tree_page has been migrated to another NUMA node, it
1347   - * will be flushed out and put into the right unstable tree
1348   - * next time: only merge with it if merge_across_nodes.
1349   - */
1350   - if (!ksm_merge_across_nodes && page_to_nid(tree_page) != nid) {
1351   - put_page(tree_page);
1352   - return NULL;
1353   - }
1354   -
1355 1345 ret = memcmp_pages(page, tree_page);
1356 1346  
1357 1347 parent = *new;
... ... @@ -1361,6 +1351,15 @@
1361 1351 } else if (ret > 0) {
1362 1352 put_page(tree_page);
1363 1353 new = &parent->rb_right;
  1354 + } else if (!ksm_merge_across_nodes &&
  1355 + page_to_nid(tree_page) != nid) {
  1356 + /*
  1357 + * If tree_page has been migrated to another NUMA node,
  1358 + * it will be flushed out and put in the right unstable
  1359 + * tree next time: only merge with it when across_nodes.
  1360 + */
  1361 + put_page(tree_page);
  1362 + return NULL;
1364 1363 } else {
1365 1364 *tree_pagep = tree_page;
1366 1365 return tree_rmap_item;