From: Hugh Dickins <hughd@google.com>
To: caiqian@redhat.com
Cc: linux-mm <linux-mm@kvack.org>
Subject: Re: understand KSM
Date: Tue, 26 Oct 2010 01:03:12 -0700 (PDT) [thread overview]
Message-ID: <alpine.LSU.2.00.1010260045120.2939@sister.anvils> (raw)
In-Reply-To: <1877317998.247611287997865214.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
On Mon, 25 Oct 2010, caiqian@redhat.com wrote:
> Hi everyone, while developing some tests for KSM in LTP
Thank you!
> - http://marc.info/?l=ltp-list&m=128754077917739&w=2 , noticed that pages_shared, pages_sharing and pages_unshared have different values than the expected values in the tests after read the doc. I am not sure if I misunderstood those values or there were bugs somewhere.
You were expecting KSM to share pages between processes, but you were
not expecting it to share pages within a process, which it does also.
To check the exact numbers, it would be easier if you use page-aligned
mmap() rather than byte-aligned malloc() for your MADV_MERGEABLE buffers:
some numbers are a little "off" because of part-pages at start and end.
>
> There are 3 programs (A, B ,C) to allocate 128M memory each using KSM.
>
> A has memory content equal 'c'.
> B has memory content equal 'a'.
> C has memory content equal 'a'.
>
> Then (using the latest mmotm tree),
> pages_shared = 2
> pages_sharing = 98292
> pages_unshared = 0
So, after KSM has done its best, it all reduces to 1 page full of 'a's
and another 1 page full of 'c's.
>
> Later,
> A has memory content = 'c'
> B has memory content = 'b'
> C has memory content = 'a'.
>
> Then,
> pages_shared = 4
> pages_sharing = 98282
> pages_unshared = 0
pages_shared 3 would be the obvious: I expect the extra 1 is an artifact
of part-pages at start and end of your buffers, a page shared there too.
>
> Finally,
> A has memory content = 'd'
> B has memory content = 'd'
> C has memory content = 'd'
>
> Then,
> pages_shared = 0
> pages_sharing = 0
> pages_unshared = 0
The children appear to exit(1) as soon as they have filled
their buffers with 'd's, so there's nothing left to share.
Hugh
>
> The following was the failed LTP output,
>
> # ./ksm01
> ksm01 0 TINFO : KSM merging...
> ksm01 0 TINFO : child 0 allocates 128 MB filled with 'c'.
> ksm01 0 TINFO : child 1 allocates 128 MB filled with 'a'.
> ksm01 0 TINFO : child 2 allocates 128 MB filled with 'a'.
> ksm01 0 TINFO : check!
> ksm01 0 TINFO : run is 1.
> ksm01 0 TINFO : pages_shared is 2.
> ksm01 1 TFAIL : pages_shared is not 32768.
> ksm01 0 TINFO : pages_sharing is 98292.
> ksm01 2 TFAIL : pages_sharing is not 32768.
> ksm01 0 TINFO : pages_unshared is 0.
> ksm01 3 TFAIL : pages_unshared is not 32768.
> ksm01 0 TINFO : child 1 continues...
> ksm01 0 TINFO : child 1 changes memory content to 'b'.
> ksm01 0 TINFO : check!
> ksm01 0 TINFO : run is 1.
> ksm01 0 TINFO : pages_shared is 4.
> ksm01 4 TFAIL : pages_shared is not 0.
> ksm01 0 TINFO : pages_sharing is 98282.
> ksm01 5 TFAIL : pages_sharing is not 0.
> ksm01 0 TINFO : pages_unshared is 0.
> ksm01 6 TFAIL : pages_unshared is not 98304.
> ksm01 0 TINFO : child 0 continues...
> ksm01 0 TINFO : child 0 changes memory content to 'd'.
> ksm01 0 TINFO : child 1 continues...
> ksm01 0 TINFO : child 1 changes memory content to 'd'
> ksm01 0 TINFO : child 2 continues...
> ksm01 0 TINFO : child 2 changes memory content to 'd'
> ksm01 0 TINFO : check!
> ksm01 0 TINFO : run is 1.
> ksm01 0 TINFO : pages_shared is 0.
> ksm01 7 TFAIL : pages_shared is not 32768.
> ksm01 0 TINFO : pages_sharing is 0.
> ksm01 8 TFAIL : pages_sharing is not 65536.
> ksm01 0 TINFO : pages_unshared is 0.
> ksm01 0 TINFO : KSM unmerging...
> ksm01 0 TINFO : check!
> ksm01 0 TINFO : run is 2.
> ksm01 0 TINFO : pages_shared is 0.
> ksm01 0 TINFO : pages_sharing is 0.
> ksm01 0 TINFO : pages_unshared is 0.
> ksm01 0 TINFO : stop KSM.
> ksm01 0 TINFO : check!
> ksm01 0 TINFO : run is 0.
> ksm01 0 TINFO : pages_shared is 0.
> ksm01 0 TINFO : pages_sharing is 0.
> ksm01 0 TINFO : pages_unshared is 0.
> ksm01 9 TFAIL : ksmtest() failed with 1.
>
> CAI Qian
--
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>
next prev parent reply other threads:[~2010-10-26 8:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <356409918.247361287997619777.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2010-10-25 9:11 ` caiqian
2010-10-26 8:03 ` Hugh Dickins [this message]
2010-10-26 11:14 ` CAI Qian
2010-10-27 4:00 ` Hugh Dickins
[not found] <395413139.534301288167215758.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2010-10-27 8:16 ` caiqian
2010-11-09 6:48 ` Hugh Dickins
2010-11-10 9:25 ` CAI Qian
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=alpine.LSU.2.00.1010260045120.2939@sister.anvils \
--to=hughd@google.com \
--cc=caiqian@redhat.com \
--cc=linux-mm@kvack.org \
/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