From: Mike Rapoport <rppt@linux.vnet.ibm.com>
To: Pintu Kumar <pintu.ping@gmail.com>
Cc: open list <linux-kernel@vger.kernel.org>,
Russell King - ARM Linux <linux@armlinux.org.uk>,
linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org
Subject: Re: KSM not working in 4.9 Kernel
Date: Mon, 17 Sep 2018 17:59:36 +0300 [thread overview]
Message-ID: <20180917145936.GA20945@rapoport-lnx> (raw)
In-Reply-To: <CAOuPNLj+4pMnEy5EyZmzDWszqMb_PQb3q7t_hvG_50BTz1He2Q@mail.gmail.com>
On Mon, Sep 17, 2018 at 05:25:27PM +0530, Pintu Kumar wrote:
> On Mon, Sep 17, 2018 at 11:46 AM Pintu Kumar <pintu.ping@gmail.com> wrote:
> > > > But still no effect.
> > > > And I checked LTP test cases. It almost doing the same thing.
> > > >
> > > > I observed that [ksmd] thread is not waking up at all.
> > > > I gave some print inside it, but I could never saw that prints coming.
> > > > I could not find it running either in top command during the operation.
> > > > Is there anything needs to be done, to wakw up ksmd?
> > > > I already set: echo 1 > /sys/kernel/mm/ksm.
> > >
> > > It should be echo 1 > /sys/kernel/mm/ksm/run
> > >
> >
> > Oh yes, sorry for the typo.
> > I tried the same, but still ksm is not getting invoked.
> > Could someone confirm if KSM was working in 4.9 kernel?
> >
>
> Ok, it's working now. I have to explicitly stop the ksm thread to see
> the statistics.
> Also there was some internal patch that was setting vm_flags to
> VM_MERGABLE thus causing ksm_advise call to return.
>
> # echo 1 > /sys/kernel/mm/ksm/run
> # ./malloc-test.out &
> # echo 0 > /sys/kernel/mm/ksm/run
>
> ~ # grep -H '' /sys/kernel/mm/ksm/*
> /sys/kernel/mm/ksm/full_scans:105
> /sys/kernel/mm/ksm/pages_shared:1
> /sys/kernel/mm/ksm/pages_sharing:999
> /sys/kernel/mm/ksm/pages_to_scan:100
> /sys/kernel/mm/ksm/pages_unshared:0
> /sys/kernel/mm/ksm/pages_volatile:0
> /sys/kernel/mm/ksm/run:0
> /sys/kernel/mm/ksm/sleep_millisecs:20
>
>
> However, I have one doubt.
> Is the above data correct, for the below program?
You have 1 shared page and 999 additional references to that page
> int main(int argc, char *argv[])
> {
> int i, n, size, ret;
> char *buffer;
> void *addr;
>
> n = 10;
> size = 100 * getpagesize();
> for (i = 0; i < n; i++) {
> buffer = (char *)malloc(size);
> memset(buffer, 0xff, size);
> madvise(buffer, size, MADV_MERGEABLE);o
This madvise() call should fail because buffer won't be page aligned
> addr = mmap(NULL, size,
> PROT_READ | PROT_EXEC | PROT_WRITE,
> MAP_PRIVATE | MAP_ANONYMOUS,
> -1, 0);
> memset(addr, 0xff, size);
> ret = madvise(addr, size, MADV_MERGEABLE);
> if (ret < 0) {
> fprintf(stderr, "madvise failed: ret: %d,
> reason: %s\n", ret, strerror(errno));
> }
> usleep(500);
> }
> printf("Done....press ^C\n");
>
> pause();
>
> return 0;
> }
>
>
> Thanks,
> Pintu
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2018-09-17 14:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-14 14:28 KSM not working in 4.9 Kernel Pintu Kumar
2018-09-14 17:12 ` Yang Shi
2018-09-15 2:55 ` Pintu Kumar
2018-09-16 15:32 ` Mike Rapoport
2018-09-16 17:05 ` Pintu Kumar
2018-09-17 4:37 ` Mike Rapoport
2018-09-17 6:16 ` Pintu Kumar
2018-09-17 11:55 ` Pintu Kumar
2018-09-17 14:59 ` Mike Rapoport [this message]
2018-09-20 11:51 ` Pintu Kumar
2018-09-21 8:16 ` Mike Rapoport
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=20180917145936.GA20945@rapoport-lnx \
--to=rppt@linux.vnet.ibm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=pintu.ping@gmail.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;
as well as URLs for NNTP newsgroup(s).