]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/mincore.2
mmap.2: srcfix: note kernel commit that caused MAP_POPULATE | MAP_NONBLOCK to be...
[thirdparty/man-pages.git] / man2 / mincore.2
1 .\" Copyright (C) 2001 Bert Hubert <ahu@ds9a.nl>
2 .\" and Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" Created Sun Jun 3 17:23:32 2001 by bert hubert <ahu@ds9a.nl>
27 .\" Slightly adapted, following comments by Hugh Dickins, aeb, 2001-06-04.
28 .\" Modified, 20 May 2003, Michael Kerrisk <mtk.manpages@gmail.com>
29 .\" Modified, 30 Apr 2004, Michael Kerrisk <mtk.manpages@gmail.com>
30 .\" 2005-04-05 mtk, Fixed error descriptions
31 .\" after message from <gordon.jin@intel.com>
32 .\" 2007-01-08 mtk, rewrote various parts
33 .\"
34 .TH MINCORE 2 2017-09-15 "Linux" "Linux Programmer's Manual"
35 .SH NAME
36 mincore \- determine whether pages are resident in memory
37 .SH SYNOPSIS
38 .B #include <unistd.h>
39 .br
40 .B #include <sys/mman.h>
41 .PP
42 .BI "int mincore(void *" addr ", size_t " length ", unsigned char *" vec );
43 .PP
44 .in -4n
45 Feature Test Macro Requirements for glibc (see
46 .BR feature_test_macros (7)):
47 .in
48 .PP
49 .BR mincore ():
50 Since glibc 2.19:
51 _DEFAULT_SOURCE
52 Glibc 2.19 and earlier:
53 _BSD_SOURCE || _SVID_SOURCE
54 .SH DESCRIPTION
55 .BR mincore ()
56 returns a vector that indicates whether pages
57 of the calling process's virtual memory are resident in core (RAM),
58 and so will not cause a disk access (page fault) if referenced.
59 The kernel returns residency information about the pages
60 starting at the address
61 .IR addr ,
62 and continuing for
63 .I length
64 bytes.
65 .PP
66 The
67 .I addr
68 argument must be a multiple of the system page size.
69 The
70 .I length
71 argument need not be a multiple of the page size,
72 but since residency information is returned for whole pages,
73 .I length
74 is effectively rounded up to the next multiple of the page size.
75 One may obtain the page size
76 .RB ( PAGE_SIZE )
77 using
78 .IR sysconf(_SC_PAGESIZE) .
79 .PP
80 The
81 .I vec
82 argument must point to an array containing at least
83 .I "(length+PAGE_SIZE\-1) / PAGE_SIZE"
84 bytes.
85 On return,
86 the least significant bit of each byte will be set if
87 the corresponding page is currently resident in memory,
88 and be clear otherwise.
89 (The settings of the other bits in each byte are undefined;
90 these bits are reserved for possible later use.)
91 Of course the information returned in
92 .I vec
93 is only a snapshot: pages that are not
94 locked in memory can come and go at any moment, and the contents of
95 .I vec
96 may already be stale by the time this call returns.
97 .SH RETURN VALUE
98 On success,
99 .BR mincore ()
100 returns zero.
101 On error, \-1 is returned, and
102 .I errno
103 is set appropriately.
104 .SH ERRORS
105 .B EAGAIN
106 kernel is temporarily out of resources.
107 .TP
108 .B EFAULT
109 .I vec
110 points to an invalid address.
111 .TP
112 .B EINVAL
113 .I addr
114 is not a multiple of the page size.
115 .TP
116 .B ENOMEM
117 .I length
118 is greater than
119 .RI ( TASK_SIZE " \- " addr ).
120 (This could occur if a negative value is specified for
121 .IR length ,
122 since that value will be interpreted as a large
123 unsigned integer.)
124 In Linux 2.6.11 and earlier, the error
125 .B EINVAL
126 was returned for this condition.
127 .TP
128 .B ENOMEM
129 .I addr
130 to
131 .I addr
132 +
133 .I length
134 contained unmapped memory.
135 .SH VERSIONS
136 Available since Linux 2.3.99pre1 and glibc 2.2.
137 .SH CONFORMING TO
138 .BR mincore ()
139 is not specified in POSIX.1,
140 and it is not available on all UNIX implementations.
141 .\" It is on at least NetBSD, FreeBSD, OpenBSD, Solaris 8,
142 .\" AIX 5.1, SunOS 4.1
143 .\" .SH HISTORY
144 .\" The
145 .\" .BR mincore ()
146 .\" function first appeared in 4.4BSD.
147 .SH BUGS
148 Before kernel 2.6.21,
149 .BR mincore ()
150 did not return correct information for
151 .B MAP_PRIVATE
152 mappings, or for nonlinear mappings (established using
153 .BR remap_file_pages (2)).
154 .\" Linux (up to now, 2.6.5),
155 .\" .B mincore
156 .\" does not return correct information for MAP_PRIVATE mappings:
157 .\" for a MAP_PRIVATE file mapping,
158 .\" .B mincore
159 .\" returns the residency of the file pages, rather than any
160 .\" modified process-private pages that have been copied on write;
161 .\" for a MAP_PRIVATE mapping of
162 .\" .IR /dev/zero ,
163 .\" .B mincore
164 .\" always reports pages as nonresident;
165 .\" and for a MAP_PRIVATE, MAP_ANONYMOUS mapping,
166 .\" .B mincore
167 .\" always fails with the error
168 .\" .BR ENOMEM .
169 .SH SEE ALSO
170 .BR fincore (1),
171 .BR madvise (2),
172 .BR mlock (2),
173 .BR mmap (2),
174 .BR posix_fadvise (2),
175 .BR posix_madvise (3)