From owner-freebsd-hackers Thu Sep 23 17:46:39 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from alcanet.com.au (border.alcanet.com.au [203.62.196.10]) by hub.freebsd.org (Postfix) with ESMTP id B92DB1545C for ; Thu, 23 Sep 1999 17:46:34 -0700 (PDT) (envelope-from jeremyp@gsmx07.alcatel.com.au) Received: by border.alcanet.com.au id <40356>; Fri, 24 Sep 1999 10:43:39 +1000 Date: Fri, 24 Sep 1999 10:46:11 +1000 From: Peter Jeremy Subject: Re: Idea: disposable memory To: toasty@dragondata.com Cc: hackers@freebsd.org Message-Id: <99Sep24.104339est.40356@border.alcanet.com.au> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Kevin Day 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