1 .\" Copyright (C) 2001 Bert Hubert <ahu@ds9a.nl>
2 .\" and Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" Created Sun Jun 3 17:23:32 2001 by bert hubert <ahu@ds9a.nl>
7 .\" Slightly adapted, following comments by Hugh Dickins, aeb, 2001-06-04.
8 .\" Modified, 20 May 2003, Michael Kerrisk <mtk.manpages@gmail.com>
9 .\" Modified, 30 Apr 2004, Michael Kerrisk <mtk.manpages@gmail.com>
10 .\" 2005-04-05 mtk, Fixed error descriptions
11 .\" after message from <gordon.jin@intel.com>
12 .\" 2007-01-08 mtk, rewrote various parts
14 .TH MINCORE 2 2021-03-22 "Linux man-pages (unreleased)"
16 mincore \- determine whether pages are resident in memory
19 .RI ( libc ", " \-lc )
22 .B #include <sys/mman.h>
24 .BI "int mincore(void *" addr ", size_t " length ", unsigned char *" vec );
28 Feature Test Macro Requirements for glibc (see
29 .BR feature_test_macros (7)):
36 Glibc 2.19 and earlier:
37 _BSD_SOURCE || _SVID_SOURCE
41 returns a vector that indicates whether pages
42 of the calling process's virtual memory are resident in core (RAM),
43 and so will not cause a disk access (page fault) if referenced.
44 The kernel returns residency information about the pages
45 starting at the address
53 argument must be a multiple of the system page size.
56 argument need not be a multiple of the page size,
57 but since residency information is returned for whole pages,
59 is effectively rounded up to the next multiple of the page size.
60 One may obtain the page size
63 .IR sysconf(_SC_PAGESIZE) .
67 argument must point to an array containing at least
68 .I "(length+PAGE_SIZE\-1) / PAGE_SIZE"
71 the least significant bit of each byte will be set if
72 the corresponding page is currently resident in memory,
73 and be clear otherwise.
74 (The settings of the other bits in each byte are undefined;
75 these bits are reserved for possible later use.)
76 Of course the information returned in
78 is only a snapshot: pages that are not
79 locked in memory can come and go at any moment, and the contents of
81 may already be stale by the time this call returns.
86 On error, \-1 is returned, and
88 is set to indicate the error.
91 kernel is temporarily out of resources.
95 points to an invalid address.
99 is not a multiple of the page size.
104 .RI ( TASK_SIZE " \- " addr ).
105 (This could occur if a negative value is specified for
107 since that value will be interpreted as a large
109 In Linux 2.6.11 and earlier, the error
111 was returned for this condition.
119 contained unmapped memory.
121 Available since Linux 2.3.99pre1 and glibc 2.2.
124 is not specified in POSIX.1,
125 and it is not available on all UNIX implementations.
126 .\" It is on at least NetBSD, FreeBSD, OpenBSD, Solaris 8,
127 .\" AIX 5.1, SunOS 4.1
131 .\" function first appeared in 4.4BSD.
133 Before kernel 2.6.21,
135 did not return correct information for
137 mappings, or for nonlinear mappings (established using
138 .BR remap_file_pages (2)).
139 .\" Linux (up to now, 2.6.5),
141 .\" does not return correct information for MAP_PRIVATE mappings:
142 .\" for a MAP_PRIVATE file mapping,
144 .\" returns the residency of the file pages, rather than any
145 .\" modified process-private pages that have been copied on write;
146 .\" for a MAP_PRIVATE mapping of
149 .\" always reports pages as nonresident;
150 .\" and for a MAP_PRIVATE, MAP_ANONYMOUS mapping,
152 .\" always fails with the error
159 .BR posix_fadvise (2),
160 .BR posix_madvise (3)