Commit 26465d3e authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds
Browse files

ksm: break cow once unshared

We kept agreeing not to bother about the unswappable shared KSM pages
which later become unshared by others: observation suggests they're not
a significant proportion.  But they are disadvantageous, and it is easier
to break COW to replace them by swappable pages, than offer statistics
to show that they don't matter; then we can stop worrying about them.

Doing this in ksm_do_scan, they don't go through cmp_and_merge_page on
this pass: give them a good chance of getting into the unstable tree
on the next pass, or back into the stable, by computing checksum now.
Signed-off-by: default avatarHugh Dickins <>
Acked-by: default avatarIzik Eidus <>
Cc: Andrea Arcangeli <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 473b0ce4
......@@ -1268,6 +1268,14 @@ static void ksm_do_scan(unsigned int scan_npages)
if (!PageKsm(page) || !in_stable_tree(rmap_item))
cmp_and_merge_page(page, rmap_item);
else if (page_mapcount(page) == 1) {
* Replace now-unshared ksm page by ordinary page.
break_cow(rmap_item->mm, rmap_item->address);
rmap_item->oldchecksum = calc_checksum(page);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment