Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1421709 > unrolled thread

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

Started by<zhouxianrong@huawei.com>
First post2016-06-14 11:30 +0200
Last post2016-06-15 00:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] more mapcount page as kpage could reduce total replacement times than fewer mapcount one in probability. <zhouxianrong@huawei.com> - 2016-06-14 11:30 +0200
    Re: [PATCH] more mapcount page as kpage could reduce total  replacement times than fewer mapcount one in probability. Andrew Morton <akpm@linux-foundation.org> - 2016-06-15 00:20 +0200

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

From<zhouxianrong@huawei.com>
Date2016-06-14 11:30 +0200
Subject[PATCH] more mapcount page as kpage could reduce total replacement times than fewer mapcount one in probability.
Message-ID<rJSPw-2Vh-1@gated-at.bofh.it>
From: z00281421 <z00281421@notesmail.huawei.com>

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@notesmail.huawei.com>
---
 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

[toc] | [next] | [standalone]


#1422397 — Re: [PATCH] more mapcount page as kpage could reduce total replacement times than fewer mapcount one in probability.

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-06-15 00:20 +0200
SubjectRe: [PATCH] more mapcount page as kpage could reduce total replacement times than fewer mapcount one in probability.
Message-ID<rK4QG-2oZ-33@gated-at.bofh.it>
In reply to#1421709
On Tue, 14 Jun 2016 17:17:37 +0800 <zhouxianrong@huawei.com> wrote:

> From: z00281421 <z00281421@notesmail.huawei.com>
> 
> more mapcount page as kpage could reduce total replacement 
> times than fewer mapcount one when ksmd scan and replace 
> among forked pages later.
> 

Hopefully Hugh will be able to have a think about this.

> --- 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;
> +	}

kernel.h provides a swap() macro.

>  	err = try_to_merge_with_ksm_page(rmap_item, page, NULL);
>  	if (!err) {
>  		err = try_to_merge_with_ksm_page(tree_rmap_item,

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web