From: "Tom May" <tom@tommay.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/8][for -mm] mem_notify v6
Date: Wed, 2 Apr 2008 10:45:05 -0700 [thread overview]
Message-ID: <ab3f9b940804021045r28e88ce9vfddad5362ea6372d@mail.gmail.com> (raw)
In-Reply-To: <20080402154910.9588.KOSAKI.MOTOHIRO@jp.fujitsu.com>
On Wed, Apr 2, 2008 at 12:31 AM, KOSAKI Motohiro
<kosaki.motohiro@jp.fujitsu.com> wrote:
> Hi Tom,
>
> Thank you very useful comment.
> that is very interesting.
>
>
> > I tried it with a real-world program that, among other things, mmaps
> > anonymous pages and touches them at a reasonable speed until it gets
> > notified via /dev/mem_notify, releases most of them with
> > madvise(MADV_DONTNEED), then loops to start the cycle again.
> >
> > What tends to happen is that I do indeed get notifications via
> > /dev/mem_notify when the kernel would like to be swapping, at which
> > point I free memory. But the notifications come at a time when the
> > kernel needs memory, and it gets the memory by discarding some Cached
> > or Mapped memory (I can see these decreasing in /proc/meminfo with
> > each notification). With each mmap/notify/madvise cycle the Cached
> > and Mapped memory gets smaller, until eventually while I'm touching
> > pages the kernel can't find enough memory and will either invoke the
> > OOM killer or return ENOMEM from syscalls. This is precisely the
> > situation I'm trying to avoid by using /dev/mem_notify.
>
> Could you send your test program?
Unfortunately, no, it's a Java Virtual Machine (which is a perfect
user of /dev/mem_notify since it can garbage collect on notification,
among other times).
But it should be possible to make a small program with the same
behavior; I'll do that.
> I can't reproduce that now, sorry.
>
>
>
> > The criterion of "notify when the kernel would like to swap" feels
> > correct, but in addition I seem to need something like "notify when
> > cached+mapped+free memory is getting low".
>
> Hmmm,
> I think this idea is only useful when userland process call
> madvise(MADV_DONTNEED) periodically.
Do you have a recommendation for freeing memory? I could maybe use
munmap/mmap, but that's not atomic and may be "worse" (more overhead,
etc.) than madvise(MADV_DONTNEED).
> but I hope improve my patch and solve your problem.
> if you don' mind, please help my testing ;)
It's my pleasure to help in any way I can.
.tom
next prev parent reply other threads:[~2008-04-02 17:45 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-09 15:19 [PATCH 0/8][for -mm] mem_notify v6 KOSAKI Motohiro
2008-02-09 16:02 ` Jon Masters
2008-02-09 16:33 ` KOSAKI Motohiro
2008-02-09 16:43 ` Rik van Riel
2008-02-09 16:49 ` KOSAKI Motohiro
2008-02-11 15:36 ` [PATCH 0/8][for -mm] mem_notify v6, " Jonathan Corbet
2008-02-11 15:46 ` KOSAKI Motohiro
2008-02-17 14:49 ` Paul Jackson
2008-02-19 7:36 ` KOSAKI Motohiro
2008-02-19 15:00 ` Paul Jackson
2008-02-19 19:02 ` Rik van Riel
2008-02-19 20:18 ` Paul Jackson
2008-02-19 20:43 ` Paul Jackson
2008-02-19 22:28 ` Pavel Machek
2008-02-20 1:54 ` Paul Jackson
2008-02-20 2:07 ` Rik van Riel
2008-02-20 2:48 ` KOSAKI Motohiro
2008-02-20 4:57 ` Paul Jackson
2008-02-20 5:21 ` KOSAKI Motohiro
2008-02-20 4:36 ` Paul Jackson
2008-04-01 23:35 ` Tom May
2008-04-02 7:31 ` KOSAKI Motohiro
2008-04-02 17:45 ` Tom May [this message]
2008-04-15 0:16 ` Tom May
2008-04-16 2:30 ` KOSAKI Motohiro
2008-04-17 9:30 ` KOSAKI Motohiro
2008-04-17 19:23 ` Tom May
2008-04-18 10:07 ` KOSAKI Motohiro
2008-04-21 20:32 ` Tom May
2008-04-23 8:27 ` Daniel Spång
2008-05-01 2:07 ` Tom May
2008-05-01 15:06 ` KOSAKI Motohiro
2008-05-02 22:21 ` Tom May
2008-05-03 12:26 ` KOSAKI Motohiro
2008-05-06 5:22 ` Tom May
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=ab3f9b940804021045r28e88ce9vfddad5362ea6372d@mail.gmail.com \
--to=tom@tommay.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).