1MINCORE(2)                 Linux Programmer's Manual                MINCORE(2)
2
3
4

NAME

6       mincore - determine whether pages are resident in memory
7

SYNOPSIS

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():
17           Since glibc 2.19:
18               _DEFAULT_SOURCE
19           Glibc 2.19 and earlier:
20               _BSD_SOURCE || _SVID_SOURCE
21

DESCRIPTION

23       mincore()  returns a vector that indicates whether pages of the calling
24       process's virtual memory are resident in core (RAM), and  so  will  not
25       cause  a  disk  access  (page fault) if referenced.  The kernel returns
26       residency information about the pages starting at the address addr, and
27       continuing for length bytes.
28
29       The  addr  argument  must  be  a multiple of the system page size.  The
30       length argument need not be a multiple of the page size, but since res‐
31       idency  information  is returned for whole pages, length is effectively
32       rounded up to the next multiple of the page size.  One may  obtain  the
33       page size (PAGE_SIZE) using sysconf(_SC_PAGESIZE).
34
35       The   vec   argument  must  point  to  an  array  containing  at  least
36       (length+PAGE_SIZE-1) / PAGE_SIZE bytes.  On return, the least  signifi‐
37       cant  bit  of  each  byte will be set if the corresponding page is cur‐
38       rently resident in memory, and be clear otherwise.   (The  settings  of
39       the  other bits in each byte are undefined; these bits are reserved for
40       possible later use.)  Of course the information returned in vec is only
41       a  snapshot: pages that are not locked in memory can come and go at any
42       moment, and the contents of vec may already be stale by the  time  this
43       call returns.
44

RETURN VALUE

46       On  success,  mincore()  returns  zero.   On error, -1 is returned, and
47       errno is set appropriately.
48

ERRORS

50       EAGAIN kernel is temporarily out of resources.
51
52       EFAULT vec points to an invalid address.
53
54       EINVAL addr is not a multiple of the page size.
55
56       ENOMEM length is greater than (TASK_SIZE - addr).  (This could occur if
57              a  negative value is specified for length, since that value will
58              be interpreted as a large unsigned integer.)   In  Linux  2.6.11
59              and earlier, the error EINVAL was returned for this condition.
60
61       ENOMEM addr to addr + length contained unmapped memory.
62

VERSIONS

64       Available since Linux 2.3.99pre1 and glibc 2.2.
65

CONFORMING TO

67       mincore()  is  not specified in POSIX.1, and it is not available on all
68       UNIX implementations.
69

BUGS

71       Before kernel 2.6.21, mincore() did not return correct information  for
72       MAP_PRIVATE  mappings,  or  for  nonlinear  mappings (established using
73       remap_file_pages(2)).
74

SEE ALSO

76       fincore(1), madvise(2), mlock(2), mmap(2), posix_fadvise(2), posix_mad‐
77       vise(3)
78

COLOPHON

80       This  page  is  part of release 5.04 of the Linux man-pages project.  A
81       description of the project, information about reporting bugs,  and  the
82       latest     version     of     this    page,    can    be    found    at
83       https://www.kernel.org/doc/man-pages/.
84
85
86
87Linux                             2017-09-15                        MINCORE(2)
Impressum