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