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