Re: [PATCH 8/11] ksm: make !merge_across_nodes migration safe

From: Hugh Dickins
Date: Sun Jan 27 2013 - 18:25:37 EST


On Sun, 27 Jan 2013, Simon Jeons wrote:
> On Fri, 2013-01-25 at 18:05 -0800, Hugh Dickins wrote:
> > @@ -1344,10 +1401,29 @@ static void cmp_and_merge_page(struct pa
> > unsigned int checksum;
> > int err;
> >
> > - remove_rmap_item_from_tree(rmap_item);
> > + stable_node = page_stable_node(page);
> > + if (stable_node) {
> > + if (stable_node->head != &migrate_nodes &&
> > + get_kpfn_nid(stable_node->kpfn) != NUMA(stable_node->nid)) {
> > + rb_erase(&stable_node->node,
> > + &root_stable_tree[NUMA(stable_node->nid)]);
> > + stable_node->head = &migrate_nodes;
> > + list_add(&stable_node->list, stable_node->head);
>
> Why list add &stable_node->list to stable_node->head? stable_node->head
> is used for queue what?

Read that as list_add(&stable_node->list, &migrate_nodes) if you prefer.
stable_node->head (overlaying stable_node->node.__rb_parent_color, which
would never point to migrate_nodes as an rb_node) &migrate_nodes is used
as "magic" to show that that rb_node is currently saved on this list,
rather than linked into the stable tree itself. We could do some
#define MIGRATE_NODES_MAGIC 0xwhatever and put that in head instead.

> > @@ -1464,6 +1540,27 @@ static struct rmap_item *scan_get_next_r
> > */
> > lru_add_drain_all();
> >
> > + /*
> > + * Whereas stale stable_nodes on the stable_tree itself
> > + * get pruned in the regular course of stable_tree_search(),
>
> Which kinds of stable_nodes can be treated as stale? I just see remove
> rmap_item in stable_tree_search() and scan_get_next_rmap_item().

See get_ksm_page().
--
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/