Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/include/mach/vm_statistics.h

1/*
2 * Copyright (c) 2000-2009 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
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
84struct vm_statistics {
85natural_tfree_count;/* # of pages free */
86natural_tactive_count;/* # of pages active */
87natural_tinactive_count;/* # of pages inactive */
88natural_twire_count;/* # of pages wired down */
89natural_tzero_fill_count;/* # of zero fill pages */
90natural_treactivations;/* # of pages reactivated */
91natural_tpageins;/* # of pageins */
92natural_tpageouts;/* # of pageouts */
93natural_tfaults;/* # of faults */
94natural_tcow_faults;/* # of copy-on-writes */
95natural_tlookups;/* object cache lookups */
96natural_thits;/* object cache hits */
97
98/* added for rev1 */
99natural_tpurgeable_count;/* # of pages purgeable */
100natural_tpurges;/* # of pages purged */
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 */
109natural_tspeculative_count;/* # of pages speculative */
110};
111
112/* Used by all architectures */
113typedef struct vm_statistics*vm_statistics_t;
114typedef struct vm_statisticsvm_statistics_data_t;
115
116/*
117 * vm_statistics64
118 *
119 * History:
120 *rev0 - original structure.
121 *rev1 - added purgable info (purgable_count and purges).
122 *rev2 - added speculative_count.
123 * ----
124 *rev3 - changed name to vm_statistics64.
125 *changed some fields in structure to 64-bit on
126 *arm, i386 and x86_64 architectures.
127 *rev4 - require 64-bit alignment for efficient access
128 *in the kernel. No change to reported data.
129 *
130 */
131
132struct vm_statistics64 {
133natural_tfree_count;/* # of pages free */
134natural_tactive_count;/* # of pages active */
135natural_tinactive_count;/* # of pages inactive */
136natural_twire_count;/* # of pages wired down */
137uint64_tzero_fill_count;/* # of zero fill pages */
138uint64_treactivations;/* # of pages reactivated */
139uint64_tpageins;/* # of pageins */
140uint64_tpageouts;/* # of pageouts */
141uint64_tfaults;/* # of faults */
142uint64_tcow_faults;/* # of copy-on-writes */
143uint64_tlookups;/* object cache lookups */
144uint64_thits;/* object cache hits */
145
146/* added for rev1 */
147uint64_tpurges;/* # of pages purged */
148natural_tpurgeable_count;/* # of pages purgeable */
149
150/* added for rev2 */
151/*
152 * NB: speculative pages are already accounted for in "free_count",
153 * so "speculative_count" is the number of "free" pages that are
154 * used to hold data that was read speculatively from disk but
155 * haven't actually been used by anyone so far.
156 */
157natural_tspeculative_count;/* # of pages speculative */
158
159} __attribute__((aligned(8)));
160
161typedef struct vm_statistics64*vm_statistics64_t;
162typedef struct vm_statistics64vm_statistics64_data_t;
163
164/*
165 * VM_STATISTICS_TRUNCATE_TO_32_BIT
166 *
167 * This is used by host_statistics() to truncate and peg the 64-bit in-kernel values from
168 * vm_statistics64 to the 32-bit values of the older structure above (vm_statistics).
169 */
170#define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) ((uint32_t)(((value) > UINT32_MAX ) ? UINT32_MAX : (value)))
171
172/*
173 * vm_extmod_statistics
174 *
175 * Structure to record modifications to a task by an
176 * external agent.
177 *
178 * History:
179 *rev0 - original structure.
180 */
181
182struct vm_extmod_statistics {
183int64_ttask_for_pid_count;/* # of times task port was looked up */
184int64_t task_for_pid_caller_count;/* # of times this task called task_for_pid */
185int64_tthread_creation_count;/* # of threads created in task */
186int64_tthread_creation_caller_count;/* # of threads created by task */
187int64_tthread_set_state_count;/* # of register state sets in task */
188int64_tthread_set_state_caller_count;/* # of register state sets by task */
189} __attribute__((aligned(8)));
190
191typedef struct vm_extmod_statistics *vm_extmod_statistics_t;
192typedef struct vm_extmod_statistics vm_extmod_statistics_data_t;
193
194
195/* included for the vm_map_page_query call */
196
197#define VM_PAGE_QUERY_PAGE_PRESENT 0x1
198#define VM_PAGE_QUERY_PAGE_FICTITIOUS 0x2
199#define VM_PAGE_QUERY_PAGE_REF 0x4
200#define VM_PAGE_QUERY_PAGE_DIRTY 0x8
201#define VM_PAGE_QUERY_PAGE_PAGED_OUT 0x10
202#define VM_PAGE_QUERY_PAGE_COPIED 0x20
203#define VM_PAGE_QUERY_PAGE_SPECULATIVE0x40
204#define VM_PAGE_QUERY_PAGE_EXTERNAL0x80
205#define VM_PAGE_QUERY_PAGE_CS_VALIDATED0x100
206#define VM_PAGE_QUERY_PAGE_CS_TAINTED0x200
207
208
209/*
210 * VM allocation flags:
211 *
212 * VM_FLAGS_FIXED
213 * (really the absence of VM_FLAGS_ANYWHERE)
214 *Allocate new VM region at the specified virtual address, if possible.
215 *
216 * VM_FLAGS_ANYWHERE
217 *Allocate new VM region anywhere it would fit in the address space.
218 *
219 * VM_FLAGS_PURGABLE
220 *Create a purgable VM object for that new VM region.
221 *
222 * VM_FLAGS_NO_PMAP_CHECK
223 *(for DEBUG kernel config only, ignored for other configs)
224 *Do not check that there is no stale pmap mapping for the new VM region.
225 *This is useful for kernel memory allocations at bootstrap when building
226 *the initial kernel address space while some memory is already in use.
227 *
228 * VM_FLAGS_OVERWRITE
229 *The new VM region can replace existing VM regions if necessary
230 *(to be used in combination with VM_FLAGS_FIXED).
231 *
232 * VM_FLAGS_NO_CACHE
233 *Pages brought in to this VM region are placed on the speculative
234 *queue instead of the active queue. In other words, they are not
235 *cached so that they will be stolen first if memory runs low.
236 */
237#define VM_FLAGS_FIXED0x0000
238#define VM_FLAGS_ANYWHERE0x0001
239#define VM_FLAGS_PURGABLE0x0002
240#define VM_FLAGS_NO_CACHE0x0010
241#define VM_FLAGS_OVERWRITE0x4000/* delete any existing mappings first */
242
243/*
244 * VM_FLAGS_SUPERPAGE_MASK
245 *3 bits that specify whether large pages should be used instead of
246 *base pages (!=0), as well as the requested page size.
247 */
248#define VM_FLAGS_SUPERPAGE_MASK0x70000/* bits 0x10000, 0x20000, 0x40000 */
249#define VM_FLAGS_SUPERPAGE_SHIFT 16
250
251#define SUPERPAGE_NONE0/* no superpages, if all bits are 0 */
252#define SUPERPAGE_SIZE_ANY1
253#define VM_FLAGS_SUPERPAGE_NONE (SUPERPAGE_NONE << VM_FLAGS_SUPERPAGE_SHIFT)
254#define VM_FLAGS_SUPERPAGE_SIZE_ANY (SUPERPAGE_SIZE_ANY << VM_FLAGS_SUPERPAGE_SHIFT)
255#define SUPERPAGE_SIZE_2MB2
256#define VM_FLAGS_SUPERPAGE_SIZE_2MB (SUPERPAGE_SIZE_2MB<<VM_FLAGS_SUPERPAGE_SHIFT)
257
258#define VM_FLAGS_ALIAS_MASK0xFF000000
259#define VM_GET_FLAGS_ALIAS(flags, alias)\
260(alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24
261#define VM_SET_FLAGS_ALIAS(flags, alias)\
262(flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) |\
263(((alias) & ~VM_FLAGS_ALIAS_MASK) << 24))
264
265/* These are the flags that we accept from user-space */
266#define VM_FLAGS_USER_ALLOCATE(VM_FLAGS_FIXED |\
267 VM_FLAGS_ANYWHERE |\
268 VM_FLAGS_PURGABLE |\
269 VM_FLAGS_NO_CACHE |\
270 VM_FLAGS_OVERWRITE |\
271 VM_FLAGS_SUPERPAGE_MASK |\
272 VM_FLAGS_ALIAS_MASK)
273#define VM_FLAGS_USER_MAPVM_FLAGS_USER_ALLOCATE
274#define VM_FLAGS_USER_REMAP(VM_FLAGS_FIXED | \
275 VM_FLAGS_ANYWHERE | \
276 VM_FLAGS_OVERWRITE)
277
278#define VM_MEMORY_MALLOC 1
279#define VM_MEMORY_MALLOC_SMALL 2
280#define VM_MEMORY_MALLOC_LARGE 3
281#define VM_MEMORY_MALLOC_HUGE 4
282#define VM_MEMORY_SBRK 5// uninteresting -- no one should call
283#define VM_MEMORY_REALLOC 6
284#define VM_MEMORY_MALLOC_TINY 7
285#define VM_MEMORY_MALLOC_LARGE_REUSABLE 8
286#define VM_MEMORY_MALLOC_LARGE_REUSED 9
287
288#define VM_MEMORY_ANALYSIS_TOOL 10
289
290#define VM_MEMORY_MACH_MSG 20
291#define VM_MEMORY_IOKIT21
292#define VM_MEMORY_STACK 30
293#define VM_MEMORY_GUARD 31
294#defineVM_MEMORY_SHARED_PMAP 32
295/* memory containing a dylib */
296#define VM_MEMORY_DYLIB33
297#define VM_MEMORY_OBJC_DISPATCHERS 34
298
299/* Was a nested pmap (VM_MEMORY_SHARED_PMAP) which has now been unnested */
300#defineVM_MEMORY_UNSHARED_PMAP35
301
302
303// Placeholders for now -- as we analyze the libraries and find how they
304// use memory, we can make these labels more specific.
305#define VM_MEMORY_APPKIT 40
306#define VM_MEMORY_FOUNDATION 41
307#define VM_MEMORY_COREGRAPHICS 42
308#define VM_MEMORY_CORESERVICES 43
309#define VM_MEMORY_CARBON VM_MEMORY_CORESERVICES
310#define VM_MEMORY_JAVA 44
311#define VM_MEMORY_ATS 50
312#define VM_MEMORY_LAYERKIT 51
313#define VM_MEMORY_CGIMAGE 52
314#define VM_MEMORY_TCMALLOC 53
315
316/* private raster data (i.e. layers, some images, QGL allocator) */
317#defineVM_MEMORY_COREGRAPHICS_DATA54
318
319/* shared image and font caches */
320#define VM_MEMORY_COREGRAPHICS_SHARED55
321
322/* Memory used for virtual framebuffers, shadowing buffers, etc... */
323#defineVM_MEMORY_COREGRAPHICS_FRAMEBUFFERS56
324
325/* Window backing stores, custom shadow data, and compressed backing stores */
326#define VM_MEMORY_COREGRAPHICS_BACKINGSTORES57
327
328/* catch-all for other uses, such as the read-only shared data page */
329#define VM_MEMORY_COREGRAPHICS_MISC VM_MEMORY_COREGRAPHICS
330
331/* memory allocated by the dynamic loader for itself */
332#define VM_MEMORY_DYLD 60
333/* malloc'd memory created by dyld */
334#define VM_MEMORY_DYLD_MALLOC 61
335
336/* Used for sqlite page cache */
337#define VM_MEMORY_SQLITE 62
338
339/* JavaScriptCore heaps */
340#define VM_MEMORY_JAVASCRIPT_CORE 63
341/* memory allocated for the JIT */
342#define VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR 64
343#define VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE 65
344
345/* memory allocated for GLSL */
346#define VM_MEMORY_GLSL 66
347
348/* memory allocated for OpenCL.framework */
349#define VM_MEMORY_OPENCL 67
350
351/* memory allocated for QuartzCore.framework */
352#define VM_MEMORY_COREIMAGE 68
353
354/* memory allocated for WebCore Purgeable Buffers */
355#define VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS 69
356
357/* ImageIO memory */
358#define VM_MEMORY_IMAGEIO70
359
360/* CoreProfile memory */
361#define VM_MEMORY_COREPROFILE71
362
363/* assetsd / MobileSlideShow memory */
364#define VM_MEMORY_ASSETSD72
365
366/* Reserve 240-255 for application */
367#define VM_MEMORY_APPLICATION_SPECIFIC_1 240
368#define VM_MEMORY_APPLICATION_SPECIFIC_16 255
369
370#define VM_MAKE_TAG(tag) ((tag) << 24)
371
372#endif/* _MACH_VM_STATISTICS_H_ */
373

Archive Download this file

Revision: 2182