Linux APIs: Difference between revisions

m 1 revision
Line 44: Line 44:
* <tt>mremap(2)</tt> allows an existing memory map (resulting from a successful <tt>mmap(2)</tt> call) to be shrunk or expanded. In combination with MAP_ANONYMOUS, this provides the base for a high-speed <tt>realloc(3)</tt> implementation. By default, the map will not be moved (and an error will be returned if such a move would be necessary); by supplying the <tt>MREMAP_MAYMOVE</tt> flag, this behavior can be changed (pointers into the buffer might be invalidated by such a call). <tt>MREMAP_FIXED</tt> causes <tt>mremap(2)</tt> to accept a fifth argument, specifying an address to which the map must be moved. <tt>MREMAP_MAYMOVE</tt> must be supplied with <tt>MREMAP_FIXED</tt>, according to the Linux man pages version 3.07, even if the target destination is the same as the source.
* <tt>mremap(2)</tt> allows an existing memory map (resulting from a successful <tt>mmap(2)</tt> call) to be shrunk or expanded. In combination with MAP_ANONYMOUS, this provides the base for a high-speed <tt>realloc(3)</tt> implementation. By default, the map will not be moved (and an error will be returned if such a move would be necessary); by supplying the <tt>MREMAP_MAYMOVE</tt> flag, this behavior can be changed (pointers into the buffer might be invalidated by such a call). <tt>MREMAP_FIXED</tt> causes <tt>mremap(2)</tt> to accept a fifth argument, specifying an address to which the map must be moved. <tt>MREMAP_MAYMOVE</tt> must be supplied with <tt>MREMAP_FIXED</tt>, according to the Linux man pages version 3.07, even if the target destination is the same as the source.
* <tt>madvise(2)</tt> accepts several options beyond those specified by POSIX.1b.; in addition to those arguments specified by POSIX.1-2001 for <tt>posix_madvise(2)</tt>, Linux since version 2.6.16 supports <tt>MADV_REMOVE</tt>, <tt>MADV_DONTFORK</tt>, and <tt>MADV_DOFORK</tt>. <tt>MADV_REMOVE</tt> allows reclamation of unused pages within a sparse mapping, similar to [[FreeBSD APIs|FreeBSD's]] <tt>MADV_FREE</tt>. The other disable the default sharing of maps with child processes across a <tt>fork(2)</tt>, and reenable it, respectively.
* <tt>madvise(2)</tt> accepts several options beyond those specified by POSIX.1b.; in addition to those arguments specified by POSIX.1-2001 for <tt>posix_madvise(2)</tt>, Linux since version 2.6.16 supports <tt>MADV_REMOVE</tt>, <tt>MADV_DONTFORK</tt>, and <tt>MADV_DOFORK</tt>. <tt>MADV_REMOVE</tt> allows reclamation of unused pages within a sparse mapping, similar to [[FreeBSD APIs|FreeBSD's]] <tt>MADV_FREE</tt>. The other disable the default sharing of maps with child processes across a <tt>fork(2)</tt>, and reenable it, respectively.
* The <tt>hugetlbfs</tt> file system supports [http://www.mjmwired.net/kernel/Documentation/vm/hugetlbpage.txt reduction of mapping granularity] in the VM. It's used by [http://www.cyberciti.biz/tips/linux-hugetlbfs-and-mysql-performance.html MySQL].