X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/a39ff7e25e19b3a8c3020042a3872ca9ec9659f1..ea3f04195ba4a5034c9c8e9b726d4f7ce96f1832:/osfmk/mach/vm_statistics.h diff --git a/osfmk/mach/vm_statistics.h b/osfmk/mach/vm_statistics.h index 04fafe640..267d5df2f 100644 --- a/osfmk/mach/vm_statistics.h +++ b/osfmk/mach/vm_statistics.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2000-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2019 Apple 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 @@ -11,10 +11,10 @@ * 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 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -22,34 +22,34 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * @OSF_COPYRIGHT@ */ -/* +/* * Mach Operating System * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -63,8 +63,8 @@ * */ -#ifndef _MACH_VM_STATISTICS_H_ -#define _MACH_VM_STATISTICS_H_ +#ifndef _MACH_VM_STATISTICS_H_ +#define _MACH_VM_STATISTICS_H_ #include @@ -73,31 +73,31 @@ * vm_statistics * * History: - * rev0 - original structure. - * rev1 - added purgable info (purgable_count and purges). - * rev2 - added speculative_count. + * 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. + * vm_statistics64. */ struct vm_statistics { - 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 */ + 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 */ + natural_t purgeable_count; /* # of pages purgeable */ + natural_t purges; /* # of pages purged */ /* added for rev2 */ /* @@ -106,23 +106,23 @@ struct vm_statistics { * 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 */ + 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; +typedef struct vm_statistics *vm_statistics_t; +typedef struct vm_statistics vm_statistics_data_t; -/* +/* * vm_statistics64 * * History: - * rev0 - original structure. - * rev1 - added purgable info (purgable_count and purges). - * rev2 - added speculative_count. + * 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 + * 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. @@ -130,44 +130,44 @@ typedef struct vm_statistics vm_statistics_data_t; */ 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 */ - 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 */ - uint64_t purges; /* # of pages purged */ - natural_t purgeable_count; /* # of pages purgeable */ + 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 */ + 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 */ + uint64_t purges; /* # of pages purged */ + natural_t purgeable_count; /* # of pages purgeable */ /* * 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 */ + natural_t speculative_count; /* # of pages speculative */ /* added for rev1 */ - uint64_t decompressions; /* # of pages decompressed */ - uint64_t compressions; /* # of pages compressed */ - uint64_t swapins; /* # of pages swapped in (via compression segments) */ - uint64_t swapouts; /* # of pages swapped out (via compression segments) */ - natural_t compressor_page_count; /* # of pages used by the compressed pager to hold all the compressed data */ - natural_t throttled_count; /* # of pages throttled */ - natural_t external_page_count; /* # of pages that are file-backed (non-swap) */ - natural_t internal_page_count; /* # of pages that are anonymous */ - uint64_t total_uncompressed_pages_in_compressor; /* # of pages (uncompressed) held within the compressor. */ + uint64_t decompressions; /* # of pages decompressed */ + uint64_t compressions; /* # of pages compressed */ + uint64_t swapins; /* # of pages swapped in (via compression segments) */ + uint64_t swapouts; /* # of pages swapped out (via compression segments) */ + natural_t compressor_page_count; /* # of pages used by the compressed pager to hold all the compressed data */ + natural_t throttled_count; /* # of pages throttled */ + natural_t external_page_count; /* # of pages that are file-backed (non-swap) */ + natural_t internal_page_count; /* # of pages that are anonymous */ + uint64_t total_uncompressed_pages_in_compressor; /* # of pages (uncompressed) held within the compressor. */ } __attribute__((aligned(8))); -typedef struct vm_statistics64 *vm_statistics64_t; -typedef struct vm_statistics64 vm_statistics64_data_t; +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 @@ -175,31 +175,31 @@ typedef struct vm_statistics64 vm_statistics64_data_t; */ #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. + * 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 */ + 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_purgeable_stat { - uint64_t count; - uint64_t size; + uint64_t count; + uint64_t size; }vm_purgeable_stat_t; struct vm_purgeable_info { @@ -208,7 +208,7 @@ struct vm_purgeable_info { vm_purgeable_stat_t lifo_data[8]; }; -typedef struct vm_purgeable_info *vm_purgeable_info_t; +typedef struct vm_purgeable_info *vm_purgeable_info_t; /* included for the vm_map_page_query call */ @@ -218,13 +218,14 @@ typedef struct vm_purgeable_info *vm_purgeable_info_t; #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 -#define VM_PAGE_QUERY_PAGE_CS_NX 0x400 +#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 +#define VM_PAGE_QUERY_PAGE_CS_NX 0x400 +#define VM_PAGE_QUERY_PAGE_REUSABLE 0x800 -#ifdef MACH_KERNEL_PRIVATE +#ifdef MACH_KERNEL_PRIVATE /* * Each machine dependent implementation is expected to @@ -234,41 +235,41 @@ typedef struct vm_purgeable_info *vm_purgeable_info_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 */ - - integer_t device; - integer_t device_peak; - integer_t internal; - integer_t internal_peak; - integer_t external; - integer_t external_peak; - integer_t reusable; - integer_t reusable_peak; - uint64_t compressed __attribute__((aligned(8))); - uint64_t compressed_peak __attribute__((aligned(8))); - uint64_t compressed_lifetime __attribute__((aligned(8))); + integer_t resident_count; /* # of pages mapped (total)*/ + integer_t resident_max; /* # of pages mapped (peak) */ + integer_t wired_count; /* # of pages wired */ + + integer_t device; + integer_t device_peak; + integer_t internal; + integer_t internal_peak; + integer_t external; + integer_t external_peak; + integer_t reusable; + integer_t reusable_peak; + uint64_t compressed __attribute__((aligned(8))); + uint64_t compressed_peak __attribute__((aligned(8))); + uint64_t compressed_lifetime __attribute__((aligned(8))); }; -typedef struct pmap_statistics *pmap_statistics_t; +typedef struct pmap_statistics *pmap_statistics_t; -#define PMAP_STATS_PEAK(field) \ - MACRO_BEGIN \ - if (field > field##_peak) { \ - field##_peak = field; \ - } \ +#define PMAP_STATS_PEAK(field) \ + MACRO_BEGIN \ + if (field > field##_peak) { \ + field##_peak = field; \ + } \ MACRO_END -#endif /* MACH_KERNEL_PRIVATE */ +#endif /* MACH_KERNEL_PRIVATE */ /* * VM allocation flags: - * + * * VM_FLAGS_FIXED - * (really the absence of VM_FLAGS_ANYWHERE) + * (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. * @@ -294,101 +295,151 @@ typedef struct pmap_statistics *pmap_statistics_t; * 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_4GB_CHUNK 0x0004 -#define VM_FLAGS_RANDOM_ADDR 0x0008 -#define VM_FLAGS_NO_CACHE 0x0010 -#define VM_FLAGS_RESILIENT_CODESIGN 0x0020 -#define VM_FLAGS_RESILIENT_MEDIA 0x0040 -#define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */ +#define VM_FLAGS_FIXED 0x0000 +#define VM_FLAGS_ANYWHERE 0x0001 +#define VM_FLAGS_PURGABLE 0x0002 +#define VM_FLAGS_4GB_CHUNK 0x0004 +#define VM_FLAGS_RANDOM_ADDR 0x0008 +#define VM_FLAGS_NO_CACHE 0x0010 +#define VM_FLAGS_RESILIENT_CODESIGN 0x0020 +#define VM_FLAGS_RESILIENT_MEDIA 0x0040 +#define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */ /* * 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_RETURN_DATA_ADDR 0x100000 /* Return address of target data, rather than base of page */ -#define VM_FLAGS_RETURN_4K_DATA_ADDR 0x800000 /* Return 4K aligned address of target data */ -#define VM_FLAGS_ALIAS_MASK 0xFF000000 -#define VM_GET_FLAGS_ALIAS(flags, alias) \ - (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24 +#define VM_FLAGS_SUPERPAGE_MASK 0x70000 /* bits 0x10000, 0x20000, 0x40000 */ +#define VM_FLAGS_RETURN_DATA_ADDR 0x100000 /* Return address of target data, rather than base of page */ +#define VM_FLAGS_RETURN_4K_DATA_ADDR 0x800000 /* Return 4K aligned address of target data */ +#define VM_FLAGS_ALIAS_MASK 0xFF000000 +#define VM_GET_FLAGS_ALIAS(flags, alias) \ + (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24 #if !XNU_KERNEL_PRIVATE -#define VM_SET_FLAGS_ALIAS(flags, alias) \ - (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) | \ - (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24)) +#define VM_SET_FLAGS_ALIAS(flags, alias) \ + (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) | \ + (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24)) #endif /* !XNU_KERNEL_PRIVATE */ /* 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_4GB_CHUNK | \ - VM_FLAGS_RANDOM_ADDR | \ - VM_FLAGS_NO_CACHE | \ - VM_FLAGS_OVERWRITE | \ - VM_FLAGS_SUPERPAGE_MASK | \ - VM_FLAGS_ALIAS_MASK) -#define VM_FLAGS_USER_MAP (VM_FLAGS_USER_ALLOCATE | \ - VM_FLAGS_RETURN_4K_DATA_ADDR | \ - VM_FLAGS_RETURN_DATA_ADDR) -#define VM_FLAGS_USER_REMAP (VM_FLAGS_FIXED | \ - VM_FLAGS_ANYWHERE | \ - VM_FLAGS_RANDOM_ADDR | \ - VM_FLAGS_OVERWRITE| \ - VM_FLAGS_RETURN_DATA_ADDR |\ - VM_FLAGS_RESILIENT_CODESIGN) +#define VM_FLAGS_USER_ALLOCATE (VM_FLAGS_FIXED | \ + VM_FLAGS_ANYWHERE | \ + VM_FLAGS_PURGABLE | \ + VM_FLAGS_4GB_CHUNK | \ + VM_FLAGS_RANDOM_ADDR | \ + VM_FLAGS_NO_CACHE | \ + VM_FLAGS_OVERWRITE | \ + VM_FLAGS_SUPERPAGE_MASK | \ + VM_FLAGS_ALIAS_MASK) +#define VM_FLAGS_USER_MAP (VM_FLAGS_USER_ALLOCATE | \ + VM_FLAGS_RETURN_4K_DATA_ADDR | \ + VM_FLAGS_RETURN_DATA_ADDR) +#define VM_FLAGS_USER_REMAP (VM_FLAGS_FIXED | \ + VM_FLAGS_ANYWHERE | \ + VM_FLAGS_RANDOM_ADDR | \ + VM_FLAGS_OVERWRITE| \ + VM_FLAGS_RETURN_DATA_ADDR | \ + VM_FLAGS_RESILIENT_CODESIGN | \ + VM_FLAGS_RESILIENT_MEDIA) #define VM_FLAGS_SUPERPAGE_SHIFT 16 -#define SUPERPAGE_NONE 0 /* no superpages, if all bits are 0 */ -#define SUPERPAGE_SIZE_ANY 1 +#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 SUPERPAGE_SIZE_2MB 2 #define VM_FLAGS_SUPERPAGE_SIZE_2MB (SUPERPAGE_SIZE_2MB<