]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
b0d623f7 | 2 | * Copyright (c) 2000-2009 Apple Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
8f6c56a5 | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
1c79356b A |
31 | /* |
32 | * Mach Operating System | |
33 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University | |
34 | * All Rights Reserved. | |
35 | * | |
36 | * Permission to use, copy, modify and distribute this software and its | |
37 | * documentation is hereby granted, provided that both the copyright | |
38 | * notice and this permission notice appear in all copies of the | |
39 | * software, derivative works or modified versions, and any portions | |
40 | * thereof, and that both notices appear in supporting documentation. | |
41 | * | |
42 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
43 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
44 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
45 | * | |
46 | * Carnegie Mellon requests users of this software to return to | |
47 | * | |
48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
49 | * School of Computer Science | |
50 | * Carnegie Mellon University | |
51 | * Pittsburgh PA 15213-3890 | |
52 | * | |
53 | * any improvements or extensions that they make and grant Carnegie Mellon | |
54 | * the rights to redistribute these changes. | |
55 | */ | |
56 | /* | |
57 | */ | |
58 | /* | |
59 | * File: mach/vm_statistics.h | |
60 | * Author: Avadis Tevanian, Jr., Michael Wayne Young, David Golub | |
61 | * | |
62 | * Virtual memory statistics structure. | |
63 | * | |
64 | */ | |
65 | ||
91447636 A |
66 | #ifndef _MACH_VM_STATISTICS_H_ |
67 | #define _MACH_VM_STATISTICS_H_ | |
1c79356b A |
68 | |
69 | #include <mach/machine/vm_types.h> | |
70 | ||
b0d623f7 A |
71 | |
72 | /* | |
73 | * vm_statistics | |
74 | * | |
75 | * History: | |
76 | * rev0 - original structure. | |
77 | * rev1 - added purgable info (purgable_count and purges). | |
78 | * rev2 - added speculative_count. | |
79 | * | |
80 | * Note: you cannot add any new fields to this structure. Add them below in | |
81 | * vm_statistics64. | |
82 | */ | |
83 | ||
1c79356b | 84 | struct vm_statistics { |
91447636 A |
85 | natural_t free_count; /* # of pages free */ |
86 | natural_t active_count; /* # of pages active */ | |
87 | natural_t inactive_count; /* # of pages inactive */ | |
88 | natural_t wire_count; /* # of pages wired down */ | |
89 | natural_t zero_fill_count; /* # of zero fill pages */ | |
90 | natural_t reactivations; /* # of pages reactivated */ | |
91 | natural_t pageins; /* # of pageins */ | |
92 | natural_t pageouts; /* # of pageouts */ | |
93 | natural_t faults; /* # of faults */ | |
94 | natural_t cow_faults; /* # of copy-on-writes */ | |
95 | natural_t lookups; /* object cache lookups */ | |
96 | natural_t hits; /* object cache hits */ | |
97 | ||
2d21ac55 | 98 | /* added for rev1 */ |
91447636 A |
99 | natural_t purgeable_count; /* # of pages purgeable */ |
100 | natural_t purges; /* # of pages purged */ | |
2d21ac55 A |
101 | |
102 | /* added for rev2 */ | |
103 | /* | |
104 | * NB: speculative pages are already accounted for in "free_count", | |
105 | * so "speculative_count" is the number of "free" pages that are | |
106 | * used to hold data that was read speculatively from disk but | |
107 | * haven't actually been used by anyone so far. | |
108 | */ | |
109 | natural_t speculative_count; /* # of pages speculative */ | |
1c79356b A |
110 | }; |
111 | ||
b0d623f7 | 112 | /* Used by all architectures */ |
1c79356b A |
113 | typedef struct vm_statistics *vm_statistics_t; |
114 | typedef struct vm_statistics vm_statistics_data_t; | |
115 | ||
b0d623f7 A |
116 | #if defined(__ppc__) /* On ppc, vm statistics are still 32-bit */ |
117 | ||
118 | typedef struct vm_statistics *vm_statistics64_t; | |
119 | typedef struct vm_statistics vm_statistics64_data_t; | |
120 | ||
121 | #define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) value | |
122 | ||
123 | #else /* !(defined(__ppc__)) */ | |
124 | ||
125 | /* | |
126 | * vm_statistics64 | |
127 | * | |
128 | * History: | |
129 | * rev0 - original structure. | |
130 | * rev1 - added purgable info (purgable_count and purges). | |
131 | * rev2 - added speculative_count. | |
132 | * ---- | |
133 | * rev3 - changed name to vm_statistics64. | |
134 | * changed some fields in structure to 64-bit on | |
135 | * arm, i386 and x86_64 architectures. | |
136 | * | |
137 | */ | |
138 | ||
139 | struct vm_statistics64 { | |
140 | natural_t free_count; /* # of pages free */ | |
141 | natural_t active_count; /* # of pages active */ | |
142 | natural_t inactive_count; /* # of pages inactive */ | |
143 | natural_t wire_count; /* # of pages wired down */ | |
144 | uint64_t zero_fill_count; /* # of zero fill pages */ | |
145 | uint64_t reactivations; /* # of pages reactivated */ | |
146 | uint64_t pageins; /* # of pageins */ | |
147 | uint64_t pageouts; /* # of pageouts */ | |
148 | uint64_t faults; /* # of faults */ | |
149 | uint64_t cow_faults; /* # of copy-on-writes */ | |
150 | uint64_t lookups; /* object cache lookups */ | |
151 | uint64_t hits; /* object cache hits */ | |
152 | ||
153 | /* added for rev1 */ | |
154 | uint64_t purges; /* # of pages purged */ | |
155 | natural_t purgeable_count; /* # of pages purgeable */ | |
156 | ||
157 | /* added for rev2 */ | |
158 | /* | |
159 | * NB: speculative pages are already accounted for in "free_count", | |
160 | * so "speculative_count" is the number of "free" pages that are | |
161 | * used to hold data that was read speculatively from disk but | |
162 | * haven't actually been used by anyone so far. | |
163 | */ | |
164 | natural_t speculative_count; /* # of pages speculative */ | |
165 | ||
166 | } | |
167 | ; | |
168 | ||
169 | typedef struct vm_statistics64 *vm_statistics64_t; | |
170 | typedef struct vm_statistics64 vm_statistics64_data_t; | |
171 | ||
172 | /* | |
173 | * VM_STATISTICS_TRUNCATE_TO_32_BIT | |
174 | * | |
175 | * This is used by host_statistics() to truncate and peg the 64-bit in-kernel values from | |
176 | * vm_statistics64 to the 32-bit values of the older structure above (vm_statistics). | |
177 | */ | |
178 | #define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) ((uint32_t)(((value) > UINT32_MAX ) ? UINT32_MAX : (value))) | |
179 | ||
180 | #endif /* !(defined(__ppc__)) */ | |
181 | ||
1c79356b A |
182 | |
183 | /* included for the vm_map_page_query call */ | |
184 | ||
185 | #define VM_PAGE_QUERY_PAGE_PRESENT 0x1 | |
186 | #define VM_PAGE_QUERY_PAGE_FICTITIOUS 0x2 | |
187 | #define VM_PAGE_QUERY_PAGE_REF 0x4 | |
188 | #define VM_PAGE_QUERY_PAGE_DIRTY 0x8 | |
2d21ac55 A |
189 | #define VM_PAGE_QUERY_PAGE_PAGED_OUT 0x10 |
190 | #define VM_PAGE_QUERY_PAGE_COPIED 0x20 | |
191 | #define VM_PAGE_QUERY_PAGE_SPECULATIVE 0x40 | |
b0d623f7 | 192 | #define VM_PAGE_QUERY_PAGE_EXTERNAL 0x80 |
593a1d5f A |
193 | #define VM_PAGE_QUERY_PAGE_CS_VALIDATED 0x100 |
194 | #define VM_PAGE_QUERY_PAGE_CS_TAINTED 0x200 | |
1c79356b | 195 | |
91447636 | 196 | #ifdef MACH_KERNEL_PRIVATE |
1c79356b A |
197 | |
198 | /* | |
199 | * Each machine dependent implementation is expected to | |
200 | * keep certain statistics. They may do this anyway they | |
201 | * so choose, but are expected to return the statistics | |
202 | * in the following structure. | |
203 | */ | |
204 | ||
205 | struct pmap_statistics { | |
206 | integer_t resident_count; /* # of pages mapped (total)*/ | |
2d21ac55 | 207 | integer_t resident_max; /* # of pages mapped (peak) */ |
1c79356b A |
208 | integer_t wired_count; /* # of pages wired */ |
209 | }; | |
210 | ||
211 | typedef struct pmap_statistics *pmap_statistics_t; | |
212 | ||
91447636 A |
213 | #endif /* MACH_KERNEL_PRIVATE */ |
214 | ||
215 | /* | |
216 | * VM allocation flags: | |
217 | * | |
218 | * VM_FLAGS_FIXED | |
219 | * (really the absence of VM_FLAGS_ANYWHERE) | |
220 | * Allocate new VM region at the specified virtual address, if possible. | |
221 | * | |
222 | * VM_FLAGS_ANYWHERE | |
223 | * Allocate new VM region anywhere it would fit in the address space. | |
224 | * | |
225 | * VM_FLAGS_PURGABLE | |
226 | * Create a purgable VM object for that new VM region. | |
227 | * | |
228 | * VM_FLAGS_NO_PMAP_CHECK | |
229 | * (for DEBUG kernel config only, ignored for other configs) | |
230 | * Do not check that there is no stale pmap mapping for the new VM region. | |
231 | * This is useful for kernel memory allocations at bootstrap when building | |
232 | * the initial kernel address space while some memory is already in use. | |
233 | * | |
234 | * VM_FLAGS_OVERWRITE | |
235 | * The new VM region can replace existing VM regions if necessary | |
236 | * (to be used in combination with VM_FLAGS_FIXED). | |
2d21ac55 A |
237 | * |
238 | * VM_FLAGS_NO_CACHE | |
239 | * Pages brought in to this VM region are placed on the speculative | |
240 | * queue instead of the active queue. In other words, they are not | |
241 | * cached so that they will be stolen first if memory runs low. | |
91447636 A |
242 | */ |
243 | #define VM_FLAGS_FIXED 0x0000 | |
244 | #define VM_FLAGS_ANYWHERE 0x0001 | |
245 | #define VM_FLAGS_PURGABLE 0x0002 | |
2d21ac55 | 246 | #define VM_FLAGS_NO_CACHE 0x0010 |
91447636 | 247 | #ifdef KERNEL_PRIVATE |
b0d623f7 A |
248 | #define VM_FLAGS_BELOW_MIN 0x0080 /* map below the map's min offset */ |
249 | #define VM_FLAGS_PERMANENT 0x0100 /* mapping can NEVER be unmapped */ | |
250 | #define VM_FLAGS_GUARD_AFTER 0x0200 /* guard page after the mapping */ | |
251 | #define VM_FLAGS_GUARD_BEFORE 0x0400 /* guard page before the mapping */ | |
2d21ac55 | 252 | #define VM_FLAGS_SUBMAP 0x0800 /* mapping a VM submap */ |
b0d623f7 A |
253 | #define VM_FLAGS_ALREADY 0x1000 /* OK if same mapping already exists */ |
254 | #define VM_FLAGS_BEYOND_MAX 0x2000 /* map beyond the map's max offset */ | |
255 | #define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */ | |
256 | #define VM_FLAGS_NO_PMAP_CHECK 0x8000 /* do not check that pmap is empty */ | |
91447636 | 257 | #endif /* KERNEL_PRIVATE */ |
b0d623f7 A |
258 | |
259 | /* | |
260 | * VM_FLAGS_SUPERPAGE_MASK | |
261 | * 3 bits that specify whether large pages should be used instead of | |
262 | * base pages (!=0), as well as the requested page size. | |
263 | */ | |
264 | #define VM_FLAGS_SUPERPAGE_MASK 0x70000 /* bits 0x10000, 0x20000, 0x40000 */ | |
265 | #define VM_FLAGS_SUPERPAGE_SHIFT 16 | |
266 | ||
267 | #define SUPERPAGE_NONE 0 /* no superpages, if all bits are 0 */ | |
268 | #define VM_FLAGS_SUPERPAGE_NONE (SUPERPAGE_NONE<<VM_FLAGS_SUPERPAGE_SHIFT) | |
269 | #if defined(__x86_64__) || !defined(KERNEL) | |
270 | #define SUPERPAGE_SIZE_2MB 1 | |
271 | #define VM_FLAGS_SUPERPAGE_SIZE_2MB (SUPERPAGE_SIZE_2MB<<VM_FLAGS_SUPERPAGE_SHIFT) | |
272 | #endif | |
91447636 | 273 | |
1c79356b A |
274 | #define VM_FLAGS_ALIAS_MASK 0xFF000000 |
275 | #define VM_GET_FLAGS_ALIAS(flags, alias) \ | |
276 | (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24 | |
277 | #define VM_SET_FLAGS_ALIAS(flags, alias) \ | |
278 | (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) | \ | |
279 | (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24)) | |
280 | ||
2d21ac55 A |
281 | /* These are the flags that we accept from user-space */ |
282 | #define VM_FLAGS_USER_ALLOCATE (VM_FLAGS_FIXED | \ | |
283 | VM_FLAGS_ANYWHERE | \ | |
284 | VM_FLAGS_PURGABLE | \ | |
285 | VM_FLAGS_NO_CACHE | \ | |
b0d623f7 | 286 | VM_FLAGS_SUPERPAGE_MASK | \ |
2d21ac55 A |
287 | VM_FLAGS_ALIAS_MASK) |
288 | #define VM_FLAGS_USER_MAP VM_FLAGS_USER_ALLOCATE | |
289 | ||
1c79356b A |
290 | #define VM_MEMORY_MALLOC 1 |
291 | #define VM_MEMORY_MALLOC_SMALL 2 | |
292 | #define VM_MEMORY_MALLOC_LARGE 3 | |
293 | #define VM_MEMORY_MALLOC_HUGE 4 | |
294 | #define VM_MEMORY_SBRK 5// uninteresting -- no one should call | |
55e303ae A |
295 | #define VM_MEMORY_REALLOC 6 |
296 | #define VM_MEMORY_MALLOC_TINY 7 | |
b0d623f7 A |
297 | #define VM_MEMORY_MALLOC_LARGE_REUSABLE 8 |
298 | #define VM_MEMORY_MALLOC_LARGE_REUSED 9 | |
1c79356b A |
299 | |
300 | #define VM_MEMORY_ANALYSIS_TOOL 10 | |
301 | ||
302 | #define VM_MEMORY_MACH_MSG 20 | |
303 | #define VM_MEMORY_IOKIT 21 | |
304 | #define VM_MEMORY_STACK 30 | |
305 | #define VM_MEMORY_GUARD 31 | |
306 | #define VM_MEMORY_SHARED_PMAP 32 | |
307 | /* memory containing a dylib */ | |
308 | #define VM_MEMORY_DYLIB 33 | |
b0d623f7 | 309 | #define VM_MEMORY_OBJC_DISPATCHERS 34 |
1c79356b A |
310 | |
311 | // Placeholders for now -- as we analyze the libraries and find how they | |
312 | // use memory, we can make these labels more specific. | |
313 | #define VM_MEMORY_APPKIT 40 | |
314 | #define VM_MEMORY_FOUNDATION 41 | |
315 | #define VM_MEMORY_COREGRAPHICS 42 | |
316 | #define VM_MEMORY_CARBON 43 | |
9bccf70c | 317 | #define VM_MEMORY_JAVA 44 |
1c79356b | 318 | #define VM_MEMORY_ATS 50 |
2d21ac55 A |
319 | #define VM_MEMORY_LAYERKIT 51 |
320 | #define VM_MEMORY_CGIMAGE 52 | |
321 | #define VM_MEMORY_TCMALLOC 53 | |
322 | ||
323 | /* private raster data (i.e. layers, some images, QGL allocator) */ | |
324 | #define VM_MEMORY_COREGRAPHICS_DATA 54 | |
325 | ||
326 | /* shared image and font caches */ | |
327 | #define VM_MEMORY_COREGRAPHICS_SHARED 55 | |
328 | ||
329 | /* Memory used for virtual framebuffers, shadowing buffers, etc... */ | |
330 | #define VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS 56 | |
331 | ||
332 | /* Window backing stores, custom shadow data, and compressed backing stores */ | |
333 | #define VM_MEMORY_COREGRAPHICS_BACKINGSTORES 57 | |
334 | ||
335 | /* catch-all for other uses, such as the read-only shared data page */ | |
336 | #define VM_MEMORY_COREGRAPHICS_MISC VM_MEMORY_COREGRAPHICS | |
1c79356b | 337 | |
1c79356b A |
338 | /* memory allocated by the dynamic loader for itself */ |
339 | #define VM_MEMORY_DYLD 60 | |
340 | /* malloc'd memory created by dyld */ | |
341 | #define VM_MEMORY_DYLD_MALLOC 61 | |
342 | ||
b0d623f7 A |
343 | /* Used for sqlite page cache */ |
344 | #define VM_MEMORY_SQLITE 62 | |
345 | ||
346 | /* JavaScriptCore heaps */ | |
347 | #define VM_MEMORY_JAVASCRIPT_CORE 63 | |
348 | /* memory allocated for the JIT */ | |
349 | #define VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR 64 | |
350 | #define VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE 65 | |
351 | ||
352 | /* memory allocated for GLSL */ | |
353 | #define VM_MEMORY_GLSL 66 | |
354 | ||
1c79356b A |
355 | /* Reserve 240-255 for application */ |
356 | #define VM_MEMORY_APPLICATION_SPECIFIC_1 240 | |
357 | #define VM_MEMORY_APPLICATION_SPECIFIC_16 255 | |
358 | ||
2d21ac55 | 359 | #define VM_MAKE_TAG(tag) ((tag) << 24) |
91447636 A |
360 | |
361 | #endif /* _MACH_VM_STATISTICS_H_ */ |