[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mmap/munmap semantics
Hi,
On Tue, 22 Feb 2000 18:46:02 +0100 (MET), Richard Guenther
<richard.guenther@student.uni-tuebingen.de> said:
> With the ongoing development of GLAME there arise the following
> problems with the backing-store management, which is a mmaped
> file and does "userspace virtual memory management":
> - I cannot see a way to mmap a part of the file but set the
> contents initially to zero,
All file contents default to zero anyway, so just ftruncate() the file
to create as much demand-zeroed mmapable memory as you want.
> - I need to "drop" a mapping sometimes without writing the contents
> back to disk - I cannot see a way to do this with linux currently.
The only way is to use Chuck Lever's madvise() patches:
madvise(MADV_DONTNEED) is exactly what you need there. It's not yet in
Linus's 2.3 tree, but the API is pretty standard.
> Ideally a hole could be created in the mmapped file on drop time -
No, if the mmaped area has already been flushed to disk then there is no
way at all to recreate the hole except by truncating and then
re-extending the file (which destroys everything until EOF, of course).
--Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/