]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/mincore.2
Fix wrong argument names in text.
[thirdparty/man-pages.git] / man2 / mincore.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (C) 2001 Bert Hubert <ahu@ds9a.nl>
4 .\" and Copyright (C) 2007 Michael Kerrisk <mtk-manpages@gmx.net>
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
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@gmx.net>
29 .\" Modified, 30 Apr 2004, Michael Kerrisk <mtk-manpages@gmx.net>
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 2007-01-08 "Linux 2.6.5" "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 .sp
42 .BI "int mincore(void *" start ", size_t " length ", unsigned char *" vec );
43 .SH DESCRIPTION
44 .BR mincore ()
45 returns a vector that indicates whether pages
46 of the calling process's virtual memory are resident in core (RAM),
47 and so will not cause a disk access (page fault) if referenced.
48 The kernel returns residency information about the pages
49 starting at the address
50 .IR start ,
51 and continuing for
52 .I length
53 bytes.
54
55 The
56 .I start
57 argument must be a multiple of the system page size.
58 The
59 .I length
60 argument need not be a multiple of the page size,
61 but since residency information is returned for whole pages,
62 .I length
63 is effectively rounded up to the next multiple of the page size.
64 One may obtain the page size (PAGE_SIZE) using
65 .IR sysconf(_SC_PAGESIZE) .
66
67 The
68 .I vec
69 argument must point to an array containing at least
70 (length+PAGE_SIZE-1) / PAGE_SIZE bytes.
71 On return,
72 the least significant bit of each byte will be set if
73 the corresponding page is currently resident in memory,
74 and be clear otherwise.
75 (The settings of the other bits in each byte are undefined;
76 these bits are reserved for possible later use.)
77 Of course the information returned in
78 .I vec
79 is only a snapshot: pages that are not
80 locked in memory can come and go at any moment, and the contents of
81 .I vec
82 may already be stale by the time this call returns.
83 .SH "RETURN VALUE"
84 On success,
85 .BR mincore ()
86 returns zero.
87 On error, \-1 is returned, and
88 .I errno
89 is set appropriately.
90 .SH ERRORS
91 .B EAGAIN
92 kernel is temporarily out of resources.
93 .TP
94 .B EFAULT
95 .I vec
96 points to an invalid address.
97 .TP
98 .B EINVAL
99 .I start
100 is not a multiple of the page size.
101 .TP
102 .B ENOMEM
103 .I length
104 is greater than
105 .RI ( TASK_SIZE " \- " start ).
106 (This could occur if a negative value is specified for
107 .IR length ,
108 since that value will be interpreted as a large
109 unsigned integer.)
110 In Linux 2.6.11 and earlier, the error
111 .B EINVAL
112 was returned for this condition.
113 .TP
114 .B ENOMEM
115 .I start
116 to
117 .I start
118 +
119 .I length
120 contained unmapped memory.
121 .SH BUGS
122 Before kernel 2.6.21,
123 .BR mincore ()
124 did not return correct information for
125 .B MAP_PRIVATE
126 mappings, or for non-linear mappings (established using
127 .BR remap_file_pages (2)).
128 .\" Linux (up to now, 2.6.5),
129 .\" .B mincore
130 .\" does not return correct information for MAP_PRIVATE mappings:
131 .\" for a MAP_PRIVATE file mapping,
132 .\" .B mincore
133 .\" returns the residency of the file pages, rather than any
134 .\" modified process-private pages that have been copied on write;
135 .\" for a MAP_PRIVATE mapping of
136 .\" .IR /dev/zero ,
137 .\" .B mincore
138 .\" always reports pages as non-resident;
139 .\" and for a MAP_PRIVATE, MAP_ANONYMOUS mapping,
140 .\" .B mincore
141 .\" always fails with the error
142 .\" .BR ENOMEM .
143 .SH "CONFORMING TO"
144 .BR mincore ()
145 is not specified in POSIX.1-2001,
146 and it is not available on all Unix implementations.
147 .\" It is on at least NetBSD, FreeBSD, OpenBSD, Solaris 8,
148 .\" AIX 5.1, SunOS 4.1
149 .SH HISTORY
150 The
151 .BR mincore ()
152 function first appeared in 4.4BSD.
153 .SH AVAILABILITY
154 Since Linux 2.3.99pre1 and glibc 2.2.
155 .SH "SEE ALSO"
156 .BR mlock (2),
157 .BR mmap (2)