History log of /freebsd-11.0-release/lib/libc/sys/mmap.2
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 303975 11-Aug-2016 gjb

Copy stable/11@r303970 to releng/11.0 as part of the 11.0-RELEASE
cycle.

Prune svn:mergeinfo from the new branch, and rename it to RC1.

Update __FreeBSD_version.

Use the quarterly branch for the default FreeBSD.conf pkg(8) repo and
the dvd1.iso packages population.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 302408 08-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 278981 19-Feb-2015 jmg

fix spelling, add comma and remove BUGS section.. it provided no useful
information, and is not really bugs, but limitations for other reasons...


# 271722 17-Sep-2014 jhb

- Remove mention of MAP_INHERIT. It hasn't been implemented for thirteen
years.
- Remove mention of unimplemented MAP_SWAP. There are no future plans to
implement it.

Submitted by: alc (2)


# 271635 15-Sep-2014 jhb

Add stricter checking of some mmap() arguments:
- Fail with EINVAL if an invalid protection mask is passed to mmap().
- Fail with EINVAL if an unknown flag is passed to mmap().
- Fail with EINVAL if both MAP_PRIVATE and MAP_SHARED are passed to mmap().
- Require one of either MAP_PRIVATE or MAP_SHARED for non-anonymous
mappings.

Reviewed by: alc, kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D698


# 267630 19-Jun-2014 kib

Add MAP_EXCL flag for mmap(2). It should be combined with MAP_FIXED,
and prevents the request from deleting existing mappings in the
region, failing instead.

Reviewed by: alc
Discussed with: jhb
Tested by: markj, pho (previous version, as part of the bigger patch)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 255426 09-Sep-2013 jhb

Add a mmap flag (MAP_32BIT) on 64-bit platforms to request that a mapping use
an address in the first 2GB of the process's address space. This flag should
have the same semantics as the same flag on Linux.

To facilitate this, add a new parameter to vm_map_find() that specifies an
optional maximum virtual address. While here, fix several callers of
vm_map_find() to use a VMFS_* constant for the findspace argument instead of
TRUE and FALSE.

Reviewed by: alc
Approved by: re (kib)


# 254430 16-Aug-2013 jhb

Add new mmap(2) flags to permit applications to request specific virtual
address alignment of mappings.
- MAP_ALIGNED(n) requests a mapping aligned on a boundary of (1 << n).
Requests for n >= number of bits in a pointer or less than the size of
a page fail with EINVAL. This matches the API provided by NetBSD.
- MAP_ALIGNED_SUPER is a special case of MAP_ALIGNED. It can be used
to optimize the chances of using large pages. By default it will align
the mapping on a large page boundary (the system is free to choose any
large page size to align to that seems best for the mapping request).
However, if the object being mapped is already using large pages, then
it will align the virtual mapping to match the existing large pages in
the object instead.
- Internally, VMFS_ALIGNED_SPACE is now renamed to VMFS_SUPER_SPACE, and
VMFS_ALIGNED_SPACE(n) is repurposed for specifying a specific alignment.
MAP_ALIGNED(n) maps to using VMFS_ALIGNED_SPACE(n), while
MAP_ALIGNED_SUPER maps to VMFS_SUPER_SPACE.
- mmap() of a device object now uses VMFS_OPTIMAL_SPACE rather than
explicitly using VMFS_SUPER_SPACE. All device objects are forced to
use a specific color on creation, so VMFS_OPTIMAL_SPACE is effectively
equivalent.

Reviewed by: alc
MFC after: 1 month


# 233102 18-Mar-2012 kib

Do not claim that msync(2) is obsoleted [1].
Document EIO from msync(2).

Inspired by PR: docs/165929 [1]
Reviewed by: jilles
MFC after: 2 weeks


# 230613 27-Jan-2012 pluknet

Remove a left-over reference to make.conf(5) which was used as a place to
store the VM_STACK compile option to enable MAP_STACK support in its
earliest stage of development.

Found by: mux


# 218989 24-Feb-2011 pluknet

Remove sysctl vm.max_proc_mmap used to protect from KVA space exhaustion.
As it was pointed out by Alan Cox, that no longer serves its purpose with
the modern UMA allocator compared to the old one used in 4.x days.

The removal of sysctl eliminates max_proc_mmap type overflow leading to
the broken mmap(2) seen with large amount of physical memory on arches
with factually unbound KVA space (such as amd64). It was found that
slightly less than 256GB of physmem was enough to trigger the overflow.

Reviewed by: alc, kib
Approved by: avg (mentor)
MFC after: 2 months


# 211937 28-Aug-2010 alc

Add the MAP_PREFAULT_READ option to mmap(2).

Reviewed by: jhb, kib


# 205536 23-Mar-2010 jhb

Reject attempts to create a MAP_ANON mapping with a non-zero offset.

PR: kern/71258
Submitted by: Alexander Best
MFC after: 2 weeks


# 198973 06-Nov-2009 ed

Add MAP_ANONYMOUS.

Many operating systems also provide MAP_ANONYMOUS. It's not hard to
support this ourselves, we'd better add it to make it more likely for
applications to work out of the box.

Reviewed by: alc (mman.h)


# 195882 26-Jul-2009 alc

Eliminate a stale paragraph from the BUGS section. This "bug" was
eliminated in r195693.

Approved by: re (kensmith)


# 195693 14-Jul-2009 jhb

- Change mmap() to fail requests with EINVAL that pass a length of 0. This
behavior is mandated by POSIX.
- Do not fail requests that pass a length greater than SSIZE_MAX
(such as > 2GB on 32-bit platforms). The 'len' parameter is actually
an unsigned 'size_t' so negative values don't really make sense.

Submitted by: Alexander Best alexbestms at math.uni-muenster.de
Reviewed by: alc
Approved by: re (kib)
MFC after: 1 week


# 184226 24-Oct-2008 alc

Finish what revision 1.40 started. Revision 1.40 removed a false statement
from the description but not the errors section. This revision removes it
from the errors statement.

Add a statement about the non-portability of non-page-aligned offsets.


# 165903 09-Jan-2007 imp

Per Regents of the University of Calfornia letter, remove advertising
clause.

# If I've done so improperly on a file, please let me know.


# 162385 17-Sep-2006 ru

Markup fixes.


# 157923 21-Apr-2006 trhodes

Update for rev 1.205 of vm_mmap.c.

Submitted by: fanf


# 157064 23-Mar-2006 peter

Document that the documented 2GB mmap limit is actually a
documentation bug. We switched to page indexes some time around
FreeBSD 2.2. The actual 'len' limit is the maximum file size or what
will fit in your address space, whichever comes first. It should be
possible to make 1TB files on 32 bit systems, but of course address space
runs out long before then.


# 152551 17-Nov-2005 ru

-mdoc sweep.


# 148043 15-Jul-2005 sobomax

Document the fact that if MAP_FIXED request has been successful it
replaces any previous mapping to the same address.

Obtained from: IEEE Std 1003.1, 2004 Edition


# 131504 02-Jul-2004 ru

Mechanically kill hard sentence breaks.


# 128411 18-Apr-2004 cperciva

Document POSIX stupidity: Attempts to mmap zero bytes will succeed (and
have no effect), while attempts to munmap zero bytes will fail.


# 108260 24-Dec-2002 ru

Spelling: s/then/than/ where appropriate.


# 108087 19-Dec-2002 ru

mdoc(7) police: "The .Fa argument.".


# 108028 18-Dec-2002 ru

mdoc(7) police: Tidy up the syscall language.

Stop calling system calls "function calls".

Use "The .Fn system call" a-la "The .Nm utility".

When referring to a non-BSD implementation in
the HISTORY section, call syscall a function,
to be safe.


# 107788 12-Dec-2002 ru

Uniformly refer to a file system as "file system".

Approved by: re


# 102340 24-Aug-2002 mike

Note that <sys/types.h> in no longer a prerequisite for <utime.h> and
<sys/mman.h>.


# 92355 15-Mar-2002 ru

mdoc(7) police: hard sentence breaks, whitespace at EOL, contractions.


# 90482 10-Feb-2002 dd

Don't make it seem like vm.max_proc_mmap only affects MAP_FIXED.

PR: 34005
Submitted by: Steven Grady <grady@digitaldeck..com>,
Hiten Pandya <hitmaster2k@yahoo.com>


# 88351 21-Dec-2001 peter

The VM_STACK option is long dead. MAP_STACK is available everywhere.


# 86518 18-Nov-2001 iedowse

Remove a sentence from the BUGS section that claims non page-aligned
offsets don't work. It should really be documented that the returned
pointer can be in the middle of a fully-valid page when the offset
is not page-aligned, but I couldn't come up with suitable wording.

PR: kern/22754


# 84306 01-Oct-2001 ru

mdoc(7) police: Use the new .In macro for #include statements.


# 82600 30-Aug-2001 alex

Add Xref to make.conf(5).


# 82400 27-Aug-2001 ru

mdoc(7) police: removed whitespace at EOL, sorted SEE ALSO xrefs.


# 82289 24-Aug-2001 dillon

Update the mmap.2 and minherit.2 manual pages. Add a short explanation and
referal from mmap to minherit for MAP_INHERIT. Fully document the
minherit.2 manual page (because frankly, my dear, however you think it
currently works is almost certainly wrong!). I may soon re-implement
MAP_COPY because I believe we can support it properly now, but I will have
to call it something else and that is for a later time.


# 82240 23-Aug-2001 dg

Killed reference to MAP_INHERIT which is not supported in FreeBSD.


# 79754 15-Jul-2001 dd

Remove whitespace at EOL.


# 79531 10-Jul-2001 ru

mdoc(7) police: removed HISTORY info from the .Os call.


# 72409 12-Feb-2001 ru

Sort PROT_* and MAP_* lists, logically and alphabetically respectively.

Suggested by: bde

General mdoc(7) cleanup.


# 72370 11-Feb-2001 nik

Mention PROT_NONE in the list of possible protections.

Pointed out by: kris


# 72367 11-Feb-2001 nik

Note that mmap(2) can allocate memory, as well as mapping existing files,
in the .Nd.

Reviewed by: hackers


# 70481 29-Dec-2000 ru

Prepare for mdoc(7)NG.


# 69563 04-Dec-2000 ru

mdoc(7) police: fix formatting errors in rev 1.27.


# 69555 03-Dec-2000 dillon

Add warning on file-fragmentation issues related to MAP_NOSYNC


# 68716 14-Nov-2000 ru

Use Fx macro wherever possible.


# 62023 23-Jun-2000 chris

Repair a cross-reference to sync(1) that should refer to sync(8).


# 61988 23-Jun-2000 chris

Replace .Va, .Ar and .Nm with .Fa or .Va where necessary, examples:
``.Ar errno'' -> ``.Va errno''
``.Nm ops'' -> ``.Fa ops''
``.Va fd'' -> ``.Fa fd''


# 59460 21-Apr-2000 phantom

Introduce ".Lb" macro to libc manpages.

More libraries manpages updates following.


# 57686 02-Mar-2000 sheldonh

Remove single-space hard sentence breaks. These degrade the quality
of the typeset output, tend to make diffs harder to read and provide
bad examples for new-comers to mdoc.


# 57550 28-Feb-2000 ps

Add MAP_NOCORE to mmap(2), and MADV_NOCORE and MADV_CORE to madvise(2).
This
This feature allows you to specify if mmap'd data is included in
an application's corefile.

Change the type of eflags in struct vm_map_entry from u_char to
vm_eflags_t (an unsigned int).

Reviewed by: dillon,jdp,alfred
Approved by: jkh


# 57263 16-Feb-2000 dillon

Fix null-pointer dereference crash when the system is intentionally
run out of KVM through a mmap()/fork() bomb that allocates hundreds
of thousands of vm_map_entry structures.

Add panic to make null-pointer dereference crash a little more verbose.

Add a new sysctl, vm.max_proc_mmap, which specifies the maximum number
of mmap()'d spaces (discrete vm_map_entry's in the process). The value
defaults to around 9000 for a 128MB machine. The test is scaled for the
number of processes sharing a vmspace (aka linux threads). Setting
the value to 0 disables the feature.

PR: kern/16573
Approved by: jkh


# 57194 14-Feb-2000 chris

Replace `.Os BSD' which caused a troff error with `.Bx' which also
happens to be the correct macro to use in this situation.


# 54467 12-Dec-1999 dillon

Add MAP_NOSYNC feature to mmap(), and MADV_NOSYNC and MADV_AUTOSYNC to
madvise().

This feature prevents the update daemon from gratuitously flushing
dirty pages associated with a mapped file-backed region of memory. The
system pager will still page the memory as necessary and the VM system
will still be fully coherent with the filesystem. Modifications made
by other means to the same area of memory, for example by write(), are
unaffected. The feature works on a page-granularity basis.

MAP_NOSYNC allows one to use mmap() to share memory between processes
without incuring any significant filesystem overhead, putting it in
the same performance category as SysV Shared memory and anonymous memory.

Reviewed by: julian, alc, dg


# 50476 28-Aug-1999 peter

$Id$ -> $FreeBSD$


# 48794 12-Jul-1999 nik

Add $Id$, to make it simpler for members of the translation teams to
track.

The $Id$ line is normally at the bottom of the main comment block in the
man page, separated from the rest of the manpage by an empty comment,
like so;

.\" $Id$
.\"

If the immediately preceding comment is a @(#) format ID marker than the
the $Id$ will line up underneath it with no intervening blank lines.
Otherwise, an additional blank line is inserted.

Approved by: bde


# 43209 26-Jan-1999 julian

Mostly remove the VM_STACK OPTION.
This changes the definitions of a few items so that structures are the
same whether or not the option itself is enabled. This allows
people to enable and disable the option without recompilng the world.

As the author says:

|I ran into a problem pulling out the VM_STACK option. I was aware of this
|when I first did the work, but then forgot about it. The VM_STACK stuff
|has some code changes in the i386 branch. There need to be corresponding
|changes in the alpha branch before it can come out completely.

what is done:
|
|1) Pull the VM_STACK option out of the header files it appears in. This
|really shouldn't affect anything that executes with or without the rest
|of the VM_STACK patches. The vm_map_entry will then always have one
|extra element (avail_ssize). It just won't be used if the VM_STACK
|option is not turned on.
|
|I've also pulled the option out of vm_map.c. This shouldn't harm anything,
|since the routines that are enabled as a result are not called unless
|the VM_STACK option is enabled elsewhere.
|
|2) Add what appears to be appropriate code the the alpha branch, still
|protected behind the VM_STACK switch. I don't have an alpha machine,
|so we would need to get some testers with alpha machines to try it out.
|
|Once there is some testing, we can consider making the change permanent
|for both i386 and alpha.
|
[..]
|
|Once the alpha code is adequately tested, we can pull VM_STACK out
|everywhere.
|

Submitted by: "Richard Seaman, Jr." <dick@tar.com>


# 32131 31-Dec-1997 alex

Convert caddr_t --> void * for sys/mman.h functions.

mlock, mmap, mprotect, msync, munlock, and munmap are defined by
POSIX as taking void *. The const modifier has been added to
mlock, munlock, and mprotect as the standard dictates.

minherit comes from OpenBSD and has been updated to conform with
their recent change to void *.

madvise and mincore are not defined by POSIX, but their arguments
have been modified to be consistent with the POSIX-defined functions.
mincore takes a const pointer, but madvise does not due to the
MADV_FREE case.

Discussed with: bde


# 26826 23-Jun-1997 steve

Show the real revision date and not the date that this
manpage is being viewed.


# 24094 21-Mar-1997 mpp

Use the .Tn macro for generic FreeBSD references. Other minor cleanup.


# 23785 12-Mar-1997 bde

Restored a .Fa line that was lost in the Lite2 merge.


# 23660 11-Mar-1997 peter

Merge from Lite2 onto mainline -
- add undelete() and undelete.2 (requires libc minor bump some time)
- man page updates


# 21907 20-Jan-1997 wosch

Sort cross references.


# 21430 08-Jan-1997 joerg

Document the various reasons for EINVAL.

Document the flaw that `offset' is required to be page-aligned, in the
BUGS section.


# 20346 12-Dec-1996 alex

POSIX.4 defines MAP_FAILED to be the error return from mmap().


# 19725 13-Nov-1996 alex

Slight rewording of the BUGS section.


# 17782 22-Aug-1996 mpp

Correctly use .Fn instead of .Nm to reference function names
in a bunch of man pages.

Use the correct .Bx (BSD UNIX) or .At (AT&T UNIX) macros
instead of explicitly specifying the version in the text
in a bunch of man pages.


# 14101 15-Feb-1996 mpp

Fixed a bunch of man page cross references that were
in the main text of various man pages.

Thanks to Warner Losh for adding an option to manck to allow
it to scan the entire man page looking for bogus xrefs, instead
of just checking the SEE ALSO section.


# 14038 11-Feb-1996 mpp

Correct a bunch of man page cross references and generally
try and silence "manck".

ncurses, rpc, and some of the gnu stuff are still a big mess, however.


# 13836 02-Feb-1996 wosch

Submitted by: bruce, davidg, dyson
add a BUG section for mmap with current limitation
section SYNOPSIS completed


# 1574 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1573,
which included commits to RCS files with non-trunk default branches.


# 1573 27-May-1994 rgrimes

BSD 4.4 Lite Lib Sources