]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/vm_statistics.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / osfmk / mach / vm_statistics.h
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * @OSF_COPYRIGHT@
32 */
33 /*
34 * Mach Operating System
35 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
36 * All Rights Reserved.
37 *
38 * Permission to use, copy, modify and distribute this software and its
39 * documentation is hereby granted, provided that both the copyright
40 * notice and this permission notice appear in all copies of the
41 * software, derivative works or modified versions, and any portions
42 * thereof, and that both notices appear in supporting documentation.
43 *
44 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
45 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
46 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
47 *
48 * Carnegie Mellon requests users of this software to return to
49 *
50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
51 * School of Computer Science
52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
54 *
55 * any improvements or extensions that they make and grant Carnegie Mellon
56 * the rights to redistribute these changes.
57 */
58 /*
59 */
60 /*
61 * File: mach/vm_statistics.h
62 * Author: Avadis Tevanian, Jr., Michael Wayne Young, David Golub
63 *
64 * Virtual memory statistics structure.
65 *
66 */
67
68 #ifndef _MACH_VM_STATISTICS_H_
69 #define _MACH_VM_STATISTICS_H_
70
71 #include <mach/machine/vm_types.h>
72
73 struct vm_statistics {
74 natural_t free_count; /* # of pages free */
75 natural_t active_count; /* # of pages active */
76 natural_t inactive_count; /* # of pages inactive */
77 natural_t wire_count; /* # of pages wired down */
78 natural_t zero_fill_count; /* # of zero fill pages */
79 natural_t reactivations; /* # of pages reactivated */
80 natural_t pageins; /* # of pageins */
81 natural_t pageouts; /* # of pageouts */
82 natural_t faults; /* # of faults */
83 natural_t cow_faults; /* # of copy-on-writes */
84 natural_t lookups; /* object cache lookups */
85 natural_t hits; /* object cache hits */
86
87 natural_t purgeable_count; /* # of pages purgeable */
88 natural_t purges; /* # of pages purged */
89 };
90
91 typedef struct vm_statistics *vm_statistics_t;
92 typedef struct vm_statistics vm_statistics_data_t;
93
94 struct vm_statistics_rev0 {
95 natural_t free_count; /* # of pages free */
96 natural_t active_count; /* # of pages active */
97 natural_t inactive_count; /* # of pages inactive */
98 natural_t wire_count; /* # of pages wired down */
99 natural_t zero_fill_count; /* # of zero fill pages */
100 natural_t reactivations; /* # of pages reactivated */
101 natural_t pageins; /* # of pageins */
102 natural_t pageouts; /* # of pageouts */
103 natural_t faults; /* # of faults */
104 natural_t cow_faults; /* # of copy-on-writes */
105 natural_t lookups; /* object cache lookups */
106 natural_t hits; /* object cache hits */
107 };
108
109 typedef struct vm_statistics_rev0 *vm_statistics_rev0_t;
110 typedef struct vm_statistics_rev0 vm_statistics_rev0_data_t;
111
112 /* included for the vm_map_page_query call */
113
114 #define VM_PAGE_QUERY_PAGE_PRESENT 0x1
115 #define VM_PAGE_QUERY_PAGE_FICTITIOUS 0x2
116 #define VM_PAGE_QUERY_PAGE_REF 0x4
117 #define VM_PAGE_QUERY_PAGE_DIRTY 0x8
118
119 #ifdef MACH_KERNEL_PRIVATE
120
121 /*
122 * Each machine dependent implementation is expected to
123 * keep certain statistics. They may do this anyway they
124 * so choose, but are expected to return the statistics
125 * in the following structure.
126 */
127
128 struct pmap_statistics {
129 integer_t resident_count; /* # of pages mapped (total)*/
130 integer_t wired_count; /* # of pages wired */
131 };
132
133 typedef struct pmap_statistics *pmap_statistics_t;
134
135 #endif /* MACH_KERNEL_PRIVATE */
136
137 /*
138 * VM allocation flags:
139 *
140 * VM_FLAGS_FIXED
141 * (really the absence of VM_FLAGS_ANYWHERE)
142 * Allocate new VM region at the specified virtual address, if possible.
143 *
144 * VM_FLAGS_ANYWHERE
145 * Allocate new VM region anywhere it would fit in the address space.
146 *
147 * VM_FLAGS_PURGABLE
148 * Create a purgable VM object for that new VM region.
149 *
150 * VM_FLAGS_NO_PMAP_CHECK
151 * (for DEBUG kernel config only, ignored for other configs)
152 * Do not check that there is no stale pmap mapping for the new VM region.
153 * This is useful for kernel memory allocations at bootstrap when building
154 * the initial kernel address space while some memory is already in use.
155 *
156 * VM_FLAGS_OVERWRITE
157 * The new VM region can replace existing VM regions if necessary
158 * (to be used in combination with VM_FLAGS_FIXED).
159 */
160 #define VM_FLAGS_FIXED 0x0000
161 #define VM_FLAGS_ANYWHERE 0x0001
162 #define VM_FLAGS_PURGABLE 0x0002
163 #ifdef KERNEL_PRIVATE
164 #define VM_FLAGS_NO_PMAP_CHECK 0x0004
165 #endif /* KERNEL_PRIVATE */
166 #define VM_FLAGS_OVERWRITE 0x0008
167
168 #define VM_FLAGS_ALIAS_MASK 0xFF000000
169 #define VM_GET_FLAGS_ALIAS(flags, alias) \
170 (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24
171 #define VM_SET_FLAGS_ALIAS(flags, alias) \
172 (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) | \
173 (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24))
174
175 #define VM_MEMORY_MALLOC 1
176 #define VM_MEMORY_MALLOC_SMALL 2
177 #define VM_MEMORY_MALLOC_LARGE 3
178 #define VM_MEMORY_MALLOC_HUGE 4
179 #define VM_MEMORY_SBRK 5// uninteresting -- no one should call
180 #define VM_MEMORY_REALLOC 6
181 #define VM_MEMORY_MALLOC_TINY 7
182
183 #define VM_MEMORY_ANALYSIS_TOOL 10
184
185 #define VM_MEMORY_MACH_MSG 20
186 #define VM_MEMORY_IOKIT 21
187 #define VM_MEMORY_STACK 30
188 #define VM_MEMORY_GUARD 31
189 #define VM_MEMORY_SHARED_PMAP 32
190 /* memory containing a dylib */
191 #define VM_MEMORY_DYLIB 33
192
193 // Placeholders for now -- as we analyze the libraries and find how they
194 // use memory, we can make these labels more specific.
195 #define VM_MEMORY_APPKIT 40
196 #define VM_MEMORY_FOUNDATION 41
197 #define VM_MEMORY_COREGRAPHICS 42
198 #define VM_MEMORY_CARBON 43
199 #define VM_MEMORY_JAVA 44
200 #define VM_MEMORY_ATS 50
201
202 /* memory allocated by the dynamic loader for itself */
203 #define VM_MEMORY_DYLD 60
204 /* malloc'd memory created by dyld */
205 #define VM_MEMORY_DYLD_MALLOC 61
206
207 /* Reserve 240-255 for application */
208 #define VM_MEMORY_APPLICATION_SPECIFIC_1 240
209 #define VM_MEMORY_APPLICATION_SPECIFIC_16 255
210
211 #define VM_MAKE_TAG(tag) (tag<<24)
212
213 #endif /* _MACH_VM_STATISTICS_H_ */