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