1 MEMINFO(2) System Calls MEMINFO(2)
2
3
4
5 NAME
6 meminfo - provide information about memory
7
8 SYNOPSIS
9 #include <sys/types.h>
10 #include <sys/mman.h>
11
12 int meminfo(const uint64_t inaddr[], int addr_count,
13 const uint_t info_req[], int info_count, uint64_t outdata[],
14 uint_t validity[]);
15
16
17 PARAMETERS
18 inaddr
19 array of input addresses; the maximum number of addresses
20 that can be processed for each call is MAX_MEMINFO_CNT
21
22
23 addr_count
24 number of addresses
25
26
27 info_req
28 array of types of information requested
29
30
31 info_count
32 number of pieces of information requested for each
33 address in inaddr
34
35
36 outdata
37 array into which results are placed; array size must be
38 the product of info_count and addr_count
39
40
41 validity
42 array of size addr_count containing bitwise result codes;
43 0th bit evaluates validity of corresponding input
44 address, 1st bit validity of response to first member of
45 info_req, and so on
46
47
48 DESCRIPTION
49 The meminfo() function provides information about virtual and physical
50 memory particular to the calling process. The user or developer of
51 performance utilities can use this information to analyze system memory
52 allocations and develop a better understanding of the factors affecting
53 application performance.
54
55
56 The caller of meminfo() can obtain the following types of information
57 about both virtual and physical memory.
58
59 MEMINFO_VPHYSICAL
60 physical address corresponding to virtual
61 address
62
63
64 MEMINFO_VLGRP
65 locality group of physical page corresponding
66 to virtual address
67
68
69 MEMINFO_VPAGESIZE
70 size of physical page corresponding to
71 virtual address
72
73
74 MEMINFO_VREPLCNT
75 number of replicated physical pages
76 corresponding to specified virtual address
77
78
79 MEMINFO_VREPL | n
80 nth physical replica of specified virtual
81 address
82
83
84 MEMINFO_VREPL_LGRP | n
85 lgrp of nth physical replica of specified
86 virtual address
87
88
89 MEMINFO_PLGRP
90 locality group of specified physical address
91
92
93
94 All but MEMINFO_VLGRP and MEMINFO_VPAGESIZE require the
95 PRIV_PROC_MEMINFO privilege.
96
97
98 RETURN VALUES
99 All but MEMINFO_VLGRP and MEMINFO_VPAGESIZE require the
100 PRIV_PROC_MEMINFO privilege.
101
102
103 RETURN VALUES
104 Upon successful completion meminfo() returns 0. Otherwise -1 is
105 returned and errno is set to indicate the error.
106
107 ERRORS
108 The meminfo() function will fail if:
109
110 EFAULT
111 The area pointed to by outdata or validity could not be
112 written, or the data pointed to by info_req or inaddr could
113 not be read.
114
115
116 EINVAL
117 The value of info_count is greater than 31 or less than 1, or
118 the value of addr_count is less than 1.
119
120
121 EXAMPLES
122 Example 1 Print physical pages and page sizes corresponding to a set of
123 virtual addresses.
124
125
126 The following example prints the physical pages and page sizes
127 corresponding to a set of virtual addresses.
128
129
130 void
131 print_info(void **addrvec, int how_many)
132 {
133 static const uint_t info[] = {
134 MEMINFO_VPHYSICAL,
135 MEMINFO_VPAGESIZE
136 };
137
138 int info_num = sizeof (info) / sizeof (info[0]);
139 int i;
140
141 uint64_t *inaddr = alloca(sizeof (uint64_t) * how_many);
142 uint64_t *outdata = alloca(sizeof (uint64_t) * how_many * info_num);
143 uint_t *validity = alloca(sizeof (uint_t) * how_many);
144
145 for (i = 0; i < how_many; i++)
146 inaddr[i] = (uint64_t)addrvec[i];
147
148 if (meminfo(inaddr, how_many, info, info_num, outdata,
149 validity) < 0) {
150 perror("meminfo");
151 return;
152 }
153
154 for (i = 0; i < how_many; i++) {
155 if ((validity[i] & 1) == 0)
156 printf("address 0x%llx not part of address space\n",
157 inaddr[i]);
158
159 else if ((validity[i] & 2) == 0)
160 printf("address 0x%llx has no physical page "
161 "associated with it\n", inaddr[i]);
162
163 else {
164 char buff[80];
165 if ((validity[i] & 4) == 0)
166 strcpy(buff, "<Unknown>");
167 else
168 sprintf(buff, "%lld",
169 outdata[i * info_num + 1]);
170
171 printf("address 0x%llx is backed by physical "
172 "page 0x%llx of size %s\n",
173 inaddr[i], outdata[i * info_num], buff);
174 }
175 }
176 }
177
178
179 ATTRIBUTES
180 See attributes(5) for descriptions of the following attributes:
181
182
183
184
185 +--------------------+-------------------+
186 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
187 +--------------------+-------------------+
188 |Interface Stability | Stable |
189 +--------------------+-------------------+
190 |MT-Level | Async-Signal-Safe |
191 +--------------------+-------------------+
192
193 SEE ALSO
194 memcntl(2), mmap(2), gethomelgroup(3C), getpagesize(3C), madvise(3C),
195 sysconf(3C), attributes(5), privileges(5)
196
197
198
199 March 10, 2015 MEMINFO(2)