Re: [PATCH 2/7] ksm: treat unstable nid like in stable tree

From: Ric Mason
Date: Fri Feb 22 2013 - 02:13:15 EST


On 02/21/2013 04:20 PM, Hugh Dickins wrote:
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.

IIUC
- ksm page from the wrong NUMA node will be add to current node's stable tree
- normal page from the wrong NUMA node will be merged to current node's stable tree <- where I miss here? I didn't see any special handling in function stable_tree_search for this case.
- normal page from the wrong NUMA node will compare but not as a leaf for merging after the patch


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@xxxxxxxxxx>
---
mm/ksm.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)

--- mmotm.orig/mm/ksm.c 2013-02-20 22:28:23.584001392 -0800
+++ mmotm/mm/ksm.c 2013-02-20 22:28:27.288001480 -0800
@@ -1340,16 +1340,6 @@ struct rmap_item *unstable_tree_search_i
return NULL;
}
- /*
- * If tree_page has been migrated to another NUMA node, it
- * will be flushed out and put into the right unstable tree
- * next time: only merge with it if merge_across_nodes.
- */
- if (!ksm_merge_across_nodes && page_to_nid(tree_page) != nid) {
- put_page(tree_page);
- return NULL;
- }
-
ret = memcmp_pages(page, tree_page);
parent = *new;
@@ -1359,6 +1349,15 @@ struct rmap_item *unstable_tree_search_i
} else if (ret > 0) {
put_page(tree_page);
new = &parent->rb_right;
+ } else if (!ksm_merge_across_nodes &&
+ page_to_nid(tree_page) != nid) {
+ /*
+ * If tree_page has been migrated to another NUMA node,
+ * it will be flushed out and put in the right unstable
+ * tree next time: only merge with it when across_nodes.
+ */
+ put_page(tree_page);
+ return NULL;
} else {
*tree_pagep = tree_page;
return tree_rmap_item;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/