Print this page
OS-4028 need a priv for meminfo and disallow by default for a zone
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/man/man2/meminfo.2
+++ new/usr/src/man/man2/meminfo.2
1 1 '\" te
2 2 .\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
3 3 .\" Copyright 2015, Joyent, Inc.
4 4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 7 .TH MEMINFO 2 "Mar 10, 2015"
8 8 .SH NAME
9 9 meminfo \- provide information about memory
10 10 .SH SYNOPSIS
11 11 .LP
12 12 .nf
13 13 #include <sys/types.h>
14 14 #include <sys/mman.h>
15 15
16 16 \fBint\fR \fBmeminfo\fR(\fBconst uint64_t\fR \fIinaddr\fR[], \fBint\fR \fIaddr_count\fR,
17 17 \fBconst uint_t\fR \fIinfo_req\fR[], \fBint\fR \fIinfo_count\fR, \fBuint64_t\fR \fIoutdata\fR[],
18 18 \fBuint_t\fR \fIvalidity\fR[]);
19 19 .fi
20 20
21 21 .SH PARAMETERS
22 22 .ne 2
23 23 .na
24 24 \fB\fIinaddr\fR\fR
25 25 .ad
26 26 .RS 14n
27 27 array of input addresses; the maximum number of addresses that can be processed
28 28 for each call is \fBMAX_MEMINFO_CNT\fR
29 29 .RE
30 30
31 31 .sp
32 32 .ne 2
33 33 .na
34 34 \fB\fIaddr_count\fR\fR
35 35 .ad
36 36 .RS 14n
37 37 number of addresses
38 38 .RE
39 39
40 40 .sp
41 41 .ne 2
42 42 .na
43 43 \fB\fIinfo_req\fR\fR
44 44 .ad
45 45 .RS 14n
46 46 array of types of information requested
47 47 .RE
48 48
49 49 .sp
50 50 .ne 2
51 51 .na
52 52 \fB\fIinfo_count\fR\fR
53 53 .ad
54 54 .RS 14n
55 55 number of pieces of information requested for each address in \fIinaddr\fR
56 56 .RE
57 57
58 58 .sp
59 59 .ne 2
60 60 .na
61 61 \fB\fIoutdata\fR\fR
62 62 .ad
63 63 .RS 14n
64 64 array into which results are placed; array size must be the product of
65 65 \fIinfo_count\fR and \fIaddr_count\fR
66 66 .RE
67 67
68 68 .sp
69 69 .ne 2
70 70 .na
71 71 \fB\fIvalidity\fR\fR
72 72 .ad
73 73 .RS 14n
74 74 array of size \fIaddr_count\fR containing bitwise result codes; 0th bit
75 75 evaluates validity of corresponding input address, 1st bit validity of response
76 76 to first member of \fIinfo_req\fR, and so on
77 77 .RE
78 78
79 79 .SH DESCRIPTION
80 80 .LP
81 81 The \fBmeminfo()\fR function provides information about virtual and physical
82 82 memory particular to the calling process. The user or developer of performance
83 83 utilities can use this information to analyze system memory allocations and
84 84 develop a better understanding of the factors affecting application
85 85 performance.
86 86 .sp
87 87 .LP
88 88 The caller of \fBmeminfo()\fR can obtain the following types of information
89 89 about both virtual and physical memory.
90 90 .sp
91 91 .ne 2
92 92 .na
93 93 \fB\fBMEMINFO_VPHYSICAL\fR\fR
94 94 .ad
95 95 .RS 26n
96 96 physical address corresponding to virtual address
97 97 .RE
98 98
99 99 .sp
100 100 .ne 2
101 101 .na
102 102 \fB\fBMEMINFO_VLGRP\fR\fR
103 103 .ad
104 104 .RS 26n
105 105 locality group of physical page corresponding to virtual address
106 106 .RE
107 107
108 108 .sp
109 109 .ne 2
110 110 .na
111 111 \fB\fBMEMINFO_VPAGESIZE\fR\fR
112 112 .ad
113 113 .RS 26n
114 114 size of physical page corresponding to virtual address
115 115 .RE
116 116
117 117 .sp
118 118 .ne 2
119 119 .na
120 120 \fB\fBMEMINFO_VREPLCNT\fR\fR
121 121 .ad
122 122 .RS 26n
123 123 number of replicated physical pages corresponding to specified virtual address
124 124 .RE
125 125
126 126 .sp
127 127 .ne 2
128 128 .na
129 129 \fB\fBMEMINFO_VREPL\fR | \fIn\fR\fR
130 130 .ad
131 131 .RS 26n
132 132 \fIn\fRth physical replica of specified virtual address
133 133 .RE
134 134
135 135 .sp
136 136 .ne 2
137 137 .na
138 138 \fB\fBMEMINFO_VREPL_LGRP\fR | \fIn\fR\fR
139 139 .ad
140 140 .RS 26n
141 141 lgrp of \fIn\fRth physical replica of specified virtual address
142 142 .RE
143 143
144 144 .sp
145 145 .ne 2
146 146 .na
147 147 \fB\fBMEMINFO_PLGRP\fR\fR
148 148 .ad
|
↓ open down ↓ |
148 lines elided |
↑ open up ↑ |
149 149 .RS 26n
150 150 locality group of specified physical address
151 151 .RE
152 152
153 153 .sp
154 154 .LP
155 155 All but \fBMEMINFO_VLGRP\fR and \fBMEMINFO_VPAGESIZE\fR require the
156 156 \fBPRIV_PROC_MEMINFO\fR privilege.
157 157
158 158 .SH RETURN VALUES
159 +.sp
159 160 .LP
161 +All but \fBMEMINFO_VLGRP\fR and \fBMEMINFO_VPAGESIZE\fR require the
162 +\fBPRIV_PROC_MEMINFO\fR privilege.
163 +
164 +.SH RETURN VALUES
165 +.LP
160 166 Upon successful completion \fBmeminfo()\fR returns 0. Otherwise \(mi1 is
161 167 returned and \fBerrno\fR is set to indicate the error.
162 168 .SH ERRORS
163 169 .LP
164 170 The \fBmeminfo()\fR function will fail if:
165 171 .sp
166 172 .ne 2
167 173 .na
168 174 \fB\fBEFAULT\fR\fR
169 175 .ad
170 176 .RS 10n
171 177 The area pointed to by \fIoutdata\fR or \fIvalidity\fR could not be written, or
172 178 the data pointed to by \fIinfo_req\fR or \fIinaddr\fR could not be read.
173 179 .RE
174 180
175 181 .sp
176 182 .ne 2
177 183 .na
178 184 \fB\fBEINVAL\fR\fR
179 185 .ad
180 186 .RS 10n
181 187 The value of \fIinfo_count\fR is greater than 31 or less than 1, or the value
182 188 of \fIaddr_count\fR is less than 1.
183 189 .RE
184 190
185 191 .SH EXAMPLES
186 192 .LP
187 193 \fBExample 1 \fRPrint physical pages and page sizes corresponding to a set of
188 194 virtual addresses.
189 195 .sp
190 196 .LP
191 197 The following example prints the physical pages and page sizes corresponding to
192 198 a set of virtual addresses.
193 199
194 200 .sp
195 201 .in +2
196 202 .nf
197 203 void
198 204 print_info(void **addrvec, int how_many)
199 205 {
200 206 static const uint_t info[] = {
201 207 MEMINFO_VPHYSICAL,
202 208 MEMINFO_VPAGESIZE
203 209 };
204 210
205 211 int info_num = sizeof (info) / sizeof (info[0]);
206 212 int i;
207 213
208 214 uint64_t *inaddr = alloca(sizeof (uint64_t) * how_many);
209 215 uint64_t *outdata = alloca(sizeof (uint64_t) * how_many * info_num);
210 216 uint_t *validity = alloca(sizeof (uint_t) * how_many);
211 217
212 218 for (i = 0; i < how_many; i++)
213 219 inaddr[i] = (uint64_t)addrvec[i];
214 220
215 221 if (meminfo(inaddr, how_many, info, info_num, outdata,
216 222 validity) < 0) {
217 223 perror("meminfo");
218 224 return;
219 225 }
220 226
221 227 for (i = 0; i < how_many; i++) {
222 228 if ((validity[i] & 1) == 0)
223 229 printf("address 0x%llx not part of address space\en",
224 230 inaddr[i]);
225 231
226 232 else if ((validity[i] & 2) == 0)
227 233 printf("address 0x%llx has no physical page "
228 234 "associated with it\en", inaddr[i]);
229 235
230 236 else {
231 237 char buff[80];
232 238 if ((validity[i] & 4) == 0)
233 239 strcpy(buff, "<Unknown>");
234 240 else
235 241 sprintf(buff, "%lld",
236 242 outdata[i * info_num + 1]);
237 243
238 244 printf("address 0x%llx is backed by physical "
239 245 "page 0x%llx of size %s\en",
240 246 inaddr[i], outdata[i * info_num], buff);
241 247 }
242 248 }
243 249 }
244 250 .fi
245 251 .in -2
246 252
247 253 .SH ATTRIBUTES
248 254 .LP
249 255 See \fBattributes\fR(5) for descriptions of the following attributes:
250 256 .sp
251 257
252 258 .sp
253 259 .TS
254 260 box;
255 261 c | c
256 262 l | l .
257 263 ATTRIBUTE TYPE ATTRIBUTE VALUE
258 264 _
259 265 Interface Stability Stable
260 266 _
261 267 MT-Level Async-Signal-Safe
262 268 .TE
263 269
264 270 .SH SEE ALSO
265 271 .LP
266 272 \fBmemcntl\fR(2), \fBmmap\fR(2), \fBgethomelgroup\fR(3C),
267 273 \fBgetpagesize\fR(3C), \fBmadvise\fR(3C), \fBsysconf\fR(3C),
268 274 \fBattributes\fR(5), \fBprivileges\fR(5)
|
↓ open down ↓ |
99 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX