2 .\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 2015, Joyent, Inc.
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 .\" 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 .\" 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 .TH MEMINFO 2 "Mar 10, 2015"
9 meminfo \- provide information about memory
13 #include <sys/types.h>
16 \fBint\fR \fBmeminfo\fR(\fBconst uint64_t\fR \fIinaddr\fR[], \fBint\fR \fIaddr_count\fR,
17 \fBconst uint_t\fR \fIinfo_req\fR[], \fBint\fR \fIinfo_count\fR, \fBuint64_t\fR \fIoutdata\fR[],
18 \fBuint_t\fR \fIvalidity\fR[]);
27 array of input addresses; the maximum number of addresses that can be processed
28 for each call is \fBMAX_MEMINFO_CNT\fR
34 \fB\fIaddr_count\fR\fR
46 array of types of information requested
52 \fB\fIinfo_count\fR\fR
55 number of pieces of information requested for each address in \fIinaddr\fR
64 array into which results are placed; array size must be the product of
65 \fIinfo_count\fR and \fIaddr_count\fR
74 array of size \fIaddr_count\fR containing bitwise result codes; 0th bit
75 evaluates validity of corresponding input address, 1st bit validity of response
76 to first member of \fIinfo_req\fR, and so on
81 The \fBmeminfo()\fR function provides information about virtual and physical
82 memory particular to the calling process. The user or developer of performance
83 utilities can use this information to analyze system memory allocations and
84 develop a better understanding of the factors affecting application
88 The caller of \fBmeminfo()\fR can obtain the following types of information
89 about both virtual and physical memory.
93 \fB\fBMEMINFO_VPHYSICAL\fR\fR
96 physical address corresponding to virtual address
102 \fB\fBMEMINFO_VLGRP\fR\fR
105 locality group of physical page corresponding to virtual address
111 \fB\fBMEMINFO_VPAGESIZE\fR\fR
114 size of physical page corresponding to virtual address
120 \fB\fBMEMINFO_VREPLCNT\fR\fR
123 number of replicated physical pages corresponding to specified virtual address
129 \fB\fBMEMINFO_VREPL\fR | \fIn\fR\fR
132 \fIn\fRth physical replica of specified virtual address
138 \fB\fBMEMINFO_VREPL_LGRP\fR | \fIn\fR\fR
141 lgrp of \fIn\fRth physical replica of specified virtual address
147 \fB\fBMEMINFO_PLGRP\fR\fR
150 locality group of specified physical address
155 All but \fBMEMINFO_VLGRP\fR and \fBMEMINFO_VPAGESIZE\fR require the
156 \fBPRIV_PROC_MEMINFO\fR privilege.
160 Upon successful completion \fBmeminfo()\fR returns 0. Otherwise \(mi1 is
161 returned and \fBerrno\fR is set to indicate the error.
164 The \fBmeminfo()\fR function will fail if:
171 The area pointed to by \fIoutdata\fR or \fIvalidity\fR could not be written, or
172 the data pointed to by \fIinfo_req\fR or \fIinaddr\fR could not be read.
181 The value of \fIinfo_count\fR is greater than 31 or less than 1, or the value
182 of \fIaddr_count\fR is less than 1.
187 \fBExample 1 \fRPrint physical pages and page sizes corresponding to a set of
191 The following example prints the physical pages and page sizes corresponding to
192 a set of virtual addresses.
198 print_info(void **addrvec, int how_many)
200 static const uint_t info[] = {
205 int info_num = sizeof (info) / sizeof (info[0]);
208 uint64_t *inaddr = alloca(sizeof (uint64_t) * how_many);
209 uint64_t *outdata = alloca(sizeof (uint64_t) * how_many * info_num);
210 uint_t *validity = alloca(sizeof (uint_t) * how_many);
212 for (i = 0; i < how_many; i++)
213 inaddr[i] = (uint64_t)addrvec[i];
215 if (meminfo(inaddr, how_many, info, info_num, outdata,
221 for (i = 0; i < how_many; i++) {
222 if ((validity[i] & 1) == 0)
223 printf("address 0x%llx not part of address space\en",
226 else if ((validity[i] & 2) == 0)
227 printf("address 0x%llx has no physical page "
228 "associated with it\en", inaddr[i]);
232 if ((validity[i] & 4) == 0)
233 strcpy(buff, "<Unknown>");
235 sprintf(buff, "%lld",
236 outdata[i * info_num + 1]);
238 printf("address 0x%llx is backed by physical "
239 "page 0x%llx of size %s\en",
240 inaddr[i], outdata[i * info_num], buff);
249 See \fBattributes\fR(5) for descriptions of the following attributes:
257 ATTRIBUTE TYPE ATTRIBUTE VALUE
259 Interface Stability Stable
261 MT-Level Async-Signal-Safe
266 \fBmemcntl\fR(2), \fBmmap\fR(2), \fBgethomelgroup\fR(3C),
267 \fBgetpagesize\fR(3C), \fBmadvise\fR(3C), \fBsysconf\fR(3C),
268 \fBattributes\fR(5), \fBprivileges\fR(5)