• Hugh Dickins's avatar
    ksm: three remove_rmap_item_from_tree cleanups · 93d17715
    Hugh Dickins authored
    1. remove_rmap_item_from_tree() is called as a precaution from
       various places: don't dirty the rmap_item cacheline unnecessarily,
       just mask the flags out of the address when they have been set.
    
    2. First get_next_rmap_item() removes an unstable rmap_item from its tree,
       then shortly afterwards cmp_and_merge_page() removes a stable rmap_item
       from its tree: it's easier just to do both at once (but definitely keep
       the BUG_ON(age > 1) which guards against a future omission).
    
    3. When cmp_and_merge_page() moves an rmap_item from unstable to stable
       tree, it does its own rb_erase() and accounting: that's better
       expressed by remove_rmap_item_from_tree().
    Signed-off-by: default avatarHugh Dickins <hugh.dickins@tiscali.co.uk>
    Cc: Izik Eidus <ieidus@redhat.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    93d17715
ksm.c 45.1 KB