linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: Chuck Lever <cel@monkey.org>
Cc: linux-mm@kvack.org
Subject: Re: madvise (MADV_FREE)
Date: Fri, 24 Mar 2000 01:21:49 +0100	[thread overview]
Message-ID: <20000324012149.C20140@pcep-jamie.cern.ch> (raw)
In-Reply-To: <Pine.BSO.4.10.10003231332080.20600-100000@funky.monkey.org>; from Chuck Lever on Thu, Mar 23, 2000 at 01:53:22PM -0500

On the dirty bit
................

And then Chuck moved onto a different topic, mincore...
> can this be any worse than mprotect?

Do you really imagine an application having to handle 1000 SEGV signals,
and call mprotect() for one page per SEGV, and the kernel locking the mm
thereby causing soft fault contention for other threads, is fast? :-)

<ahem>, but enough sensationalism from me.  I went and looked at some
papers -- and found a rather annoying problem with mprotect, for general
purpose GCs[1]:

	"The resulting write faults were caught as UNIX signals and
	recorded.  Various Portable Common Runtime interfaces to SunOS
	system calls were modified so as to preclude unrecoverable
	faults in system calls."

Ouch!  You can't use the mprotect() method with read().  mincore would
be just fine.  So you can't make a conservative collector that works
with a third-party library unless you're willing to write wrappers for
all the system calls that touch user memory.  ioctl() for a hairy
example.

On the matter of timing, when that paper was written (1991), continued
from above:

	"The primary cost of this is that the first time a page in the
	heap is written after a garbage collection, a signal must be
	caught and a system call must be executed to unprotect the
	page.  The cost of this is variable, but in our environment
	appears to be somewhat less then half a millisecond per page
	written."

As a counterpoint, Boehm has this to say on the subject of getting dirty
bits from the OS[2].  See 3:

	"We keep track of modified pages using one of three distinct
	mechanisms:

	1. Through explicit mutator cooperation. Currently this requires the
	   use of GC_malloc_stubborn. 
	2. By write-protecting physical pages and catching write faults. This
           is implemented for many Unix-like systems and for win32. It is not
           possible in a few environments. 
	3. By retrieving dirty bit information from /proc. (Currently only
           Sun's Solaris supports this. Though this is considerably cleaner,
           performance may actually be better with mprotect and signals.) 

Well, I guess we will never know until it has been tried, but it looks
like it should be experimented with by someone writing a garbage
collector before it becomes a standard kernel feature.  I really don't
like the way mprotect breaks syscalls though, even if it performs well.


On the accessed bit
...................

In [3], Boehm says:

	"Paging locality 

	A common concern about garbage collection, or any form of
	dynamic memory allocation, is its interaction with a virtual
	memory system.  Accesses to virtual memory should be such that
	the traffic between disk and memory is small, i.e. most access
	should be to pages that were already recently accessed.  On
	modern computers, where disks are so much slower than CPUs, many
	programs page very little, and most of their heaps reside in the
	working set. But even for those programs in which significant
	parts of the heap do not reside in the working set, there are a
	number of techniques which dramatically increase the locality of
	reference of a mark-and-sweep collector.  The fundamental
	problem is that all memory that may possibly contain pointers
	has to be examined during every full collection."

Boehm then goes on to summarise methods used to avoid this problem.  In
particular, generational collection.

This is something that mincore could perhaps help with.  Pages that
haven't been accessed since certain GC checkpoints can gather in a set
of pages that don't need to be scanned, or at least not scanned
particularly often.

Again, somebody working on a real GC implementation would be the right
person to experiment with extensions to mincore.

My summary from this is: no point adding mincore extensions until we
know what would be useful.  But do reserve the space in those bits 1-7.

enjoy,
-- Jamie

[1] http://reality.sgi.com/boehm/papers/pldi91.ps.Z
[2] http://reality.sgi.com/boehm/gcdescr.html
[3] http://reality.sgi.com/boehm/issues.html
--
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/

  parent reply	other threads:[~2000-03-24  0:21 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               ` Jamie Lokier [this message]
2000-03-24  7:21                 ` madvise (MADV_FREE) 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
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=20000324012149.C20140@pcep-jamie.cern.ch \
    --to=lk@tantalophile.demon.co.uk \
    --cc=cel@monkey.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