linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Izik Eidus <ieidus@redhat.com>
To: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Andrea Arcangeli <aarcange@redhat.com>,
	Rik van Riel <riel@redhat.com>, Chris Wright <chrisw@redhat.com>,
	Nick Piggin <nickpiggin@yahoo.com.au>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: KSM: current madvise rollup
Date: Sat, 11 Jul 2009 01:42:25 +0300	[thread overview]
Message-ID: <4A57C3D1.7000407@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0907082035400.10356@sister.anvils>

Hugh Dickins wrote:
>  
>   
Hey Hugh,

I started to hack the code around to make sure i understand everything, 
and in addition i wanted to add few things

One thing that catched my eyes was:
> +
> +/*
> + * cmp_and_merge_page - take a page computes its hash value and check if there
> + * is similar hash value to different page,
> + * in case we find that there is similar hash to different page we call to
> + * try_to_merge_two_pages().
> + *
> + * @page: the page that we are searching identical page to.
> + * @rmap_item: the reverse mapping into the virtual address of this page
> + */
> +static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
> +{
> +	struct page *page2[1];
> +	struct rmap_item *tree_rmap_item;
> +	unsigned int checksum;
> +	int err;
> +
> +	if (in_stable_tree(rmap_item))
> +		remove_rmap_item_from_tree(rmap_item);
> +
>
>   


So when we enter to cmp_and_merge_page, if the page is in_stable_tree() 
we will remove the rmap_item from the stable tree,
And then we have inside:

> + * ksm_do_scan  - the ksm scanner main worker function.
> + * @scan_npages - number of pages we want to scan before we return.
> + */
> +static void ksm_do_scan(unsigned int scan_npages)
> +{
> +	struct rmap_item *rmap_item;
> +	struct page *page;
> +
> +	while (scan_npages--) {
> +		cond_resched();
> +		rmap_item = scan_get_next_rmap_item(&page);
> +		if (!rmap_item)
> +			return;
> +		if (!PageKsm(page) || !in_stable_tree(rmap_item))
> +			cmp_and_merge_page(page, rmap_item);
> +		put_page(page);
> +	}
> +}
>   

So this check for: if (!PageKsm(page) || !in_stable_tree(rmap_item)) 
will be true for !in_stable_tree(rmap_item)

Isnt it mean that we are "stop using the stable tree help" ?
It look like every item that will go into the stable tree will get 
flushed from it in the second run, that will highly increase the ksmd 
cpu usage, and will make it find less pages...
Was this what you wanted to do? or am i missed anything?

Beside this one more thing i noticed while checking this code:
beacuse the new "Ksm shared page" is not File backed page, it isnt count 
in top as a shared page, and i couldnt find a way to see how many pages 
are shared for each application..
This is important for management tools such as a tool that will want to 
know what Virtual Machines it want to migrate from the host into another 
host based on the memory sharing in that specific host (Meaning how much 
ram it really take on that specific host)

So I started to prepre a patch that will show merged pages count inside 
/proc/pid/mergedpages, But then i thought this statics lie:
if we will have 2 applications: application A and application B, that 
share the same page, how should it look like?:

cat /proc/pid_of_A/merged_pages -> 1
cat /proc/pid_of_B/merged_pages -> 1

or:

cat /proc/pid_of_A/merged_pages -> 0 (beacuse this one was shared with 
the page of B)
cat /proc/pid_of_B/merged_pages -> 1

To make the second method thing work as much as reaible as we can we 
would want to break KsmPages that have just one mapping into them...


What do you think about that? witch direction should we take for that?


(Other than this stuff, everything running happy and nice, I think cpu 
is little bit too high beacuse the removing of the stable_tree issue)

Thanks.

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

  parent reply	other threads:[~2009-07-10 22:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-29 14:14 Hugh Dickins
2009-06-30  9:52 ` Izik Eidus
2009-06-30 15:57   ` Hugh Dickins
2009-06-30 18:41     ` Izik Eidus
2009-07-01  2:03       ` Hugh Dickins
2009-07-01  9:50         ` Izik Eidus
2009-07-08 21:07           ` Hugh Dickins
2009-07-09 15:37             ` Izik Eidus
2009-07-10 13:43               ` Hugh Dickins
2009-07-10 22:42             ` Izik Eidus [this message]
2009-07-10 22:49               ` Izik Eidus
2009-07-11 19:22               ` Hugh Dickins
2009-07-11 21:22                 ` Izik Eidus
2009-07-12 14:44                   ` Hugh Dickins
2009-07-13 18:28                     ` Izik Eidus
2009-07-01 10:33         ` Andrea Arcangeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A57C3D1.7000407@redhat.com \
    --to=ieidus@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=chrisw@redhat.com \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=riel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox