linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] more mapcount page as kpage could reduce total replacement times than fewer mapcount one in probability.
@ 2016-06-14  9:17 zhouxianrong
  2016-06-14 22:14 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: zhouxianrong @ 2016-06-14  9:17 UTC (permalink / raw)
  To: linux-mm
  Cc: akpm, hughd, aarcange, kirill.shutemov, dave.hansen,
	zhouchengming1, geliangtang, zhouxianrong, linux-kernel,
	zhouxiyu, wanghaijun5

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] more mapcount page as kpage could reduce total replacement times than fewer mapcount one in probability.
  2016-06-14  9:17 [PATCH] more mapcount page as kpage could reduce total replacement times than fewer mapcount one in probability zhouxianrong
@ 2016-06-14 22:14 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2016-06-14 22:14 UTC (permalink / raw)
  To: zhouxianrong
  Cc: linux-mm, hughd, aarcange, kirill.shutemov, dave.hansen,
	zhouchengming1, geliangtang, linux-kernel, zhouxiyu, wanghaijun5,
	Hugh Dickins

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,

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-14 22:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-14  9:17 [PATCH] more mapcount page as kpage could reduce total replacement times than fewer mapcount one in probability zhouxianrong
2016-06-14 22:14 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).