]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/vm_statistics.h
xnu-1228.12.14.tar.gz
[apple/xnu.git] / osfmk / mach / vm_statistics.h
1 /*
2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
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
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * @OSF_COPYRIGHT@
30 */
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
66 #ifndef _MACH_VM_STATISTICS_H_
67 #define _MACH_VM_STATISTICS_H_
68
69 #include <mach/machine/vm_types.h>
70
71 struct vm_statistics {
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
85 /* added for rev1 */
86 natural_t purgeable_count; /* # of pages purgeable */
87 natural_t purges; /* # of pages purged */
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 */
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
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
112 #define VM_PAGE_QUERY_PAGE_CS_VALIDATED 0x100
113 #define VM_PAGE_QUERY_PAGE_CS_TAINTED 0x200
114
115 #ifdef MACH_KERNEL_PRIVATE
116
117 /*
118 * Each machine dependent implementation is expected to
119 * keep certain statistics. They may do this anyway they
120 * so choose, but are expected to return the statistics
121 * in the following structure.
122 */
123
124 struct pmap_statistics {
125 integer_t resident_count; /* # of pages mapped (total)*/
126 integer_t resident_max; /* # of pages mapped (peak) */
127 integer_t wired_count; /* # of pages wired */
128 };
129
130 typedef struct pmap_statistics *pmap_statistics_t;
131
132 #endif /* MACH_KERNEL_PRIVATE */
133
134 /*
135 * VM allocation flags:
136 *
137 * VM_FLAGS_FIXED
138 * (really the absence of VM_FLAGS_ANYWHERE)
139 * Allocate new VM region at the specified virtual address, if possible.
140 *
141 * VM_FLAGS_ANYWHERE
142 * Allocate new VM region anywhere it would fit in the address space.
143 *
144 * VM_FLAGS_PURGABLE
145 * Create a purgable VM object for that new VM region.
146 *
147 * VM_FLAGS_NO_PMAP_CHECK
148 * (for DEBUG kernel config only, ignored for other configs)
149 * Do not check that there is no stale pmap mapping for the new VM region.
150 * This is useful for kernel memory allocations at bootstrap when building
151 * the initial kernel address space while some memory is already in use.
152 *
153 * VM_FLAGS_OVERWRITE
154 * The new VM region can replace existing VM regions if necessary
155 * (to be used in combination with VM_FLAGS_FIXED).
156 *
157 * VM_FLAGS_NO_CACHE
158 * Pages brought in to this VM region are placed on the speculative
159 * queue instead of the active queue. In other words, they are not
160 * cached so that they will be stolen first if memory runs low.
161 */
162 #define VM_FLAGS_FIXED 0x0000
163 #define VM_FLAGS_ANYWHERE 0x0001
164 #define VM_FLAGS_PURGABLE 0x0002
165 #define VM_FLAGS_NO_CACHE 0x0010
166
167 #ifdef KERNEL_PRIVATE
168 #define VM_FLAGS_NO_PMAP_CHECK 0x8000 /* do not check that pmap is empty */
169 #define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */
170 #define VM_FLAGS_BEYOND_MAX 0x2000 /* map beyond the map's limits */
171 #define VM_FLAGS_ALREADY 0x1000 /* OK if same mapping already exists */
172 #define VM_FLAGS_SUBMAP 0x0800 /* mapping a VM submap */
173 #endif /* KERNEL_PRIVATE */
174 #define VM_FLAGS_GUARD_BEFORE 0x0010
175 #define VM_FLAGS_GUARD_AFTER 0x0020
176
177 #define VM_FLAGS_ALIAS_MASK 0xFF000000
178 #define VM_GET_FLAGS_ALIAS(flags, alias) \
179 (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24
180 #define VM_SET_FLAGS_ALIAS(flags, alias) \
181 (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) | \
182 (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24))
183
184 /* These are the flags that we accept from user-space */
185 #define VM_FLAGS_USER_ALLOCATE (VM_FLAGS_FIXED | \
186 VM_FLAGS_ANYWHERE | \
187 VM_FLAGS_PURGABLE | \
188 VM_FLAGS_NO_CACHE | \
189 VM_FLAGS_ALIAS_MASK)
190 #define VM_FLAGS_USER_MAP VM_FLAGS_USER_ALLOCATE
191
192 #define VM_MEMORY_MALLOC 1
193 #define VM_MEMORY_MALLOC_SMALL 2
194 #define VM_MEMORY_MALLOC_LARGE 3
195 #define VM_MEMORY_MALLOC_HUGE 4
196 #define VM_MEMORY_SBRK 5// uninteresting -- no one should call
197 #define VM_MEMORY_REALLOC 6
198 #define VM_MEMORY_MALLOC_TINY 7
199
200 #define VM_MEMORY_ANALYSIS_TOOL 10
201
202 #define VM_MEMORY_MACH_MSG 20
203 #define VM_MEMORY_IOKIT 21
204 #define VM_MEMORY_STACK 30
205 #define VM_MEMORY_GUARD 31
206 #define VM_MEMORY_SHARED_PMAP 32
207 /* memory containing a dylib */
208 #define VM_MEMORY_DYLIB 33
209
210 // Placeholders for now -- as we analyze the libraries and find how they
211 // use memory, we can make these labels more specific.
212 #define VM_MEMORY_APPKIT 40
213 #define VM_MEMORY_FOUNDATION 41
214 #define VM_MEMORY_COREGRAPHICS 42
215 #define VM_MEMORY_CARBON 43
216 #define VM_MEMORY_JAVA 44
217 #define VM_MEMORY_ATS 50
218 #define VM_MEMORY_LAYERKIT 51
219 #define VM_MEMORY_CGIMAGE 52
220 #define VM_MEMORY_TCMALLOC 53
221
222 /* private raster data (i.e. layers, some images, QGL allocator) */
223 #define VM_MEMORY_COREGRAPHICS_DATA 54
224
225 /* shared image and font caches */
226 #define VM_MEMORY_COREGRAPHICS_SHARED 55
227
228 /* Memory used for virtual framebuffers, shadowing buffers, etc... */
229 #define VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS 56
230
231 /* Window backing stores, custom shadow data, and compressed backing stores */
232 #define VM_MEMORY_COREGRAPHICS_BACKINGSTORES 57
233
234 /* catch-all for other uses, such as the read-only shared data page */
235 #define VM_MEMORY_COREGRAPHICS_MISC VM_MEMORY_COREGRAPHICS
236
237 /* memory allocated by the dynamic loader for itself */
238 #define VM_MEMORY_DYLD 60
239 /* malloc'd memory created by dyld */
240 #define VM_MEMORY_DYLD_MALLOC 61
241
242 /* Reserve 240-255 for application */
243 #define VM_MEMORY_APPLICATION_SPECIFIC_1 240
244 #define VM_MEMORY_APPLICATION_SPECIFIC_16 255
245
246 #define VM_MAKE_TAG(tag) ((tag) << 24)
247
248 #endif /* _MACH_VM_STATISTICS_H_ */