diff options
-rw-r--r-- | mm/ksm.c | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -453,6 +453,7 @@ static void remove_rmap_item_from_tree(struct rmap_item *rmap_item) | |||
453 | } | 453 | } |
454 | 454 | ||
455 | rmap_item->next = NULL; | 455 | rmap_item->next = NULL; |
456 | rmap_item->address &= PAGE_MASK; | ||
456 | 457 | ||
457 | } else if (rmap_item->address & NODE_FLAG) { | 458 | } else if (rmap_item->address & NODE_FLAG) { |
458 | unsigned char age; | 459 | unsigned char age; |
@@ -467,11 +468,11 @@ static void remove_rmap_item_from_tree(struct rmap_item *rmap_item) | |||
467 | BUG_ON(age > 1); | 468 | BUG_ON(age > 1); |
468 | if (!age) | 469 | if (!age) |
469 | rb_erase(&rmap_item->node, &root_unstable_tree); | 470 | rb_erase(&rmap_item->node, &root_unstable_tree); |
471 | |||
470 | ksm_pages_unshared--; | 472 | ksm_pages_unshared--; |
473 | rmap_item->address &= PAGE_MASK; | ||
471 | } | 474 | } |
472 | 475 | ||
473 | rmap_item->address &= PAGE_MASK; | ||
474 | |||
475 | cond_resched(); /* we're called from many long loops */ | 476 | cond_resched(); /* we're called from many long loops */ |
476 | } | 477 | } |
477 | 478 | ||
@@ -1086,8 +1087,7 @@ static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item) | |||
1086 | unsigned int checksum; | 1087 | unsigned int checksum; |
1087 | int err; | 1088 | int err; |
1088 | 1089 | ||
1089 | if (in_stable_tree(rmap_item)) | 1090 | remove_rmap_item_from_tree(rmap_item); |
1090 | remove_rmap_item_from_tree(rmap_item); | ||
1091 | 1091 | ||
1092 | /* We first start with searching the page inside the stable tree */ | 1092 | /* We first start with searching the page inside the stable tree */ |
1093 | tree_rmap_item = stable_tree_search(page, page2, rmap_item); | 1093 | tree_rmap_item = stable_tree_search(page, page2, rmap_item); |
@@ -1143,9 +1143,7 @@ static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item) | |||
1143 | * tree, and insert it instead as new node in the stable tree. | 1143 | * tree, and insert it instead as new node in the stable tree. |
1144 | */ | 1144 | */ |
1145 | if (!err) { | 1145 | if (!err) { |
1146 | rb_erase(&tree_rmap_item->node, &root_unstable_tree); | 1146 | remove_rmap_item_from_tree(tree_rmap_item); |
1147 | tree_rmap_item->address &= ~NODE_FLAG; | ||
1148 | ksm_pages_unshared--; | ||
1149 | 1147 | ||
1150 | /* | 1148 | /* |
1151 | * If we fail to insert the page into the stable tree, | 1149 | * If we fail to insert the page into the stable tree, |
@@ -1174,11 +1172,8 @@ static struct rmap_item *get_next_rmap_item(struct mm_slot *mm_slot, | |||
1174 | 1172 | ||
1175 | while (cur != &mm_slot->rmap_list) { | 1173 | while (cur != &mm_slot->rmap_list) { |
1176 | rmap_item = list_entry(cur, struct rmap_item, link); | 1174 | rmap_item = list_entry(cur, struct rmap_item, link); |
1177 | if ((rmap_item->address & PAGE_MASK) == addr) { | 1175 | if ((rmap_item->address & PAGE_MASK) == addr) |
1178 | if (!in_stable_tree(rmap_item)) | ||
1179 | remove_rmap_item_from_tree(rmap_item); | ||
1180 | return rmap_item; | 1176 | return rmap_item; |
1181 | } | ||
1182 | if (rmap_item->address > addr) | 1177 | if (rmap_item->address > addr) |
1183 | break; | 1178 | break; |
1184 | cur = cur->next; | 1179 | cur = cur->next; |