From: "Tom May" <tom@tommay.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: "Daniel Sp蚣g" <daniel.spang@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/8][for -mm] mem_notify v6
Date: Mon, 5 May 2008 22:22:03 -0700 [thread overview]
Message-ID: <ab3f9b940805052222o4f4a7dev3f4dce92b3766435@mail.gmail.com> (raw)
In-Reply-To: <20080503205732.642F.KOSAKI.MOTOHIRO@jp.fujitsu.com>
All the talk about how what is using memory, whether things are in
Java or native, etc., is missing the point. I'm not sure I'm making
my point, so I'll try again: regardless of memory size, mlock, etc.,
the interaction between client and /dev/mem_notify can be unstable,
and is unstable in my case:
- User-space code page faults in MAP_ANONYMOUS regions until there is
no free memory.
- The kernel gives a notification.
- There kernel frees some cache to satisfy the memory request.
- The user-space code gets the notification and frees anonymous pages.
Concurrently
with this, some thread(s) in the system may continue to page fault.
- The cycle repeats.
- This works well, perhaps hundreds or thousands of cycles, until all
or most of the cache has been freed and we get an oom handling a page
fault.
My requirement is to have a stable system, with memory allocated on
demand to whatever process(es) want it (jvm, web browser, ...) until a
low memory notification occurs, which causes them to free whatever
memory they no longer need, then continue, without arbitrary static
limits on Java heap size, web browser cache size, etc.
My workaround to make things stable is to put pages in the cache
(after releasing anonymous pages and increasing free memory) by
accessing pages in _text, but that seems silly and expensive.
.tom
On Sat, May 3, 2008 at 5:26 AM, KOSAKI Motohiro
<kosaki.motohiro@jp.fujitsu.com> wrote:
> > > your memnotify check routine is written by native or java?
> >
> > Some of each.
>
> Wow!
> you have 2 /dev/mem_notify checking routine?
> java routine free java memory, native routine free native memory, right?
>
>
>
> > > my point is "on swapless system, /dev/mem_notify checked routine should be mlocked".
> >
> > mlocking didn't fix things, it just made the oom happen at a different
> > time (see graphs below), both in the small test program where I used
> > mlockall, and in the jvm where during initialization I read
> > /proc/self/maps and mlocked each region of memory that was mapped to a
> > file. Note that without swap, all of the anonymous pages containing
> > the java code are effectively locked in memory, too, so everything
> > runs without page faults.
>
> okey.
>
>
>
> > > I hope understand your requirement more.
> >
> > Most simply, I need to get low memory notifications while there is
> > still enough memory to handle them before oom.
>
> Ah, That's your implementation idea.
> I hope know why don't works well my current implementation at first.
>
>
>
> > > Can I ask your system more?
> >
> > x86, Linux 2.6.23.9 (with your patches trivially backported), 128MB,
> > no swap. Is there something else I can tell you?
> >
> > > I think all java text and data is mapped.
> >
> > It's not what /proc/meminfo calls "Mapped". It's in anonymous pages
> > with no backing store, i.e., mmap with MAP_ANONYMOUS.
>
> okey.
> Mapped of /proc/meminfo mean mapped pages with file backing store.
>
> therefore, that isn't contain anonymous memory(e.g. java).
>
>
> > > When cached+mapped+free memory is happend?
> > > and at the time, What is used memory?
> >
> > Here's a graph of MemFree, Cached, and Mapped over time (I believe
> > Mapped is mostly or entirely subset of Cached here, so it's not
> > actually important):
> >
> > http://www.tommay.net/memory.png
>
> I hope know your system memory usage detail.
> your system have 128MB, but your graph vertical line represent 0M - 35M.
> Who use remain 93MB(128-35)?
> We should know who use memory intead decrease cached memory.
>
> So, Can you below operation before mesurement?
>
> # echo 100 > /proc/sys/vm/swappiness
> # echo 3 >/proc/sys/vm/drop_caches
>
> and, Can you mesure AnonPages of /proc/meminfo too?
> (Can your memory shrinking routine reduce anonymous memory?)
>
> if JVM use memory as anonymous memory and your memory shrinking routine can't
> anonymous memory, that isn't mem_notify proble,
> that is just poor JVM garbege collection problem.
>
> Why I think that?
> mapped page of your graph decrease linearly.
> if notification doesn't happened, it doesn't decrease.
>
> thus,
> in your system, memory notification is happend rightly.
> but your JVM doesn't have enough freeable memory.
>
> if my assumption is right, increase number of memory notification
> doesn't solve your problem.
>
> Sould we find way of good interaction to JVM GC and mem_notify shrinker?
> Sould mem_notify shrinker kick JVM GC for shrink anonymous memory?
>
>
>
>
> > My thought was to notify only when the threshold is crossed, i.e.,
> > edge-triggered not level-triggered.
>
> Hm, interesting..
>
>
>
> > But I now think a threshold
> > mechanism may be too complicated, and artificially putting pages in
> > the cache works just as well. As a proof-of-concept, I do this, and
> > it works well, but is inefficient:
> >
> > extern char _text;
> > for (int i = 0; i < bytes; i += 4096) {
> > *((volatile char *)&_text + i);
> > }
>
> you intent populate to .text segment?
> if so, you can mamp(MAP_POPULATE), IMHO.
>
>
>
> > I think embedded Java is a perfect user of /dev/mem_notify :-) I was
> > happy to see your patches and the criteria you used for notification.
> > But I'm having a problem in practice :-(
>
> Yeah, absolutely.
> I'll try to set up JVM to my test environment tomorrow.
>
>
>
--
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>
prev parent reply other threads:[~2008-05-06 5:22 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
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 [this message]
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=ab3f9b940805052222o4f4a7dev3f4dce92b3766435@mail.gmail.com \
--to=tom@tommay.com \
--cc=daniel.spang@gmail.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).