Re: wrong madvise(MADV_DONTNEED) semantic

From: Robert Love
Date: Tue Jun 28 2005 - 13:29:23 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.

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.

Robert Love


-
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/