]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2007 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 | ||
71 | struct vm_statistics { | |
91447636 A |
72 | natural_t free_count; /* # of pages free */ |
73 | natural_t active_count; /* # of pages active */ | |
74 | natural_t inactive_count; /* # of pages inactive */ | |
75 | natural_t wire_count; /* # of pages wired down */ | |
76 | natural_t zero_fill_count; /* # of zero fill pages */ | |
77 | natural_t reactivations; /* # of pages reactivated */ | |
78 | natural_t pageins; /* # of pageins */ | |
79 | natural_t pageouts; /* # of pageouts */ | |
80 | natural_t faults; /* # of faults */ | |
81 | natural_t cow_faults; /* # of copy-on-writes */ | |
82 | natural_t lookups; /* object cache lookups */ | |
83 | natural_t hits; /* object cache hits */ | |
84 | ||
2d21ac55 | 85 | /* added for rev1 */ |
91447636 A |
86 | natural_t purgeable_count; /* # of pages purgeable */ |
87 | natural_t purges; /* # of pages purged */ | |
2d21ac55 A |
88 | |
89 | /* added for rev2 */ | |
90 | /* | |
91 | * NB: speculative pages are already accounted for in "free_count", | |
92 | * so "speculative_count" is the number of "free" pages that are | |
93 | * used to hold data that was read speculatively from disk but | |
94 | * haven't actually been used by anyone so far. | |
95 | */ | |
96 | natural_t speculative_count; /* # of pages speculative */ | |
1c79356b A |
97 | }; |
98 | ||
99 | typedef struct vm_statistics *vm_statistics_t; | |
100 | typedef struct vm_statistics vm_statistics_data_t; | |
101 | ||
102 | ||
103 | /* included for the vm_map_page_query call */ | |
104 | ||
105 | #define VM_PAGE_QUERY_PAGE_PRESENT 0x1 | |
106 | #define VM_PAGE_QUERY_PAGE_FICTITIOUS 0x2 | |
107 | #define VM_PAGE_QUERY_PAGE_REF 0x4 | |
108 | #define VM_PAGE_QUERY_PAGE_DIRTY 0x8 | |
2d21ac55 A |
109 | #define VM_PAGE_QUERY_PAGE_PAGED_OUT 0x10 |
110 | #define VM_PAGE_QUERY_PAGE_COPIED 0x20 | |
111 | #define VM_PAGE_QUERY_PAGE_SPECULATIVE 0x40 | |
1c79356b | 112 | |
91447636 | 113 | #ifdef MACH_KERNEL_PRIVATE |
1c79356b A |
114 | |
115 | /* | |
116 | * Each machine dependent implementation is expected to | |
117 | * keep certain statistics. They may do this anyway they | |
118 | * so choose, but are expected to return the statistics | |
119 | * in the following structure. | |
120 | */ | |
121 | ||
122 | struct pmap_statistics { | |
123 | integer_t resident_count; /* # of pages mapped (total)*/ | |
2d21ac55 | 124 | integer_t resident_max; /* # of pages mapped (peak) */ |
1c79356b A |
125 | integer_t wired_count; /* # of pages wired */ |
126 | }; | |
127 | ||
128 | typedef struct pmap_statistics *pmap_statistics_t; | |
129 | ||
91447636 A |
130 | #endif /* MACH_KERNEL_PRIVATE */ |
131 | ||
132 | /* | |
133 | * VM allocation flags: | |
134 | * | |
135 | * VM_FLAGS_FIXED | |
136 | * (really the absence of VM_FLAGS_ANYWHERE) | |
137 | * Allocate new VM region at the specified virtual address, if possible. | |
138 | * | |
139 | * VM_FLAGS_ANYWHERE | |
140 | * Allocate new VM region anywhere it would fit in the address space. | |
141 | * | |
142 | * VM_FLAGS_PURGABLE | |
143 | * Create a purgable VM object for that new VM region. | |
144 | * | |
145 | * VM_FLAGS_NO_PMAP_CHECK | |
146 | * (for DEBUG kernel config only, ignored for other configs) | |
147 | * Do not check that there is no stale pmap mapping for the new VM region. | |
148 | * This is useful for kernel memory allocations at bootstrap when building | |
149 | * the initial kernel address space while some memory is already in use. | |
150 | * | |
151 | * VM_FLAGS_OVERWRITE | |
152 | * The new VM region can replace existing VM regions if necessary | |
153 | * (to be used in combination with VM_FLAGS_FIXED). | |
2d21ac55 A |
154 | * |
155 | * VM_FLAGS_NO_CACHE | |
156 | * Pages brought in to this VM region are placed on the speculative | |
157 | * queue instead of the active queue. In other words, they are not | |
158 | * cached so that they will be stolen first if memory runs low. | |
91447636 A |
159 | */ |
160 | #define VM_FLAGS_FIXED 0x0000 | |
161 | #define VM_FLAGS_ANYWHERE 0x0001 | |
162 | #define VM_FLAGS_PURGABLE 0x0002 | |
2d21ac55 A |
163 | #define VM_FLAGS_NO_CACHE 0x0010 |
164 | ||
91447636 | 165 | #ifdef KERNEL_PRIVATE |
2d21ac55 A |
166 | #define VM_FLAGS_NO_PMAP_CHECK 0x8000 /* do not check that pmap is empty */ |
167 | #define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */ | |
168 | #define VM_FLAGS_BEYOND_MAX 0x2000 /* map beyond the map's limits */ | |
169 | #define VM_FLAGS_ALREADY 0x1000 /* OK if same mapping already exists */ | |
170 | #define VM_FLAGS_SUBMAP 0x0800 /* mapping a VM submap */ | |
91447636 | 171 | #endif /* KERNEL_PRIVATE */ |
2d21ac55 A |
172 | #define VM_FLAGS_GUARD_BEFORE 0x0010 |
173 | #define VM_FLAGS_GUARD_AFTER 0x0020 | |
91447636 | 174 | |
1c79356b A |
175 | #define VM_FLAGS_ALIAS_MASK 0xFF000000 |
176 | #define VM_GET_FLAGS_ALIAS(flags, alias) \ | |
177 | (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24 | |
178 | #define VM_SET_FLAGS_ALIAS(flags, alias) \ | |
179 | (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) | \ | |
180 | (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24)) | |
181 | ||
2d21ac55 A |
182 | /* These are the flags that we accept from user-space */ |
183 | #define VM_FLAGS_USER_ALLOCATE (VM_FLAGS_FIXED | \ | |
184 | VM_FLAGS_ANYWHERE | \ | |
185 | VM_FLAGS_PURGABLE | \ | |
186 | VM_FLAGS_NO_CACHE | \ | |
187 | VM_FLAGS_ALIAS_MASK) | |
188 | #define VM_FLAGS_USER_MAP VM_FLAGS_USER_ALLOCATE | |
189 | ||
1c79356b A |
190 | #define VM_MEMORY_MALLOC 1 |
191 | #define VM_MEMORY_MALLOC_SMALL 2 | |
192 | #define VM_MEMORY_MALLOC_LARGE 3 | |
193 | #define VM_MEMORY_MALLOC_HUGE 4 | |
194 | #define VM_MEMORY_SBRK 5// uninteresting -- no one should call | |
55e303ae A |
195 | #define VM_MEMORY_REALLOC 6 |
196 | #define VM_MEMORY_MALLOC_TINY 7 | |
1c79356b A |
197 | |
198 | #define VM_MEMORY_ANALYSIS_TOOL 10 | |
199 | ||
200 | #define VM_MEMORY_MACH_MSG 20 | |
201 | #define VM_MEMORY_IOKIT 21 | |
202 | #define VM_MEMORY_STACK 30 | |
203 | #define VM_MEMORY_GUARD 31 | |
204 | #define VM_MEMORY_SHARED_PMAP 32 | |
205 | /* memory containing a dylib */ | |
206 | #define VM_MEMORY_DYLIB 33 | |
207 | ||
208 | // Placeholders for now -- as we analyze the libraries and find how they | |
209 | // use memory, we can make these labels more specific. | |
210 | #define VM_MEMORY_APPKIT 40 | |
211 | #define VM_MEMORY_FOUNDATION 41 | |
212 | #define VM_MEMORY_COREGRAPHICS 42 | |
213 | #define VM_MEMORY_CARBON 43 | |
9bccf70c | 214 | #define VM_MEMORY_JAVA 44 |
1c79356b | 215 | #define VM_MEMORY_ATS 50 |
2d21ac55 A |
216 | #define VM_MEMORY_LAYERKIT 51 |
217 | #define VM_MEMORY_CGIMAGE 52 | |
218 | #define VM_MEMORY_TCMALLOC 53 | |
219 | ||
220 | /* private raster data (i.e. layers, some images, QGL allocator) */ | |
221 | #define VM_MEMORY_COREGRAPHICS_DATA 54 | |
222 | ||
223 | /* shared image and font caches */ | |
224 | #define VM_MEMORY_COREGRAPHICS_SHARED 55 | |
225 | ||
226 | /* Memory used for virtual framebuffers, shadowing buffers, etc... */ | |
227 | #define VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS 56 | |
228 | ||
229 | /* Window backing stores, custom shadow data, and compressed backing stores */ | |
230 | #define VM_MEMORY_COREGRAPHICS_BACKINGSTORES 57 | |
231 | ||
232 | /* catch-all for other uses, such as the read-only shared data page */ | |
233 | #define VM_MEMORY_COREGRAPHICS_MISC VM_MEMORY_COREGRAPHICS | |
1c79356b | 234 | |
1c79356b A |
235 | /* memory allocated by the dynamic loader for itself */ |
236 | #define VM_MEMORY_DYLD 60 | |
237 | /* malloc'd memory created by dyld */ | |
238 | #define VM_MEMORY_DYLD_MALLOC 61 | |
239 | ||
240 | /* Reserve 240-255 for application */ | |
241 | #define VM_MEMORY_APPLICATION_SPECIFIC_1 240 | |
242 | #define VM_MEMORY_APPLICATION_SPECIFIC_16 255 | |
243 | ||
2d21ac55 | 244 | #define VM_MAKE_TAG(tag) ((tag) << 24) |
91447636 A |
245 | |
246 | #endif /* _MACH_VM_STATISTICS_H_ */ |