madvise.2: Recast discussion of 'advice' into two groups of values

madvise() is one of those system calls that has congealed over
time, as has the man page. It's helpful to split the discussion
of 'advice' into those flags into two groups:

* Those flags that are (1) widespread across implementations;
  (2) have counterparts in posix_madvise(3); and (3) were present
  in the initial Linux madvise implementation.
* The rest, which are values that (1) may not have counterparts
  in other implementations; (2) have no counterparts in
  posix_madvise(3); and (3) were added to Linux in more recent
  times.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2015-02-03 14:11:17 +01:00
parent bdfe6b8f8e
commit 845c8bea2d
1 changed files with 41 additions and 16 deletions

View File

@ -50,25 +50,48 @@ _BSD_SOURCE
.SH DESCRIPTION
The
.BR madvise ()
system call advises the kernel about how to handle paging input/output in
the address range beginning at address
system call is used to give advice or directions to the kernel
about the address range beginning at address
.I addr
and with size
.I length
bytes.
It allows an application to tell the kernel how it expects to use
Initially, the system call supported a set of "conventional"
.I advice
values, which are also available on several other implementations.
(Note, though, that
.BR madvise ()
is not specified in POSIX.)
Subsequently, a number of Linux-specific
.IR advice
values have been added.
.\"
.\" ======================================================================
.\"
.SS Conventional advice values
The
.I advice
values listed below
allow an application to tell the kernel how it expects to use
some mapped or shared memory areas, so that the kernel can choose
appropriate read-ahead and caching techniques.
This call does not influence the semantics of the application
These
.I advice
values do not influence the semantics of the application
(except in the case of
.BR MADV_DONTNEED ),
but
may influence its performance.
but may influence its performance.
The kernel is free to ignore the advice.
All of the
.I advice
values listed here have analogs in the POSIX-specified
.BR posix_madvise (3)
function, and the values have the same meanings, with the exception of
.BR MADV_DONTNEED .
.LP
The advice is indicated in the
.I advice
argument which can be
argument which is one of the following:
.TP
.B MADV_NORMAL
No special treatment.
@ -97,6 +120,17 @@ either in reloading of the memory contents from the underlying mapped file
.BR mmap (2))
or zero-fill-on-demand pages for mappings
without an underlying file.
.\"
.\" ======================================================================
.\"
.SS Linux-specific advice values
The following Linux-specific
.I advice
values have no counterparts in the POSIX-specified
.BR posix_madvise (3),
and may or may not have counterparts in the
.BR madvise ()
interface available on other implementations:
.TP
.BR MADV_REMOVE " (since Linux 2.6.16)"
.\" commit f6b3ec238d12c8cc6cc71490c6e3127988460349
@ -359,15 +393,6 @@ and so on, with a behavior close to the similarly named flags listed above.
.BR POSIX_MADV_NOREUSE ,
that has no analog in
.BR madvise (2)).
.BR MADV_REMOVE ,
.BR MADV_DONTFORK ,
.BR MADV_DOFORK ,
.BR MADV_HWPOISON ,
.BR MADV_MERGEABLE ,
and
.BR MADV_UNMERGEABLE
are Linux-specific.
.SH NOTES
.SS Linux notes
.LP