]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/mach/vm_statistics.h
xnu-1228.tar.gz
[apple/xnu.git] / osfmk / mach / vm_statistics.h
index 754aec336195e5477a887c44a7a5030af0a5d875..aab39fd3ce32b89d40b5814801fbd18ea5560bff 100644 (file)
@@ -1,16 +1,19 @@
 /*
- * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  * This file contains Original Code and/or Modifications of Original Code
  * as defined in and that are subject to the Apple Public Source License
  * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ * 
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
  * 
  * The Original Code and all software distributed under the License are
  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
@@ -20,7 +23,7 @@
  * Please see the License for the specific language governing rights and
  * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  *
  */
 
-#ifndef        VM_STATISTICS_H_
-#define        VM_STATISTICS_H_
+#ifndef        _MACH_VM_STATISTICS_H_
+#define        _MACH_VM_STATISTICS_H_
 
 #include <mach/machine/vm_types.h>
 
 struct vm_statistics {
-       integer_t       free_count;             /* # of pages free */
-       integer_t       active_count;           /* # of pages active */
-       integer_t       inactive_count;         /* # of pages inactive */
-       integer_t       wire_count;             /* # of pages wired down */
-       integer_t       zero_fill_count;        /* # of zero fill pages */
-       integer_t       reactivations;          /* # of pages reactivated */
-       integer_t       pageins;                /* # of pageins */
-       integer_t       pageouts;               /* # of pageouts */
-       integer_t       faults;                 /* # of faults */
-       integer_t       cow_faults;             /* # of copy-on-writes */
-       integer_t       lookups;                /* object cache lookups */
-       integer_t       hits;                   /* object cache hits */
+       natural_t       free_count;             /* # of pages free */
+       natural_t       active_count;           /* # of pages active */
+       natural_t       inactive_count;         /* # of pages inactive */
+       natural_t       wire_count;             /* # of pages wired down */
+       natural_t       zero_fill_count;        /* # of zero fill pages */
+       natural_t       reactivations;          /* # of pages reactivated */
+       natural_t       pageins;                /* # of pageins */
+       natural_t       pageouts;               /* # of pageouts */
+       natural_t       faults;                 /* # of faults */
+       natural_t       cow_faults;             /* # of copy-on-writes */
+       natural_t       lookups;                /* object cache lookups */
+       natural_t       hits;                   /* object cache hits */
+
+       /* added for rev1 */
+       natural_t       purgeable_count;        /* # of pages purgeable */
+       natural_t       purges;                 /* # of pages purged */
+
+       /* added for rev2 */
+       /*
+        * NB: speculative pages are already accounted for in "free_count",
+        * so "speculative_count" is the number of "free" pages that are
+        * used to hold data that was read speculatively from disk but
+        * haven't actually been used by anyone so far.
+        */
+       natural_t       speculative_count;      /* # of pages speculative */
 };
 
 typedef struct vm_statistics   *vm_statistics_t;
@@ -90,7 +106,11 @@ typedef struct vm_statistics        vm_statistics_data_t;
 #define VM_PAGE_QUERY_PAGE_FICTITIOUS   0x2
 #define VM_PAGE_QUERY_PAGE_REF          0x4
 #define VM_PAGE_QUERY_PAGE_DIRTY        0x8
+#define VM_PAGE_QUERY_PAGE_PAGED_OUT    0x10
+#define VM_PAGE_QUERY_PAGE_COPIED       0x20
+#define VM_PAGE_QUERY_PAGE_SPECULATIVE 0x40
 
+#ifdef MACH_KERNEL_PRIVATE
 
 /*
  *     Each machine dependent implementation is expected to
@@ -101,13 +121,57 @@ typedef struct vm_statistics      vm_statistics_data_t;
 
 struct pmap_statistics {
        integer_t       resident_count; /* # of pages mapped (total)*/
+       integer_t       resident_max;   /* # of pages mapped (peak) */
        integer_t       wired_count;    /* # of pages wired */
 };
 
 typedef struct pmap_statistics *pmap_statistics_t;
 
-#define VM_FLAGS_FIXED         0x0
-#define VM_FLAGS_ANYWHERE      0x1
+#endif /* MACH_KERNEL_PRIVATE */
+
+/*
+ * VM allocation flags:
+ * 
+ * VM_FLAGS_FIXED
+ *     (really the absence of VM_FLAGS_ANYWHERE)
+ *     Allocate new VM region at the specified virtual address, if possible.
+ * 
+ * VM_FLAGS_ANYWHERE
+ *     Allocate new VM region anywhere it would fit in the address space.
+ *
+ * VM_FLAGS_PURGABLE
+ *     Create a purgable VM object for that new VM region.
+ *
+ * VM_FLAGS_NO_PMAP_CHECK
+ *     (for DEBUG kernel config only, ignored for other configs)
+ *     Do not check that there is no stale pmap mapping for the new VM region.
+ *     This is useful for kernel memory allocations at bootstrap when building
+ *     the initial kernel address space while some memory is already in use.
+ *
+ * VM_FLAGS_OVERWRITE
+ *     The new VM region can replace existing VM regions if necessary
+ *     (to be used in combination with VM_FLAGS_FIXED).
+ *
+ * VM_FLAGS_NO_CACHE
+ *     Pages brought in to this VM region are placed on the speculative
+ *     queue instead of the active queue.  In other words, they are not
+ *     cached so that they will be stolen first if memory runs low.
+ */
+#define VM_FLAGS_FIXED         0x0000
+#define VM_FLAGS_ANYWHERE      0x0001
+#define VM_FLAGS_PURGABLE      0x0002
+#define VM_FLAGS_NO_CACHE      0x0010
+
+#ifdef KERNEL_PRIVATE
+#define VM_FLAGS_NO_PMAP_CHECK 0x8000  /* do not check that pmap is empty */
+#define VM_FLAGS_OVERWRITE     0x4000  /* delete any existing mappings first */
+#define VM_FLAGS_BEYOND_MAX    0x2000  /* map beyond the map's limits */
+#define VM_FLAGS_ALREADY       0x1000  /* OK if same mapping already exists */
+#define VM_FLAGS_SUBMAP                0x0800  /* mapping a VM submap */
+#endif /* KERNEL_PRIVATE */
+#define VM_FLAGS_GUARD_BEFORE  0x0010
+#define VM_FLAGS_GUARD_AFTER   0x0020
+
 #define VM_FLAGS_ALIAS_MASK    0xFF000000
 #define VM_GET_FLAGS_ALIAS(flags, alias)                       \
                (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24 
@@ -115,11 +179,21 @@ typedef struct pmap_statistics    *pmap_statistics_t;
                (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) |   \
                (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24))
 
+/* These are the flags that we accept from user-space */
+#define VM_FLAGS_USER_ALLOCATE (VM_FLAGS_FIXED |               \
+                                VM_FLAGS_ANYWHERE |            \
+                                VM_FLAGS_PURGABLE |            \
+                                VM_FLAGS_NO_CACHE |            \
+                                VM_FLAGS_ALIAS_MASK)
+#define VM_FLAGS_USER_MAP      VM_FLAGS_USER_ALLOCATE
+
 #define VM_MEMORY_MALLOC 1
 #define VM_MEMORY_MALLOC_SMALL 2
 #define VM_MEMORY_MALLOC_LARGE 3
 #define VM_MEMORY_MALLOC_HUGE 4
 #define VM_MEMORY_SBRK 5// uninteresting -- no one should call
+#define VM_MEMORY_REALLOC 6
+#define VM_MEMORY_MALLOC_TINY 7
 
 #define VM_MEMORY_ANALYSIS_TOOL 10
 
@@ -139,7 +213,24 @@ typedef struct pmap_statistics     *pmap_statistics_t;
 #define VM_MEMORY_CARBON 43
 #define VM_MEMORY_JAVA 44
 #define VM_MEMORY_ATS 50
+#define VM_MEMORY_LAYERKIT 51
+#define VM_MEMORY_CGIMAGE 52
+#define VM_MEMORY_TCMALLOC 53
+
+/* private raster data (i.e. layers, some images, QGL allocator) */
+#define        VM_MEMORY_COREGRAPHICS_DATA     54
 
+/* shared image and font caches */
+#define VM_MEMORY_COREGRAPHICS_SHARED  55
+
+/* Memory used for virtual framebuffers, shadowing buffers, etc... */
+#define        VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS     56
+
+/* Window backing stores, custom shadow data, and compressed backing stores */
+#define VM_MEMORY_COREGRAPHICS_BACKINGSTORES   57
+
+/* catch-all for other uses, such as the read-only shared data page */
+#define VM_MEMORY_COREGRAPHICS_MISC VM_MEMORY_COREGRAPHICS
 
 /* memory allocated by the dynamic loader for itself */
 #define VM_MEMORY_DYLD 60
@@ -150,5 +241,6 @@ typedef struct pmap_statistics      *pmap_statistics_t;
 #define VM_MEMORY_APPLICATION_SPECIFIC_1 240
 #define VM_MEMORY_APPLICATION_SPECIFIC_16 255
 
-#define VM_MAKE_TAG(tag) (tag<<24)
-#endif /* VM_STATISTICS_H_ */
+#define VM_MAKE_TAG(tag) ((tag) << 24)
+
+#endif /* _MACH_VM_STATISTICS_H_ */