summaryrefslogtreecommitdiff
path: root/usr/src/man/man3c
diff options
context:
space:
mode:
authorDan McDonald <danmcd@joyent.com>2022-04-20 14:46:04 -0400
committerDan McDonald <danmcd@joyent.com>2022-04-20 14:46:04 -0400
commitedca041beee90a450071fd47356c26905e1b9937 (patch)
treebd9182e1cf7a01446f4145ddd32f98ee29305cba /usr/src/man/man3c
parentf077edea49a734a4c170f2c437f67f85291543e7 (diff)
parentdf5cd018c34371890eeeb8c930245b9323e8aa25 (diff)
downloadillumos-joyent-release-20220421.tar.gz
[illumos-gate merge]release-20220421
commit df5cd018c34371890eeeb8c930245b9323e8aa25 14418 mman.h symbol visibility is a mess commit 34331de35882eb41acdf4f0d2065b5e12d083e82 14531 want nvme namespace management mutex commit 353d89b0745ef752e824c1afc3f0474f66dfbd64 14530 nvme should require exclusive open for attach, detach, and format ioctls commit c542a624b7efda0b8123026500f05f430ff6c770 14607 Add CONS_GETDEV so we can see which port is /dev/console
Diffstat (limited to 'usr/src/man/man3c')
-rw-r--r--usr/src/man/man3c/madvise.3c465
-rw-r--r--usr/src/man/man3c/mlock.3c339
2 files changed, 381 insertions, 423 deletions
diff --git a/usr/src/man/man3c/madvise.3c b/usr/src/man/man3c/madvise.3c
index c6d39ab8d4..dd523a2c0c 100644
--- a/usr/src/man/man3c/madvise.3c
+++ b/usr/src/man/man3c/madvise.3c
@@ -1,36 +1,62 @@
-'\" te
+.\"
+.\" Copyright 2022 Oxide Computer Company
.\" Copyright (c) 2005, Sun Microsystems, Inc. All Right Reserved.
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
-.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
-.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH MADVISE 3C "Mar 28, 2016"
-.SH NAME
-madvise \- provide advice to VM system
-.SH SYNOPSIS
-.LP
-.nf
-#include <sys/types.h>
-#include <sys/mman.h>
-
-\fBint\fR \fBmadvise\fR(\fBcaddr_t\fR \fIaddr\fR, \fBsize_t\fR \fIlen\fR, \fBint\fR \fIadvice\fR);
-.fi
-
-.SH DESCRIPTION
-.LP
-The \fBmadvise()\fR function advises the kernel that a region of user mapped
-memory in the range [\fIaddr\fR, \fIaddr\fR + \fIlen\fR) will be accessed
-following a type of pattern. The kernel uses this information to optimize the
-procedure for manipulating and maintaining the resources associated with the
-specified mapping range. In general (and true to the name of the function),
-the advice is merely advisory, and the only user-visible ramifications
-are in terms of performance, not semantics. Note that
-\fBMADV_PURGE\fR is an exception to this; see below for details.
-.sp
-.LP
-Values for \fIadvice\fR are defined in <\fBsys/mman.h\fR> as:
-.sp
-.in +2
-.nf
+.\"
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.\"
+.Dd March 13, 2022
+.Dt MADVISE 3C
+.Os
+.Sh NAME
+.Nm madvise
+.Nd provide advice to VM system
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/mman.h
+.Ft int
+.Fo madviase
+.Fa "void *addr"
+.Fa "size_t len"
+.Fa "int advice"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn madvise
+function advises the kernel that a region of user mapped memory in the range
+.Pf [ Fa addr ,
+.Fa addr
++
+.Fa len Ns
+) will be accessed following a type of pattern.
+The kernel uses this information to optimize the procedure for manipulating and
+maintaining the resources associated with the specified mapping range.
+In general
+.Pq and true to the name of the function ,
+the advice is merely advisory, and the only user-visible ramifications are in
+terms of performance, not semantics.
+Note that
+.Dv MADV_PURGE
+is an exception to this; see below for details.
+.Pp
+Values for
+.Fa advice
+are defined in
+.In sys/mman.h
+as:
+.Bd -literal -offset indent
#define MADV_NORMAL 0x0 /* No further special treatment */
#define MADV_RANDOM 0x1 /* Expect random page references */
#define MADV_SEQUENTIAL 0x2 /* Expect sequential page references */
@@ -41,246 +67,175 @@ Values for \fIadvice\fR are defined in <\fBsys/mman.h\fR> as:
#define MADV_ACCESS_LWP 0x7 /* next LWP to access heavily */
#define MADV_ACCESS_MANY 0x8 /* many processes to access heavily */
#define MADV_PURGE 0x9 /* contents will be purged */
-.fi
-.in -2
-
-.sp
-.ne 2
-.na
-\fB\fBMADV_NORMAL\fR\fR
-.ad
-.RS 23n
+.Ed
+.Bl -tag -width Ds
+.It Dv MADV_NORMAL
This is the default system characteristic where accessing memory within the
-address range causes the system to read data from the mapped file. The kernel
-reads all data from files into pages which are retained for a period of time as
-a "cache." System pages can be a scarce resource, so the kernel steals pages
-from other mappings when needed. This is a likely occurrence, but adversely
-affects system performance only if a large amount of memory is accessed.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBMADV_RANDOM\fR\fR
-.ad
-.RS 23n
+address range causes the system to read data from the mapped file.
+The kernel reads all data from files into pages which are retained for a period
+of time as a
+.Dq cache .
+System pages can be a scarce resource, so the kernel steals pages from other
+mappings when needed.
+This is a likely occurrence, but adversely affects system performance only if a
+large amount of memory is accessed.
+.It Dv MADV_RANDOM
Tell the kernel to read in a minimum amount of data from a mapped file on any
-single particular access. If \fBMADV_NORMAL\fR is in effect when an address of
-a mapped file is accessed, the system tries to read in as much data from the
-file as reasonable, in anticipation of other accesses within a certain
-locality.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBMADV_SEQUENTIAL\fR\fR
-.ad
-.RS 23n
+single particular access.
+If
+.Dv MADV_NORMAL
+is in effect when an address of a mapped file is accessed, the system tries to
+read in as much data from the file as reasonable, in anticipation of other
+accesses within a certain locality.
+.It Dv MADV_SEQUENTIAL
Tell the system that addresses in this range are likely to be accessed only
once, so the system will free the resources mapping the address range as
quickly as possible.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBMADV_WILLNEED\fR\fR
-.ad
-.RS 23n
+.It Dv MADV_WILLNEED
Tell the system that a certain address range is definitely needed so the kernel
-will start reading the specified range into memory. This can benefit programs
-wanting to minimize the time needed to access memory the first time, as the
-kernel would need to read in from the file.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBMADV_DONTNEED\fR\fR
-.ad
-.RS 23n
+will start reading the specified range into memory.
+This can benefit programs wanting to minimize the time needed to access memory
+the first time, as the kernel would need to read in from the file.
+.It Dv MADV_DONTNEED
Tell the kernel that the specified address range is no longer needed, so the
system starts to free the resources associated with the address range.
-While the semantics of \fBMADV_DONTNEED\fR are similar to other systems,
-they differ significantly from the semantics on Linux, where
-\fBMADV_DONTNEED\fR will actually synchronously purge the address range,
-and subsequent faults will load from either backing store or be
-zero-filled on demand. If the peculiar Linux semantics are
-desired, \fBMADV_PURGE\fR should be used in lieu of \fBMADV_DONTNEED\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBMADV_FREE\fR\fR
-.ad
-.RS 23n
+While the semantics of
+.Dv MADV_DONTNEED
+are similar to other systems, they differ significantly from the semantics on
+Linux, where
+.Dv MADV_DONTNEED
+will actually synchronously purge the address range, and subsequent faults will
+load from either backing store or be zero-filled on demand.
+If the peculiar Linux semantics are desired,
+.Dv MADV_PURGE
+should be used in lieu of
+.Dv MADV_DONTNEED .
+.It Dv MADV_FREE
Tell the kernel that contents in the specified address range are no longer
-important and the range will be overwritten. When there is demand for memory,
-the system will free pages associated with the specified address range. In this
-instance, the next time a page in the address range is referenced, it will
-contain all zeroes. Otherwise, it will contain the data that was there prior
-to the \fBMADV_FREE\fR call. References made to the address range will not make
-the system read from backing store (swap space) until the page is modified
-again.
-.sp
+important and the range will be overwritten.
+When there is demand for memory, the system will free pages associated with the
+specified address range.
+In this instance, the next time a page in the address range is referenced, it
+will contain all zeroes.
+Otherwise, it will contain the data that was there prior to the
+.Dv MADV_FREE
+call.
+References made to the address range will not make the system read from backing
+store
+.Pq swap space
+until the page is modified again.
+.Pp
This value cannot be used on mappings that have underlying file objects.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBMADV_PURGE\fR\fR
-.ad
-.RS 23n
-Tell the kernel to purge the specified address range. The mapping will
-be retained, but the pages themselves will be destroyed; subsequent
-faults on the range will result in the page being read from backing
-store (if file-backed) or being zero-filled on demand (if anonymous). Note
-that these semantics are generally inferior to \fBMADV_FREE\fR, which gives the
-system more flexibility and results in better performance
-when pages are, in fact, reused by the caller. Indeed, \fBMADV_PURGE\fR only
-exists to provide an equivalent to the unfortunate
-\fBMADV_DONTNEED\fR semantics found in Linux, upon which some programs
-have (regrettably) come to depend. In de novo applications,
-\fBMADV_PURGE\fR should be avoided; \fBMADV_FREE\fR should always be
-preferred.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBMADV_ACCESS_LWP\fR\fR
-.ad
-.RS 23n
+.It Dv MADV_PURGE
+Tell the kernel to purge the specified address range.
+The mapping will be retained, but the pages themselves will be destroyed;
+subsequent faults on the range will result in the page being read from backing
+store
+.Pq if file-backed
+or being zero-filled on demand
+.Pq if anonymous .
+Note that these semantics are generally inferior to
+.Dv MADV_FREE ,
+which gives the system more flexibility and results in better performance when
+pages are, in fact, reused by the caller.
+Indeed,
+.Dv MADV_PURGE
+only exists to provide an equivalent to the unfortunate
+.Dv MADV_DONTNEED
+semantics found in Linux, upon which some programs have
+.Pq regrettably
+come to depend.
+In de novo applications,
+.Dv MADV_PURGE
+should be avoided;
+.Dv MADV_FREE
+should always be preferred.
+.It Dv MADV_ACCESS_LWP
Tell the kernel that the next LWP to touch the specified address range will
access it most heavily, so the kernel should try to allocate the memory and
other resources for this range and the LWP accordingly.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBMADV_ACCESS_MANY\fR\fR
-.ad
-.RS 23n
+.It Dv MADV_ACCESS_MANY
Tell the kernel that many processes and/or LWPs will access the specified
address range randomly across the machine, so the kernel should try to allocate
the memory and other resources for this range accordingly.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBMADV_ACCESS_DEFAULT\fR\fR
-.ad
-.RS 23n
+.It Dv MADV_ACCESS_DEFAULT
Reset the kernel's expectation for how the specified range will be accessed to
the default.
-.RE
-
-.sp
-.LP
-The \fBmadvise()\fR function should be used by applications with specific
-knowledge of their access patterns over a memory object, such as a mapped file,
-to increase system performance.
-.SH RETURN VALUES
-.LP
-Upon successful completion, \fBmadvise()\fR returns \fB0\fR; otherwise, it
-returns \fB\(mi1\fR and sets \fBerrno\fR to indicate the error.
-.SH ERRORS
-.ne 2
-.na
-\fB\fBEAGAIN\fR\fR
-.ad
-.RS 10n
-Some or all mappings in the address range [\fIaddr\fR, \fIaddr\fR +
-\fIlen\fR) are locked for I/O.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEBUSY\fR\fR
-.ad
-.RS 10n
-Some or all of the addresses in the range [\fIaddr\fR, \fIaddr\fR + \fIlen\fR)
-are locked and \fBMS_SYNC\fR with the \fBMS_INVALIDATE\fR option is specified.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEFAULT\fR\fR
-.ad
-.RS 10n
+.El
+.Pp
+The
+.Fn madvise
+function should be used by applications with specific knowledge of their access
+patterns over a memory object, such as a mapped file, to increase system
+performance.
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn madvise
+returns
+.Sy 0 ;
+otherwise, it returns
+.Sy -1
+and sets
+.Va errno
+to indicate the error.
+.Sh ERRORS
+.Bl -tag -width Er
+.It Er EAGAIN
+Some or all mappings in the address range
+.Pf [ Fa addr ,
+.Fa addr
++
+.Fa len Ns
+) are locked for I/O.
+.It Er EBUSY
+.ad
+Some or all of the addresses in the range
+.Pf [ Fa addr ,
+.Fa addr
++
+.Fa len Ns
+) are locked and
+.Dv MS_SYNC
+with the
+.Dv MS_INVALIDATE
+option is specified.
+.It Er EFAULT
Some or all of the addresses in the specified range could not be read into
-memory from the underlying object when performing \fBMADV_WILLNEED\fR. The
-\fBmadvise()\fR function could return prior to this condition being detected,
-in which case \fBerrno\fR will not be set to \fBEFAULT\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEINVAL\fR\fR
-.ad
-.RS 10n
-The \fIaddr\fR argument is not a multiple of the page size as returned by
-\fBsysconf\fR(3C), the length of the specified address range is equal to 0, or
-the \fIadvice\fR argument was invalid.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEIO\fR\fR
-.ad
-.RS 10n
+memory from the underlying object when performing
+.Dv MADV_WILLNEED .
+The
+.Fn madvise
+function could return prior to this condition being detected, in which case
+.Va errno
+will not be set to
+.Er EFAULT .
+.It Er EINVAL
+The
+.Fa addr
+argument is not a multiple of the page size as returned by
+.Xr sysconf 3C ,
+the length of the specified address range is equal to 0, or the
+.Fa advice
+argument was invalid.
+.It Er EIO
An I/O error occurred while reading from or writing to the file system.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENOMEM\fR\fR
-.ad
-.RS 10n
-Addresses in the range [\fIaddr\fR, \fIaddr\fR + \fIlen\fR) are outside the
-valid range for the address space of a process, or specify one or more pages
-that are not mapped.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBESTALE\fR\fR
-.ad
-.RS 10n
-Stale \fBNFS\fR file handle.
-.RE
-
-.SH ATTRIBUTES
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Stable
-_
-MT-Level MT-Safe
-.TE
-
-.SH SEE ALSO
-.LP
-.BR meminfo (2),
-.BR mmap (2),
-.BR sysconf (3C),
-.BR attributes (7)
+.It Er ENOMEM
+Addresses in the range
+.Pf [ Fa addr ,
+.Fa addr
++
+.Fa len Ns
+) are outside the valid range for the address space of a process, or specify one
+or more pages that are not mapped.
+.It Er ESTALE
+Stale NFS file handle.
+.El
+.Sh INTERFACE STABILITY
+.Sy Committed
+.Sh MT-LEVEL
+.Sy MT-Safe
+.Sh SEE ALSO
+.Xr meminfo 2 ,
+.Xr mmap 2 ,
+.Xr sysconf 3C ,
+.Xr attributes 7
diff --git a/usr/src/man/man3c/mlock.3c b/usr/src/man/man3c/mlock.3c
index 692d94d623..6cda515ef3 100644
--- a/usr/src/man/man3c/mlock.3c
+++ b/usr/src/man/man3c/mlock.3c
@@ -1,175 +1,178 @@
-'\" te
+.\"
+.\" Copyright 2022 Oxide Computer Company
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 1989 AT&T
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
-.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
-.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH MLOCK 3C "Apr 10, 2007"
-.SH NAME
-mlock, munlock \- lock or unlock pages in memory
-.SH SYNOPSIS
-.LP
-.nf
-#include <sys/mman.h>
-
-\fBint\fR \fBmlock\fR(\fBcaddr_t\fR \fIaddr\fR, \fBsize_t\fR \fIlen\fR);
-.fi
-
-.LP
-.nf
-\fBint\fR \fBmunlock\fR(\fBcaddr_t\fR \fIaddr\fR, \fBsize_t\fR \fIlen\fR);
-.fi
-
-.SS "Standard conforming"
-.LP
-.nf
-#include <sys/mman.h>
-
-\fBint\fR \fBmlock\fR(\fBconst void *\fR \fIaddr\fR, \fBsize_t\fR \fIlen\fR);
-.fi
-
-.LP
-.nf
-\fBint\fR \fBmunlock\fR(\fBconst void *\fR \fIaddr\fR, \fBsize_t\fR \fIlen\fR);
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBmlock()\fR function uses the mappings established for the address range
-[\fIaddr, addr + len\fR) to identify pages to be locked in memory. If the page
-identified by a mapping changes, such as occurs when a copy of a writable
-\fBMAP_PRIVATE\fR page is made upon the first store, the lock will be
-transferred to the newly copied private page.
-.sp
-.LP
-The \fBmunlock()\fR function removes locks established with \fBmlock()\fR.
-.sp
-.LP
-A given page may be locked multiple times by executing an \fBmlock()\fR through
-different mappings. That is, if two different processes lock the same page,
-then the page will remain locked until both processes remove their locks.
-However, within a given mapping, page locks do not nest \(mi multiple
-\fBmlock()\fR operations on the same address in the same process will all be
-removed with a single \fBmunlock()\fR. Of course, a page locked in one process
-and mapped in another (or visible through a different mapping in the locking
-process) is still locked in memory. This fact can be used to create
-applications that do nothing other than lock important data in memory, thereby
-avoiding page I/O faults on references from other processes in the system.
-.sp
-.LP
+.\"
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.\"
+.Dd March 13, 2022
+.Dt MLOCK 3C
+.Os
+.Sh NAME
+.Nm mlock ,
+.Nm munlock
+.Nd lock or unlock pages in memory
+.Sh SYNOPSIS
+.In sys/mman.h
+.Ft int
+.Fo mlock
+.Fa "const void *addr"
+.Fa "size_t len"
+.Fc
+.Ft int
+.Fo munlock
+.Fa "const void *addr"
+.Fa "size_t len"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn mlock
+function uses the mappings established for the address range
+.Pf [ Fa addr ,
+.Fa addr
++
+.Fa len Ns
+) to identify pages to be locked in memory.
+If the page identified by a mapping changes, such as occurs when a copy of a
+writable
+.Dv MAP_PRIVATE
+page is made upon the first store, the lock will be transferred to the newly
+copied private page.
+.Pp
+The
+.Fn munlock
+function removes locks established with
+.Fn mlock .
+.Pp
+A given page may be locked multiple times by executing an
+.Fn mlock
+through different mappings.
+That is, if two different processes lock the same page, then the page will
+remain locked until both processes remove their locks.
+However, within a given mapping, page locks do not nest \(em multiple
+.Fn mlock
+operations on the same address in the same process will all be removed with a
+single
+.Fn munlock .
+Of course, a page locked in one process and mapped in another
+.Pq or visible through a different mapping in the locking process
+is still locked in memory.
+This fact can be used to create applications that do nothing other than lock
+important data in memory, thereby avoiding page I/O faults on references from
+other processes in the system.
+.Pp
The contents of the locked pages will not be transferred to or from disk except
-when explicitly requested by one of the locking processes. This guarantee
-applies only to the mapped data, and not to any associated data structures
-(file descriptors and on-disk metadata, among others).
-.sp
-.LP
-If the mapping through which an \fBmlock()\fR has been performed is removed, an
-\fBmunlock()\fR is implicitly performed. An \fBmunlock()\fR is also performed
-implicitly when a page is deleted through file removal or truncation.
-.sp
-.LP
-Locks established with \fBmlock()\fR are not inherited by a child process after
-a \fBfork()\fR and are not nested.
-.sp
-.LP
-Attempts to \fBmlock()\fR more memory than a system-specific limit will fail.
-.SH RETURN VALUES
-.sp
-.LP
-Upon successful completion, the \fBmlock()\fR and \fBmunlock()\fR functions
-return \fB0\fR. Otherwise, no changes are made to any locks in the address
-space of the process, the functions return \fB\(mi1\fR and set \fBerrno\fR to
-indicate the error.
-.SH ERRORS
-.sp
-.LP
-The \fBmlock()\fR and \fBmunlock()\fR functions will fail if:
-.sp
-.ne 2
-.na
-\fB\fBEINVAL\fR\fR
-.ad
-.RS 10n
-The \fIaddr\fR argument is not a multiple of the page size as returned by
-\fBsysconf\fR(3C).
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENOMEM\fR\fR
-.ad
-.RS 10n
-Addresses in the range [\fIaddr, addr + len\fR) are invalid for the address
-space of a process, or specify one or more pages which are not mapped.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENOSYS\fR\fR
-.ad
-.RS 10n
+when explicitly requested by one of the locking processes.
+This guarantee applies only to the mapped data, and not to any associated data
+structures
+.Pq file descriptors and on-disk metadata, among others .
+.Pp
+If the mapping through which an
+.Fn mlock
+has been performed is removed, an
+.Fn munlock
+is implicitly performed.
+An
+.Fn munlock
+is also performed implicitly when a page is deleted through file removal or
+truncation.
+.Pp
+Locks established with
+.Fn mlock
+are not inherited by a child process after
+a
+.Xr fork 2
+and are not nested.
+.Pp
+Attempts to
+.Fn mlock
+more memory than a system-specific limit will fail.
+.Sh RETURN VALUES
+Upon successful completion, the
+.Fn mlock
+and
+.Fn munlock
+functions return
+.Sy 0 .
+Otherwise, no changes are made to any locks in the address space of the process,
+the functions return
+.Sy -1
+and set
+.Va errno
+to indicate the error.
+.Sh ERRORS
+The
+.Fn mlock
+and
+.Fn munlock
+functions will fail if:
+.Bl -tag -width Er
+.It Er EINVAL
+The
+.Fa addr
+argument is not a multiple of the page size as returned by
+.Xr sysconf 3C .
+.It Er ENOMEM
+Addresses in the range
+.Pf [ Fa addr ,
+.Fa addr
++
+.Fa len Ns
+) are invalid for the address space of a process, or specify one or more pages
+which are not mapped.
+.It Er ENOSYS
The system does not support this memory locking interface.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEPERM\fR\fR
-.ad
-.RS 10n
-The {\fBPRIV_PROC_LOCK_MEMORY\fR} privilege is not asserted in the effective
-set of the calling process.
-.RE
-
-.sp
-.LP
-The \fBmlock()\fR function will fail if:
-.sp
-.ne 2
-.na
-\fB\fBEAGAIN\fR\fR
+.It Er EPERM
+The
+.Brq PRIV_PROC_LOCK_MEMORY
+privilege is not asserted in the effective set of the calling process.
+.El
+.Pp
+The
+.Fn mlock
+function will fail if:
+.Bl -tag -width Er
+.It Er EAGAIN
.ad
-.RS 10n
-Some or all of the memory identified by the range [\fIaddr, addr + len\fR)
-could not be locked because of insufficient system resources or because of a
+Some or all of the memory identified by the range
+.Pf [ Fa addr ,
+.Fa addr
++
+.Fa len Ns
+) could not be locked because of insufficient system resources or because of a
limit or resource control on locked memory.
-.RE
-
-.SH USAGE
-.sp
-.LP
-Because of the impact on system resources, the use of \fBmlock()\fR and
-\fBmunlock()\fR is restricted to users with the {\fBPRIV_PROC_LOCK_MEMORY\fR}
+.El
+.Sh USAGE
+Because of the impact on system resources, the use of
+.Fn mlock
+and
+.Fn munlock
+is restricted to users with the
+.Brq PRIV_PROC_LOCK_MEMORY
privilege.
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Standard
-_
-MT-Level MT-Safe
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-.BR fork (2),
-.BR memcntl (2),
-.BR mmap (2),
-.BR mlockall (3C),
-.BR plock (3C),
-.BR sysconf (3C),
-.BR attributes (7),
-.BR standards (7)
+.Sh INTERFACE STABILITY
+.Sy Committed
+.Sh MT-LEVEL
+.Sy MT-Safe
+.Sh SEE ALSO
+.Xr fork 2 ,
+.Xr memcntl 2 ,
+.Xr mmap 2 ,
+.Xr mlockall 3C ,
+.Xr plock 3C ,
+.Xr sysconf 3C ,
+.Xr attributes 7 ,
+.Xr standards 7