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: Sun, 12 Jul 2009 00:22:19 +0300	[thread overview]
Message-ID: <20090712002219.502540d2@woof.woof> (raw)
In-Reply-To: <Pine.LNX.4.64.0907111916001.30651@sister.anvils>

On Sat, 11 Jul 2009 20:22:11 +0100 (BST)
Hugh Dickins <hugh.dickins@tiscali.co.uk> wrote:


> I think it becomes quite a big subject, and you may be able to
> excite other people with it.

Yea, I agree, I dropped this patch, I think i have idea how to mange
it from userspace in a much better way for the kvm case.

> 
> > 
> > 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...
> 
> We may want to do that anyway.  It concerned me a lot when I was
> first testing (and often saw kernel_pages_allocated greater than
> pages_shared - probably because of the original KSM's eagerness to
> merge forked pages, though I think there may have been more to it
> than that).  But seems much less of an issue now (that ratio is much
> healthier), and even less of an issue once KSM pages can be swapped.
> So I'm not bothering about it at the moment, but it may make sense.
> 

We could add patch like the below, but I think we should leave it as it
is now, and solve it all (like you have said) with the ksm pages
swapping support in next kernel release.
(Right now ksm can limit itself with max_kernel_pages_alloc)

diff --git a/mm/ksm.c b/mm/ksm.c
index a0fbdb2..ee80861 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1261,8 +1261,13 @@ static void ksm_do_scan(unsigned int scan_npages)
 		rmap_item = scan_get_next_rmap_item(&page);
 		if (!rmap_item)
 			return;
-		if (!PageKsm(page) || !in_stable_tree(rmap_item))
+		if (!PageKsm(page) || !in_stable_tree(rmap_item)) {
 			cmp_and_merge_page(page, rmap_item);
+		} else if (page_mapcount(page) == 0) {
+			break_cow(rmap_item->mm,
+				  rmap_item->address & PAGE_MASK);
+			remove_rmap_item_from_tree(rmap_item);
+		}
 		put_page(page);
 	}
 }


> 
> I think you've resolved that as a non-issue, but is cpu still looking
> too high to you?  It looks high to me, but then I realize that I've
> tuned it to be high anyway.  Do you have any comparison against the
> /dev/ksm KSM, or your first madvise version?

I think I made myself to think it is to high, i ran it for 250 pages
scan each 10 millisecond, cpu usage was most of the time 1-4%, (beside
when it merged pages) - then the walking on the tree is longer, and if
it is the first page, we have addition memcpy of the page (into new
allocated page) - we can solve this issue, together with a big list of
optimizations that can come into ksm stable/unstable
algorithm/implemantion, in later releases of the kernel.

> 
> Oh, something that might be making it higher, that I didn't highlight
> (and can revert if you like, it was just more straightforward this
> way): with scan_get_next_rmap skipping the non-present ptes,
> pages_to_scan is currently a limit on the _present_ pages scanned in
> one batch.

You mean that now when you say: pages_to_scan = 512, it wont count the
none present ptes as part of the counter, so if we have 500 not present
ptes in the begining and then 512 ptes later, before it used to call
cmp_and_merge_page() only for 12 pages while now it will get called on
512 pages?

If yes, then I liked this change, it is more logical from cpu
consumption point of view, and in addition we have that cond_reched()
so I dont see a problem with this.

Thanks.

> 
> Hugh

--
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>

  reply	other threads:[~2009-07-11 21:09 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
2009-07-10 22:49               ` Izik Eidus
2009-07-11 19:22               ` Hugh Dickins
2009-07-11 21:22                 ` Izik Eidus [this message]
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=20090712002219.502540d2@woof.woof \
    --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