Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Jan 1997 21:50:08 -0500 (EST)
From:      "John S. Dyson" <toor@dyson.iquest.net>
To:        mpp@freefall.freebsd.org (Mike Pritchard)
Cc:        dyson@FreeBSD.ORG, dtc@scrooge.ee.swin.oz.au, current@FreeBSD.ORG
Subject:   Re: possible madvise MADV_FREE improvement
Message-ID:  <199701260250.VAA16940@dyson.iquest.net>
In-Reply-To: <199701260231.SAA10393@freefall.freebsd.org> from "Mike Pritchard" at Jan 25, 97 06:31:41 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> John S. Dyson wrote:
> > > 
> > > Below is a patch which seems to improve madvise MADV_FREE; stops the
> > > page-ins in the example recently posted.  It also brings the call
> > > closer to reliably zeroing the pages.
> > > 
> > Thanks for the bug report, and I will be committing a fix in a little
> > while (next hour or so) for the problem.  Note that MADV_FREE does not
> > guarantee that the page will be zeroed in any way.  Specificially, MADV_FREE
> > allows the system to optionally dispose of the contents of the page range,
> > without paging it out.  If the contents are disposed of, of course, the
> > pages in the page range will be demand zeroed.
> > 
> > John
> > dyson@freebsd.org
> 
> Can someone clarify  what PR# 1851 has to say?  Is it
> possible for "random" data to be returned in some cases?  Here
> is the next of the PR:
> 
It is possible for random data to be paged in/out due to an evil
race condition.  The correct behavior is for the data to be
unmodified in the process address space, or for the memory
to be demand zeroed.  MADV_FREE allows the kernel to "throw away" the
data in the pages instead of paging it out (and subsequently pageing
it back in.)  If the data is thrown away, the pages come back demand
zeroed.  There was a race condition that broke the proper behavior.


> 
>     "MADV_FREE gives the VM system the freedom to free pages, and tells the
>      system that information in the specified page range is no longer impor-
>      tant.  This is an efficient way of allowing malloc(3) to free pages any-
>      where in the address space, while keeping the address space valid.  The
>      next time that the page is referenced, the page might be demand zeroed,
>      or might contain the data that was there before the MADV_FREE call. ..."
> 
> I have a slight query on the behaviour of MADV_FREE. My initial
> interpretation was that after a MADV_FREE a page would either be zero
> filled or remain unchanged. However I found that pages could have
> different data in them after the MADV_FREE call.
> 
Your interpretation is correct, and the system behavior was wrong.

John



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701260250.VAA16940>