Re: wrong madvise(MADV DONTNEED) semantic

From: Michael Kerrisk
Date: Wed Jun 29 2005 - 11:47:19 EST


> On Tue, 2005-06-28 at 11:16 -0700, Andy Isaacson wrote:
>
> > Besides, if you read the documentation closely, it does not say what
> > you
> > think it says.
> >
> > MADV_DONTNEED
> > Do not expect access in the near future. (For the time
> > being, the application is finished with the given range,
> > so the kernel can free resources associated with it.)
> > Subsequent accesses of pages in this range will succeed,
> > but will result either in reloading of the memory contents
> > from the underlying mapped file (see mmap) or
> > zero-fill-on-demand pages for mappings without an
> > underlying file.
> >
> > You seem to think that "reloading ... from the underlying mapped file"
> > means that changes are lost, but that's not implied.
>
> This wording _does_ imply that changes are lost if the file is mapped
> writable and not mysnc'ed or if the memory mapping is anonymous.

A little late into this thread, but...

Indeed it does imply that, because that was what I understood
when (IIRC) I wrote that text in the man page.

> In the former, changes are dropped and the file is reread from the stale
> on-disk copy. In the latter case, the data is dropped and the pages are
> zero-filled on access.

Yes.

Cheers,

Michael

--
5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail
+++ GMX - die erste Adresse für Mail, Message, More +++
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/