1MINCORE(2) Linux Programmer's Manual MINCORE(2)
2
3
4
6 mincore - determine whether pages are resident in memory
7
9 #include <unistd.h>
10 #include <sys/mman.h>
11
12 int mincore(void *addr, size_t length, unsigned char *vec);
13
14 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16 mincore(): _BSD_SOURCE || _SVID_SOURCE
17
19 mincore() returns a vector that indicates whether pages of the calling
20 process's virtual memory are resident in core (RAM), and so will not
21 cause a disk access (page fault) if referenced. The kernel returns
22 residency information about the pages starting at the address addr, and
23 continuing for length bytes.
24
25 The addr argument must be a multiple of the system page size. The
26 length argument need not be a multiple of the page size, but since res‐
27 idency information is returned for whole pages, length is effectively
28 rounded up to the next multiple of the page size. One may obtain the
29 page size (PAGE_SIZE) using sysconf(_SC_PAGESIZE).
30
31 The vec argument must point to an array containing at least
32 (length+PAGE_SIZE-1) / PAGE_SIZE bytes. On return, the least signifi‐
33 cant bit of each byte will be set if the corresponding page is cur‐
34 rently resident in memory, and be clear otherwise. (The settings of
35 the other bits in each byte are undefined; these bits are reserved for
36 possible later use.) Of course the information returned in vec is only
37 a snapshot: pages that are not locked in memory can come and go at any
38 moment, and the contents of vec may already be stale by the time this
39 call returns.
40
42 On success, mincore() returns zero. On error, -1 is returned, and
43 errno is set appropriately.
44
46 EAGAIN kernel is temporarily out of resources.
47
48 EFAULT vec points to an invalid address.
49
50 EINVAL addr is not a multiple of the page size.
51
52 ENOMEM length is greater than (TASK_SIZE - addr). (This could occur if
53 a negative value is specified for length, since that value will
54 be interpreted as a large unsigned integer.) In Linux 2.6.11
55 and earlier, the error EINVAL was returned for this condition.
56
57 ENOMEM addr to addr + length contained unmapped memory.
58
60 Available since Linux 2.3.99pre1 and glibc 2.2.
61
63 mincore() is not specified in POSIX.1-2001, and it is not available on
64 all Unix implementations.
65
67 Before kernel 2.6.21, mincore() did not return correct information for
68 MAP_PRIVATE mappings, or for nonlinear mappings (established using
69 remap_file_pages(2)).
70
72 mlock(2), mmap(2)
73
75 This page is part of release 3.25 of the Linux man-pages project. A
76 description of the project, and information about reporting bugs, can
77 be found at http://www.kernel.org/doc/man-pages/.
78
79
80
81Linux 2008-04-22 MINCORE(2)