'\" te .\" Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. .TH meminfo 2 "3 Nov 2015" "SunOS 5.11" "System Calls" .SH NAME meminfo \- provide information about memory .SH SYNOPSIS .LP .nf #include #include \fBint\fR \fBmeminfo\fR(\fBconst uint64_t\fR \fIinaddr\fR[], \fBint\fR \fIaddr_count\fR, \fBconst uint_t\fR \fIinfo_req\fR[], \fBint\fR \fIinfo_count\fR, \fBuint64_t\fR \fIoutdata\fR[], \fBuint_t\fR \fIvalidity\fR[]); .fi .SH PARAMETERS .sp .ne 2 .mk .na \fB\fIinaddr\fR\fR .ad .RS 14n .rt array of addresses to be examined; the maximum number of addresses that can be processed for each call is \fBMAX_MEMINFO_CNT\fR .RE .sp .ne 2 .mk .na \fB\fIaddr_count\fR\fR .ad .RS 14n .rt number of addresses to be examined. Request sizes exceeding \fBMAX_MEMINFO_CNT\fR are not examined atomically and thus may not be self-consistent. .RE .sp .ne 2 .mk .na \fB\fIinfo_req\fR\fR .ad .RS 14n .rt array of types of information requested .RE .sp .ne 2 .mk .na \fB\fIinfo_count\fR\fR .ad .RS 14n .rt number of pieces of information requested for each address in \fIinaddr\fR .RE .sp .ne 2 .mk .na \fB\fIoutdata\fR\fR .ad .RS 14n .rt array into which results are placed; array size must be the product of \fIinfo_count\fR and \fIaddr_count\fR .RE .sp .ne 2 .mk .na \fB\fIvalidity\fR\fR .ad .RS 14n .rt array of size \fIaddr_count\fR containing bitwise result codes; 0th bit evaluates validity of corresponding input address, 1st bit validity of response to first member of \fIinfo_req\fR, and so on .RE .SH DESCRIPTION .sp .LP The \fBmeminfo()\fR function provides information about virtual and physical memory particular to the calling process. The user or developer of performance utilities can use this information to analyze system memory allocations and develop a better understanding of the factors affecting application performance. .sp .LP The caller of \fBmeminfo()\fR can obtain the following types of information about both virtual and physical memory. .sp .ne 2 .mk .na \fB\fBMEMINFO_VPHYSICAL\fR\fR .ad .RS 26n .rt physical address corresponding to virtual address (requires PRIV_ALL) .RE .sp .ne 2 .mk .na \fB\fBMEMINFO_VLGRP\fR\fR .ad .RS 26n .rt locality group of physical page corresponding to virtual address .RE .sp .ne 2 .mk .na \fB\fBMEMINFO_VPAGESIZE\fR\fR .ad .RS 26n .rt size of physical page corresponding to virtual address .RE .sp .ne 2 .mk .na \fB\fBMEMINFO_VREPLCNT\fR\fR .ad .RS 26n .rt number of replicated physical pages corresponding to specified virtual address .RE .sp .ne 2 .mk .na \fB\fBMEMINFO_VREPL\fR | \fIn\fR\fR .ad .RS 26n .rt \fIn\fRth physical replica of specified virtual address .RE .sp .ne 2 .mk .na \fB\fBMEMINFO_VREPL_LGRP\fR | \fIn\fR\fR .ad .RS 26n .rt lgrp of \fIn\fRth physical replica of specified virtual address .RE .sp .ne 2 .mk .na \fB\fBMEMINFO_PLGRP\fR\fR .ad .RS 26n .rt locality group of specified physical address .RE .sp .ne 2 .mk .na \fB\fBMEMINFO_VADI\fR\fR .ad .RS 26n .rt ADI status for the specified virtual address. 0=ADI disabled, 1=ADI enabled. .RE .sp .LP For all types of information except \fBMEMINFO_VADI\fR, any addresses in the \fBinaddr\fR array that have never been referenced will not have any information about them returned by \fBmeminfo()\fR. This can also occur if an address has not been referenced recently and the physical page that had been backing that address has been paged out. Information for \fBMEMINFO_VADI\fR is always returned. .SH RETURN VALUES .sp .LP Upon successful completion \fBmeminfo()\fR returns 0. Otherwise \(mi1 is returned and \fBerrno\fR is set to indicate the error. .SH ERRORS .sp .LP The \fBmeminfo()\fR function will fail if: .sp .ne 2 .mk .na \fB\fBEFAULT\fR\fR .ad .RS 11n .rt The area pointed to by \fIoutdata\fR or \fIvalidity\fR could not be written, or the data pointed to by \fIinfo_req\fR or \fIinaddr\fR could not be read. .RE .sp .ne 2 .mk .na \fB\fBEINVAL\fR\fR .ad .RS 11n .rt The value of \fIinfo_count\fR is greater than 31 or less than 1, or the value of \fIaddr_count\fR is less than 1. .RE .sp .ne 2 .mk .na \fB\fBENOTSUP\fR\fR .ad .RS 11n .rt \fBMEMINFO_VADI\fR is specified, and ADI is not supported by the platform. .sp \fBMEMINFO_VADI\fR is specified, and the caller is a 32-bit process. .RE .SH EXAMPLES .LP \fBExample 1 \fRPrint physical pages and page sizes corresponding to a set of virtual addresses. .sp .LP The following example prints the physical pages and page sizes corresponding to a set of virtual addresses. .sp .in +2 .nf void print_info(void **addrvec, int how_many) { static const uint_t info[] = { MEMINFO_VPHYSICAL, MEMINFO_VPAGESIZE }; int info_num = sizeof (info) / sizeof (info[0]); int i; uint64_t *inaddr = alloca(sizeof (uint64_t) * how_many); uint64_t *outdata = alloca(sizeof (uint64_t) * how_many * info_num); uint_t *validity = alloca(sizeof (uint_t) * how_many); for (i = 0; i < how_many; i++) inaddr[i] = (uint64_t)addrvec[i]; if (meminfo(inaddr, how_many, info, info_num, outdata, validity) < 0) { perror("meminfo"); return; } for (i = 0; i < how_many; i++) { if ((validity[i] & 1) == 0) printf("address 0x%llx not part of address space\en", inaddr[i]); else if ((validity[i] & 2) == 0) printf("address 0x%llx has no physical page " "associated with it\en", inaddr[i]); else { char buff[80]; if ((validity[i] & 4) == 0) strcpy(buff, ""); else sprintf(buff, "%lld", outdata[i * info_num + 1]); printf("address 0x%llx is backed by physical " "page 0x%llx of size %s\en", inaddr[i], outdata[i * info_num], buff); } } } .fi .in -2 .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelAsync-Signal-Safe .TE .SH SEE ALSO .sp .LP \fBmemcntl\fR(2), \fBmmap\fR(2), \fBgethomelgroup\fR(3C), \fBgetpagesize\fR(3C), \fBmadvise\fR(3C), \fBsysconf\fR(3C), \fBattributes\fR(5)