From: ebiederm+eric@ccr.net (Eric W. Biederman)
To: Jamie Lokier <jamie.lokier@cern.ch>
Cc: "Stephen C. Tweedie" <sct@redhat.com>,
Chuck Lever <cel@monkey.org>,
linux-mm@kvack.org
Subject: Re: Extensions to mincore
Date: 22 Mar 2000 01:36:02 -0600 [thread overview]
Message-ID: <m14s9z1mot.fsf@flinx.hidden> (raw)
In-Reply-To: Jamie Lokier's message of "Tue, 21 Mar 2000 17:48:56 +0100"
Jamie Lokier <jamie.lokier@cern.ch> writes:
> Stephen C. Tweedie wrote:
> > > Didn't you read a few paragraphs down, where I explain how to implement
> > > this? You've got struct page. It is enough for private mappings, and
> > > we don't need this feature for shared mappings.
> >
> > Umm, yes, but just saying "we'll solve synchronisation problems by
> > stopping all the other threads" hardly seems like a "solution" to me:
> > more of a workaround of the problem! mprotect() does work correctly
> > without stopping other threads.
>
> It is a limitation on mincore (at present).
>
> But I haven't though of a GC implementation that will work without
> synchronising the threads anyway. So the limitation may not be a
> problem for GC, and only GC would use this feature.
Nope. In dosemu we do the mprotect style of munging with mappings
as well. This allows us to detect which parts of a virtual frame
buffer have been changed pretty cheaply. I think it is actually
implemented with mmap & munamp though. Same story....
Doing mprotect tricks in a GC algorithm is actually a pretty
stupid way to go. Upon occasion it might be the only solution
where you can't get in and modify the code the GC algorithm
is cooperating with. But it still won't work great.
And only the slower GC algorithms, that need backwards compatiblity
with languages like C.
Anyway as you have mentioned to make this work you have to add
additional state from what is already kept, and it isn't
clear exactly what would make efficient use of this state.
I won't argue that in the long run this a bad idea. But in
the short run of the upcomming 2.4. I see no clear win.
For a GC that works with a SMP threaded heap you should never
need to do that crap anyway. You have the cost of the write lock
per object or group of objects anyway. And it shouldn't be hard
to instrument the lock aquiring paths to mark the object dirty as
well.
> User space SEGV processing is horrible, per-page mprotect()
> write-enabling is slow and a resource hog, and the mprotect works on
> vmas instead of pages unfortunately so you get zillions of vmas.
> zillions of vmas isn't good. Try cat /proc/self/maps when you have
> 25000 entries :-)
That's atleast 97 meg of RAM being managed, and given that
we combing adjacent vmas with the same permissions probably a lot
more. While not unthinkable I suspect that is a pretty unlikely case.
> Oops, I also forgot to mention that each per-page mprotect to
> write-enable the page on SEGV causes horrendous SMP behaviour too.
> > > It would be enough the say "the mincore accessed/dirty bits are not
> > > guaranteed to be accurate if pages are accessed by concurrent threads
> > > during the mincore call".
> >
> > Exactly why you need mprotect, which _does_ make the necessary
> > guarantees.
>
> It does so with utterly sucking performance too. And not because of the
> synchronisation -- but because you need 2500 separate mprotect calls and
> to handle 2500 SEGV signals to detect that 10MB of pages have been
> dirtied between GC runs.
>
> mincore() can gather that info in one relatively fast system call.
mincore has to use exactly the same implementation except it
might be able to get lucky, and not need to juggle vmas.
In which case it probably makes more sense to figure out how
to store the page writeable flag in the page table of a swapped
out page so mprotect does not need to break vmas....
All GC's that use mprotect & co will have sucky performance period.
They are definentily compromise solutions.
> It does have synchronisation issues -- on _some_ architectures. But
> they can be either documented (where they may not be a problem for GC),
> or explicit synchronisation can be added for architectures that need it.
>
> > Oh, and suggesting that we can obtain the dirty bit by assuming all
> > mappings are private doesn't work either. Private mappings *need* a
> > per-pte (NOT per-page, but per-pte) dirty bit to distinguish between
> > pages shared with the underlying mapped object, and pages which have
> > been modified by the local process.
>
> For private mappings, any page pointing to the underlying mapped object
> is by definition clean. That's easy enough to check.
>
> Any other page has either a struct page or a swap entry that's local to
> its pte. So the mincore-dirty flag can be stored in the struct page or
> the swap entry.
Again if you must please look at optimising mprotect. If we can find
3 bits in a pte of a swapped out page we don't need to split the
vma's. Nor do we need to change existing applications.
Plus the shared case is handled as well. At the cost of a slightly
higher miss penalty for a page. That sound like a much more
reasonable thing to do then what you are proposing now.
Please feel free to tell me I'm an idiot but I think I just stumbled
upon a pretty decent idea.
Eric
--
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.eu.org/Linux-MM/
next prev parent reply other threads:[~2000-03-22 7:36 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20000320135939.A3390@pcep-jamie.cern.ch>
2000-03-20 19:09 ` MADV_SPACEAVAIL and MADV_FREE in pre2-3 Chuck Lever
2000-03-21 1:20 ` madvise (MADV_FREE) Jamie Lokier
2000-03-21 2:24 ` William J. Earl
2000-03-21 14:08 ` Jamie Lokier
2000-03-22 16:24 ` Chuck Lever
2000-03-22 18:05 ` Jamie Lokier
2000-03-22 21:39 ` Chuck Lever
2000-03-22 22:31 ` Jamie Lokier
2000-03-22 22:44 ` Stephen C. Tweedie
2000-03-23 18:53 ` Chuck Lever
2000-03-24 0:00 ` /dev/recycle Jamie Lokier
2000-03-24 9:14 ` /dev/recycle Christoph Rohland
2000-03-24 13:10 ` /dev/recycle Jamie Lokier
2000-03-24 13:54 ` /dev/recycle Christoph Rohland
2000-03-24 14:17 ` /dev/recycle Jamie Lokier
2000-03-24 17:40 ` /dev/recycle Christoph Rohland
2000-03-24 18:13 ` /dev/recycle Jamie Lokier
2000-03-25 8:35 ` /dev/recycle Christoph Rohland
2000-03-28 0:48 ` /dev/recycle Chuck Lever
2000-03-24 0:21 ` madvise (MADV_FREE) Jamie Lokier
2000-03-24 7:21 ` lars brinkhoff
2000-03-24 17:42 ` Jeff Dike
2000-03-24 16:49 ` Jamie Lokier
2000-03-24 17:08 ` Stephen C. Tweedie
2000-03-24 19:58 ` Jeff Dike
2000-03-25 0:30 ` Stephen C. Tweedie
2000-03-22 22:33 ` Stephen C. Tweedie
2000-03-22 22:45 ` Jamie Lokier
2000-03-22 22:48 ` Stephen C. Tweedie
2000-03-22 22:55 ` Q. about swap-cache orphans Jamie Lokier
2000-03-22 22:58 ` Stephen C. Tweedie
2000-03-22 18:15 ` madvise (MADV_FREE) Christoph Rohland
2000-03-22 18:30 ` Jamie Lokier
2000-03-23 16:56 ` Christoph Rohland
2000-03-21 1:29 ` MADV_DONTNEED Jamie Lokier
2000-03-22 17:04 ` MADV_DONTNEED Chuck Lever
2000-03-22 17:10 ` MADV_DONTNEED Stephen C. Tweedie
2000-03-22 17:32 ` MADV_DONTNEED Jamie Lokier
2000-03-22 17:33 ` MADV_DONTNEED Jamie Lokier
2000-03-22 17:37 ` MADV_DONTNEED Stephen C. Tweedie
2000-03-22 17:43 ` MADV_DONTNEED Jamie Lokier
2000-03-22 21:54 ` MADV_DONTNEED Chuck Lever
2000-03-22 22:41 ` MADV_DONTNEED Jamie Lokier
2000-03-23 19:13 ` MADV_DONTNEED James Antill
2000-03-21 1:47 ` Extensions to mincore Jamie Lokier
2000-03-21 9:11 ` Eric W. Biederman
2000-03-21 9:40 ` lars brinkhoff
2000-03-21 11:34 ` Stephen C. Tweedie
2000-03-21 15:15 ` Jamie Lokier
2000-03-21 15:41 ` Stephen C. Tweedie
2000-03-21 15:55 ` Jamie Lokier
2000-03-21 16:08 ` Stephen C. Tweedie
2000-03-21 16:48 ` Jamie Lokier
2000-03-22 7:36 ` Eric W. Biederman [this message]
2000-03-21 1:50 ` MADV flags as mmap options Jamie Lokier
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=m14s9z1mot.fsf@flinx.hidden \
--to=ebiederm+eric@ccr.net \
--cc=cel@monkey.org \
--cc=jamie.lokier@cern.ch \
--cc=linux-mm@kvack.org \
--cc=sct@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