Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Sep 1999 10:46:11 +1000
From:      Peter Jeremy <jeremyp@gsmx07.alcatel.com.au>
To:        toasty@dragondata.com
Cc:        hackers@freebsd.org
Subject:   Re: Idea: disposable memory
Message-ID:  <99Sep24.104339est.40356@border.alcanet.com.au>

next in thread | raw e-mail | index | archive | help
Kevin Day <toasty@dragondata.com> wrote:
>I'd like a way to be able to specify that a region of malloc'ed data is
>'disposable' and has approximately the same weight as disk cached data.

As others have pointed out, this is almost (but not quite) the same as
madvise(MADV_FREE).  I don't think there is any way to achieve what
Kevin wants with the current kernel.

The simplest solution would appear to be a new madvise option which
marks the relevant pages as `throw away instead of swapping out'.
This is similar to MADV_FREE, but does not immediately free the page.
It will also need to flag the page so the the user is warned if the
page _is_ reused - the most logical way is by returning SIGBUS or
SIGSEGV the first time the page is referenced after it has been
released.

The user process then just reads data normally.  If it gets a signal,
it knows it needs to re-create that page - this is presumably relatively
trivial to do on a page-by-page basis (since you have no control over
which page gets reused).

The code to handle the `throw away' bit should be fairly trivial -
it's just the existing MADV_FREE code, without the actual `free' bit.
I'm less certain about being able to mark a page mapping so that a
a page fault gets passed back to userland as well as mapping a zero-
filled page to that location.

Peter


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?99Sep24.104339est.40356>