xref: /NextBSD/sys/sys/mach/vm_statistics.h (revision 33da5adc555b3bc29986eeadca03829e4ad06b1e)
1 /*
2  * Copyright 1991-1998 by Open Software Foundation, Inc.
3  *              All Rights Reserved
4  *
5  * Permission to use, copy, modify, and distribute this software and
6  * its documentation for any purpose and without fee is hereby granted,
7  * provided that the above copyright notice appears in all copies and
8  * that both the copyright notice and this permission notice appear in
9  * supporting documentation.
10  *
11  * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
12  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13  * FOR A PARTICULAR PURPOSE.
14  *
15  * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
16  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17  * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
18  * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
19  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  */
21 /*
22  * MkLinux
23  */
24 /* CMU_HIST */
25 /*
26  * Revision 2.3  91/05/14  17:03:07  mrt
27  * 	Correcting copyright
28  *
29  * Revision 2.2  91/02/05  17:37:41  mrt
30  * 	Changed to new Mach copyright
31  * 	[91/02/01  17:22:49  mrt]
32  *
33  * Revision 2.1  89/08/03  16:06:55  rwd
34  * Created.
35  *
36  * Revision 2.4  89/02/25  18:42:35  gm0w
37  * 	Changes for cleanup.
38  *
39  * Revision 2.3  89/02/07  00:54:39  mwyoung
40  * Relocated from sys/vm_statistics.h
41  *
42  * Revision 2.2  89/01/30  22:08:54  rpd
43  * 	Made variable declarations use "extern".
44  * 	[89/01/25  15:26:30  rpd]
45  *
46  * 30-Sep-86  Avadis Tevanian (avie) at Carnegie-Mellon University
47  *	Changed "reclaim" to "inactive."
48  *
49  * 22-Aug-86  Michael Young (mwyoung) at Carnegie-Mellon University
50  *	Made vm_stat structure kernel-only.
51  *
52  * 22-May-86  Avadis Tevanian (avie) at Carnegie-Mellon University
53  *	Defined vm_statistics_data_t as a real typedef so that
54  *	MatchMaker can deal with it.
55  *
56  * 14-Feb-86  Avadis Tevanian (avie) at Carnegie-Mellon University
57  *	Created.
58  *
59  */
60 /* CMU_ENDHIST */
61 /*
62  * Mach Operating System
63  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
64  * All Rights Reserved.
65  *
66  * Permission to use, copy, modify and distribute this software and its
67  * documentation is hereby granted, provided that both the copyright
68  * notice and this permission notice appear in all copies of the
69  * software, derivative works or modified versions, and any portions
70  * thereof, and that both notices appear in supporting documentation.
71  *
72  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
73  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
74  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
75  *
76  * Carnegie Mellon requests users of this software to return to
77  *
78  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
79  *  School of Computer Science
80  *  Carnegie Mellon University
81  *  Pittsburgh PA 15213-3890
82  *
83  * any improvements or extensions that they make and grant Carnegie Mellon
84  * the rights to redistribute these changes.
85  */
86 /*
87  */
88 /*
89  *	File:	mach/vm_statistics.h
90  *	Author:	Avadis Tevanian, Jr., Michael Wayne Young, David Golub
91  *
92  *	Virtual memory statistics structure.
93  *
94  */
95 
96 #ifndef	VM_STATISTICS_H_
97 #define	VM_STATISTICS_H_
98 
99 #include <sys/mach/vm_types.h>
100 
101 struct vm_statistics {
102 	integer_t	free_count;		/* # of pages free */
103 	integer_t	active_count;		/* # of pages active */
104 	integer_t	inactive_count;		/* # of pages inactive */
105 	integer_t	wire_count;		/* # of pages wired down */
106 	integer_t	zero_fill_count;	/* # of zero fill pages */
107 	integer_t	reactivations;		/* # of pages reactivated */
108 	integer_t	pageins;		/* # of pageins */
109 	integer_t	pageouts;		/* # of pageouts */
110 	integer_t	faults;			/* # of faults */
111 	integer_t	cow_faults;		/* # of copy-on-writes */
112 	integer_t	lookups;		/* object cache lookups */
113 	integer_t	hits;			/* object cache hits */
114 
115 	integer_t       purgeable_count;        /* # of pages purgeable */
116 	integer_t       purges;                 /* # of pages purged */
117 
118 };
119 
120 typedef struct vm_statistics	*vm_statistics_t;
121 typedef struct vm_statistics	vm_statistics_data_t;
122 
123 struct vm_extmod_statistics {
124         int64_t task_for_pid_count;                     /* # of times task port was looked up */
125         int64_t task_for_pid_caller_count;      /* # of times this task called task_for_pid */
126         int64_t thread_creation_count;          /* # of threads created in task */
127         int64_t thread_creation_caller_count;   /* # of threads created by task */
128         int64_t thread_set_state_count;         /* # of register state sets in task */
129         int64_t thread_set_state_caller_count;  /* # of register state sets by task */
130 } __attribute__((aligned(8)));
131 
132 typedef struct vm_extmod_statistics *vm_extmod_statistics_t;
133 typedef struct vm_extmod_statistics vm_extmod_statistics_data_t;
134 
135 typedef struct vm_purgeable_stat {
136         uint64_t        count;
137         uint64_t        size;
138 }vm_purgeable_stat_t;
139 
140 struct vm_purgeable_info {
141         vm_purgeable_stat_t fifo_data[8];
142         vm_purgeable_stat_t obsolete_data;
143         vm_purgeable_stat_t lifo_data[8];
144 };
145 
146 typedef struct vm_purgeable_info        *vm_purgeable_info_t;
147 
148 
149 /*
150  * VM allocation flags:
151  *
152  * VM_FLAGS_FIXED
153  *      (really the absence of VM_FLAGS_ANYWHERE)
154  *      Allocate new VM region at the specified virtual address, if possible.
155  *
156  * VM_FLAGS_ANYWHERE
157  *      Allocate new VM region anywhere it would fit in the address space.
158  *
159  * VM_FLAGS_PURGABLE
160  *      Create a purgable VM object for that new VM region.
161  *
162  * VM_FLAGS_NO_PMAP_CHECK
163  *      (for DEBUG kernel config only, ignored for other configs)
164  *      Do not check that there is no stale pmap mapping for the new VM region.
165  *      This is useful for kernel memory allocations at bootstrap when building
166  *      the initial kernel address space while some memory is already in use.
167  *
168  * VM_FLAGS_OVERWRITE
169  *      The new VM region can replace existing VM regions if necessary
170  *      (to be used in combination with VM_FLAGS_FIXED).
171  *
172  * VM_FLAGS_NO_CACHE
173  *      Pages brought in to this VM region are placed on the speculative
174  *      queue instead of the active queue.  In other words, they are not
175  *      cached so that they will be stolen first if memory runs low.
176  */
177 #define VM_FLAGS_FIXED          0x0000
178 #define VM_FLAGS_ANYWHERE       0x0001
179 #define VM_FLAGS_PURGABLE       0x0002
180 #define VM_FLAGS_NO_CACHE       0x0010
181 #define VM_FLAGS_OVERWRITE      0x4000  /* delete any existing mappings first */
182 /*
183  * VM_FLAGS_SUPERPAGE_MASK
184  *      3 bits that specify whether large pages should be used instead of
185  *      base pages (!=0), as well as the requested page size.
186  */
187 #define VM_FLAGS_SUPERPAGE_MASK 0x70000 /* bits 0x10000, 0x20000, 0x40000 */
188 #define VM_FLAGS_RETURN_DATA_ADDR       0x100000 /* Return address of target data, rather than base of page */
189 #define VM_FLAGS_ALIAS_MASK     0xFF000000
190 #define VM_GET_FLAGS_ALIAS(flags, alias)                        \
191                 (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24
192 #define VM_SET_FLAGS_ALIAS(flags, alias)                        \
193                 (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) |   \
194                 (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24))
195 
196 /* These are the flags that we accept from user-space */
197 #define VM_FLAGS_USER_ALLOCATE  (VM_FLAGS_FIXED |               \
198                                  VM_FLAGS_ANYWHERE |            \
199                                  VM_FLAGS_PURGABLE |            \
200                                  VM_FLAGS_NO_CACHE |            \
201                                  VM_FLAGS_OVERWRITE |           \
202                                  VM_FLAGS_SUPERPAGE_MASK |      \
203                                  VM_FLAGS_ALIAS_MASK)
204 #define VM_FLAGS_USER_MAP       (VM_FLAGS_USER_ALLOCATE |       \
205                                  VM_FLAGS_RETURN_DATA_ADDR)
206 #define VM_FLAGS_USER_REMAP     (VM_FLAGS_FIXED |    \
207                                  VM_FLAGS_ANYWHERE | \
208                                  VM_FLAGS_OVERWRITE| \
209                                  VM_FLAGS_RETURN_DATA_ADDR)
210 
211 /*
212  *	Each machine dependent implementation is expected to
213  *	keep certain statistics.  They may do this anyway they
214  *	so choose, but are expected to return the statistics
215  *	in the following structure.
216  */
217 #if 0
218 struct pmap_statistics {
219 	integer_t	resident_count;	/* # of pages mapped (total)*/
220 	integer_t	wired_count;	/* # of pages wired */
221 };
222 
223 typedef struct pmap_statistics	*pmap_statistics_t;
224 #endif
225 #endif	/* VM_STATISTICS_H_ */
226