[PATCH] more mapcount page as kpage could reduce total replacement times than fewer mapcount one in probability.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: z00281421 <z00281421@xxxxxxxxxxxxxxxxxxxx>

more mapcount page as kpage could reduce total replacement 
times than fewer mapcount one when ksmd scan and replace 
among forked pages later.

Signed-off-by: z00281421 <z00281421@xxxxxxxxxxxxxxxxxxxx>
---
 mm/ksm.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/mm/ksm.c b/mm/ksm.c
index 4786b41..17a238c 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1094,6 +1094,21 @@ static struct page *try_to_merge_two_pages(struct rmap_item *rmap_item,
 {
 	int err;
 
+	/*
+	 * select more mapcount page as kpage
+	 */
+	if (page_mapcount(page) < page_mapcount(tree_page)) {
+		struct page *tmp_page;
+		struct rmap_item *tmp_rmap_item;
+
+		tmp_page = page;
+		page = tree_page;
+		tree_page = tmp_page;
+		tmp_rmap_item = rmap_item;
+		rmap_item = tree_rmap_item;
+		tree_rmap_item = tmp_rmap_item;
+	}
+
 	err = try_to_merge_with_ksm_page(rmap_item, page, NULL);
 	if (!err) {
 		err = try_to_merge_with_ksm_page(tree_rmap_item,
-- 
1.7.9.5

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



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]