1meminfo(2)                       System Calls                       meminfo(2)
2
3
4

NAME

6       meminfo - provide information about memory
7

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

PARAMETERS

18       inaddr        array of input addresses; the maximum number of addresses
19                     that can be processed for each call is MAX_MEMINFO_CNT
20
21
22       addr_count    number of addresses
23
24
25       info_req      array of types of information requested
26
27
28       info_count    number  of  pieces  of  information  requested  for  each
29                     address in inaddr
30
31
32       outdata       array  into  which results are placed; array size must be
33                     the product of info_count and addr_count
34
35
36       validity      array of size addr_count containing bitwise result codes;
37                     0th   bit   evaluates  validity  of  corresponding  input
38                     address, 1st bit validity of response to first member  of
39                     info_req, and so on
40
41

DESCRIPTION

43       The  meminfo() function provides information about virtual and physical
44       memory particular to the calling process.  The  user  or  developer  of
45       performance utilities can use this information to analyze system memory
46       allocations and develop a better understanding of the factors affecting
47       application performance.
48
49
50       The  caller  of meminfo() can obtain the following types of information
51       about both virtual and physical memory.
52
53       MEMINFO_VPHYSICAL         physical  address  corresponding  to  virtual
54                                 address
55
56
57       MEMINFO_VLGRP             locality group of physical page corresponding
58                                 to virtual address
59
60
61       MEMINFO_VPAGESIZE         size of physical page corresponding  to  vir‐
62                                 tual address
63
64
65       MEMINFO_VREPLCNT          number  of  replicated  physical pages corre‐
66                                 sponding to specified virtual address
67
68
69       MEMINFO_VREPL | n         nth physical  replica  of  specified  virtual
70                                 address
71
72
73       MEMINFO_VREPL_LGRP | n    lgrp  of  nth  physical  replica of specified
74                                 virtual address
75
76
77       MEMINFO_PLGRP             locality group of specified physical address
78
79

RETURN VALUES

81       Upon  successful  completion  meminfo()  returns  0.  Otherwise  −1  is
82       returned and errno is set to indicate the error.
83

ERRORS

85       The meminfo() function will fail if:
86
87       EFAULT    The area pointed to by outdata or validity could not be writ‐
88                 ten, or the data pointed to by info_req or inaddr  could  not
89                 be read.
90
91
92       EINVAL    The value of info_count is greater than 31 or less than 1, or
93                 the value of addr_count is less than 1.
94
95

EXAMPLES

97       Example 1 Print physical pages and page sizes corresponding to a set of
98       virtual addresses.
99
100
101       The  following  example prints the physical pages and page sizes corre‐
102       sponding to a set of virtual addresses.
103
104
105         void
106         print_info(void **addrvec, int how_many)
107         {
108             static const uint_t info[] = {
109                 MEMINFO_VPHYSICAL,
110                 MEMINFO_VPAGESIZE
111             };
112
113             int info_num = sizeof (info) / sizeof (info[0]);
114             int i;
115
116             uint64_t *inaddr = alloca(sizeof (uint64_t) * how_many);
117             uint64_t *outdata = alloca(sizeof (uint64_t) * how_many * info_num);
118             uint_t *validity = alloca(sizeof (uint_t) * how_many);
119
120             for (i = 0; i < how_many; i++)
121                 inaddr[i] = (uint64_t)addrvec[i];
122
123             if (meminfo(inaddr, how_many, info, info_num, outdata,
124                         validity) < 0) {
125                 perror("meminfo");
126                 return;
127             }
128
129             for (i = 0; i < how_many; i++) {
130                 if ((validity[i] & 1) == 0)
131                     printf("address 0x%llx not part of address space\n",
132                         inaddr[i]);
133
134                 else if ((validity[i] & 2) == 0)
135                     printf("address 0x%llx has no physical page "
136                         "associated with it\n", inaddr[i]);
137
138                 else {
139                     char buff[80];
140                     if ((validity[i] & 4) == 0)
141                         strcpy(buff, "<Unknown>");
142                     else
143                         sprintf(buff, "%lld",
144                             outdata[i * info_num + 1]);
145
146                     printf("address 0x%llx is backed by physical "
147                         "page 0x%llx of size %s\n",
148                         inaddr[i], outdata[i * info_num], buff);
149                 }
150             }
151         }
152
153

ATTRIBUTES

155       See attributes(5) for descriptions of the following attributes:
156
157
158
159
160       ┌─────────────────────────────┬─────────────────────────────┐
161       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
162       ├─────────────────────────────┼─────────────────────────────┤
163       │Interface Stability          │Stable                       │
164       ├─────────────────────────────┼─────────────────────────────┤
165       │MT-Level                     │Async-Signal-Safe            │
166       └─────────────────────────────┴─────────────────────────────┘
167

SEE ALSO

169       memcntl(2), mmap(2), gethomelgroup(3C),  getpagesize(3C),  madvise(3C),
170       sysconf(3C), attributes(5)
171
172
173
174SunOS 5.11                        21 Feb 2003                       meminfo(2)
Impressum