X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/8f6c56a50524aa785f7e596d52dddfb331e18961..316670eb35587141e969394ae8537d66b9211e80:/osfmk/mach/vm_statistics.h diff --git a/osfmk/mach/vm_statistics.h b/osfmk/mach/vm_statistics.h index cdcd19405..487549894 100644 --- a/osfmk/mach/vm_statistics.h +++ b/osfmk/mach/vm_statistics.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2009 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -68,6 +68,19 @@ #include + +/* + * vm_statistics + * + * History: + * rev0 - original structure. + * rev1 - added purgable info (purgable_count and purges). + * rev2 - added speculative_count. + * + * Note: you cannot add any new fields to this structure. Add them below in + * vm_statistics64. + */ + struct vm_statistics { natural_t free_count; /* # of pages free */ natural_t active_count; /* # of pages active */ @@ -82,30 +95,102 @@ struct vm_statistics { 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 */ }; +/* Used by all architectures */ typedef struct vm_statistics *vm_statistics_t; typedef struct vm_statistics vm_statistics_data_t; -struct vm_statistics_rev0 { +/* + * vm_statistics64 + * + * History: + * rev0 - original structure. + * rev1 - added purgable info (purgable_count and purges). + * rev2 - added speculative_count. + * ---- + * rev3 - changed name to vm_statistics64. + * changed some fields in structure to 64-bit on + * arm, i386 and x86_64 architectures. + * rev4 - require 64-bit alignment for efficient access + * in the kernel. No change to reported data. + * + */ + +struct vm_statistics64 { 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 */ -}; + uint64_t zero_fill_count; /* # of zero fill pages */ + uint64_t reactivations; /* # of pages reactivated */ + uint64_t pageins; /* # of pageins */ + uint64_t pageouts; /* # of pageouts */ + uint64_t faults; /* # of faults */ + uint64_t cow_faults; /* # of copy-on-writes */ + uint64_t lookups; /* object cache lookups */ + uint64_t hits; /* object cache hits */ + + /* added for rev1 */ + uint64_t purges; /* # of pages purged */ + natural_t purgeable_count; /* # of pages purgeable */ + + /* 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 */ + +} __attribute__((aligned(8))); + +typedef struct vm_statistics64 *vm_statistics64_t; +typedef struct vm_statistics64 vm_statistics64_data_t; + +/* + * VM_STATISTICS_TRUNCATE_TO_32_BIT + * + * This is used by host_statistics() to truncate and peg the 64-bit in-kernel values from + * vm_statistics64 to the 32-bit values of the older structure above (vm_statistics). + */ +#define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) ((uint32_t)(((value) > UINT32_MAX ) ? UINT32_MAX : (value))) + +/* + * vm_extmod_statistics + * + * Structure to record modifications to a task by an + * external agent. + * + * History: + * rev0 - original structure. + */ + +struct vm_extmod_statistics { + int64_t task_for_pid_count; /* # of times task port was looked up */ + int64_t task_for_pid_caller_count; /* # of times this task called task_for_pid */ + int64_t thread_creation_count; /* # of threads created in task */ + int64_t thread_creation_caller_count; /* # of threads created by task */ + int64_t thread_set_state_count; /* # of register state sets in task */ + int64_t thread_set_state_caller_count; /* # of register state sets by task */ +} __attribute__((aligned(8))); + +typedef struct vm_extmod_statistics *vm_extmod_statistics_t; +typedef struct vm_extmod_statistics vm_extmod_statistics_data_t; -typedef struct vm_statistics_rev0 *vm_statistics_rev0_t; -typedef struct vm_statistics_rev0 vm_statistics_rev0_data_t; /* included for the vm_map_page_query call */ @@ -113,6 +198,12 @@ typedef struct vm_statistics_rev0 vm_statistics_rev0_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 +#define VM_PAGE_QUERY_PAGE_EXTERNAL 0x80 +#define VM_PAGE_QUERY_PAGE_CS_VALIDATED 0x100 +#define VM_PAGE_QUERY_PAGE_CS_TAINTED 0x200 #ifdef MACH_KERNEL_PRIVATE @@ -125,6 +216,7 @@ typedef struct vm_statistics_rev0 vm_statistics_rev0_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 */ }; @@ -154,14 +246,46 @@ typedef struct pmap_statistics *pmap_statistics_t; * 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 0x0004 +#define VM_FLAGS_PERMANENT 0x0100 /* mapping can NEVER be unmapped */ +#define VM_FLAGS_GUARD_AFTER 0x0200 /* guard page after the mapping */ +#define VM_FLAGS_GUARD_BEFORE 0x0400 /* guard page before the mapping */ +#define VM_FLAGS_SUBMAP 0x0800 /* mapping a VM submap */ +#define VM_FLAGS_ALREADY 0x1000 /* OK if same mapping already exists */ +#define VM_FLAGS_BEYOND_MAX 0x2000 /* map beyond the map's max offset */ #endif /* KERNEL_PRIVATE */ -#define VM_FLAGS_OVERWRITE 0x0008 +#define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */ +#ifdef KERNEL_PRIVATE +#define VM_FLAGS_NO_PMAP_CHECK 0x8000 /* do not check that pmap is empty */ +#define VM_FLAGS_MAP_JIT 0x80000 /* Used to mark an entry as describing a JIT region */ +#endif /* KERNEL_PRIVATE */ + +/* + * VM_FLAGS_SUPERPAGE_MASK + * 3 bits that specify whether large pages should be used instead of + * base pages (!=0), as well as the requested page size. + */ +#define VM_FLAGS_SUPERPAGE_MASK 0x70000 /* bits 0x10000, 0x20000, 0x40000 */ +#define VM_FLAGS_SUPERPAGE_SHIFT 16 + +#define SUPERPAGE_NONE 0 /* no superpages, if all bits are 0 */ +#define SUPERPAGE_SIZE_ANY 1 +#define VM_FLAGS_SUPERPAGE_NONE (SUPERPAGE_NONE << VM_FLAGS_SUPERPAGE_SHIFT) +#define VM_FLAGS_SUPERPAGE_SIZE_ANY (SUPERPAGE_SIZE_ANY << VM_FLAGS_SUPERPAGE_SHIFT) +#if defined(__x86_64__) || !defined(KERNEL) +#define SUPERPAGE_SIZE_2MB 2 +#define VM_FLAGS_SUPERPAGE_SIZE_2MB (SUPERPAGE_SIZE_2MB<