xref: /openbsd/sys/uvm/uvmexp.h (revision 82673a18)
1 /*	$OpenBSD: uvmexp.h,v 1.15 2024/05/01 12:54:27 mpi Exp $	*/
2 
3 #ifndef	_UVM_UVMEXP_
4 #define	_UVM_UVMEXP_
5 
6 /*
7  * CTL_VM identifiers
8  */
9 #define	VM_METER	1		/* struct vmmeter */
10 #define	VM_LOADAVG	2		/* struct loadavg */
11 #define	VM_PSSTRINGS	3		/* PSSTRINGS */
12 #define VM_UVMEXP	4		/* struct uvmexp */
13 #define VM_SWAPENCRYPT	5		/* int */
14 #define VM_NKMEMPAGES	6		/* int - # kmem_map pages */
15 #define	VM_ANONMIN	7
16 #define	VM_VTEXTMIN	8
17 #define	VM_VNODEMIN	9
18 #define	VM_MAXSLP	10
19 #define	VM_USPACE	11
20 #define	VM_MALLOC_CONF	12		/* config for userland malloc */
21 #define	VM_MAXID	13		/* number of valid vm ids */
22 
23 #define	CTL_VM_NAMES { \
24 	{ 0, 0 }, \
25 	{ "vmmeter", CTLTYPE_STRUCT }, \
26 	{ "loadavg", CTLTYPE_STRUCT }, \
27 	{ "psstrings", CTLTYPE_STRUCT }, \
28 	{ "uvmexp", CTLTYPE_STRUCT }, \
29 	{ "swapencrypt", CTLTYPE_NODE }, \
30 	{ "nkmempages", CTLTYPE_INT }, \
31 	{ "anonmin", CTLTYPE_INT }, \
32 	{ "vtextmin", CTLTYPE_INT }, \
33 	{ "vnodemin", CTLTYPE_INT }, \
34 	{ "maxslp", CTLTYPE_INT }, \
35 	{ "uspace", CTLTYPE_INT }, \
36 	{ "malloc_conf", CTLTYPE_STRING }, \
37 }
38 
39 /*
40  * uvmexp: global data structures that are exported to parts of the kernel
41  * other than the vm system.
42  *
43  *  Locks used to protect struct members in this file:
44  *	a	atomic operations
45  *	I	immutable after creation
46  *	K	kernel lock
47  *	F	uvm_lock_fpageq
48  *	L	uvm_lock_pageq
49  *	S	uvm_swap_data_lock
50  *	p	copy of per-CPU counters, used only by userland.
51  */
52 struct uvmexp {
53 	/* vm_page constants */
54 	int pagesize;   /* size of a page (PAGE_SIZE): must be power of 2 */
55 	int pagemask;   /* page mask */
56 	int pageshift;  /* page shift */
57 
58 	/* vm_page counters */
59 	int npages;     /* [I] number of pages we manage */
60 	int free;       /* [F] number of free pages */
61 	int active;     /* [L] # of active pages */
62 	int inactive;   /* [L] # of pages that we free'd but may want back */
63 	int paging;	/* number of pages in the process of being paged out */
64 	int wired;      /* number of wired pages */
65 
66 	int zeropages;		/* [F] number of zero'd pages */
67 	int reserve_pagedaemon; /* [I] # of pages reserved for pagedaemon */
68 	int reserve_kernel;	/* [I] # of pages reserved for kernel */
69 	int percpucaches;	/* [a] # of pages in per-CPU caches */
70 	int vnodepages;		/* XXX # of pages used by vnode page cache */
71 	int vtextpages;		/* XXX # of pages used by vtext vnodes */
72 
73 	/* pageout params */
74 	int freemin;    /* [I] min number of free pages */
75 	int freetarg;   /* [I] target number of free pages */
76 	int inactarg;   /* target number of inactive pages */
77 	int wiredmax;   /* [I] max number of wired pages */
78 	int anonmin;	/* min threshold for anon pages */
79 	int vtextmin;	/* min threshold for vtext pages */
80 	int vnodemin;	/* min threshold for vnode pages */
81 	int anonminpct;	/* min percent anon pages */
82 	int vtextminpct;/* min percent vtext pages */
83 	int vnodeminpct;/* min percent vnode pages */
84 
85 	/* swap */
86 	int nswapdev;	/* [S] number of configured swap devices in system */
87 	int swpages;	/* [S] number of PAGE_SIZE'ed swap pages */
88 	int swpginuse;	/* [S] number of swap pages in use */
89 	int swpgonly;	/* [a] number of swap pages in use, not also in RAM */
90 	int nswget;	/* [a] number of swap pages moved from disk to RAM */
91 	int nanon;	/* XXX number total of anon's in system */
92 	int unused05;	/* formerly nanonneeded */
93 	int unused06;	/* formerly nfreeanon */
94 
95 	/* stat counters */
96 	int faults;		/* [p] page fault count */
97 	int traps;		/* trap count */
98 	int intrs;		/* interrupt count */
99 	int swtch;		/* context switch count */
100 	int softs;		/* software interrupt count */
101 	int syscalls;		/* system calls */
102 	int pageins;		/* [p] pagein operation count */
103 				/* pageouts are in pdpageouts below */
104 	int pcphit;		/* [a] # of pagealloc from per-CPU cache */
105 	int pcpmiss;		/* [a] # of times a per-CPU cache was empty */
106 	int pgswapin;		/* pages swapped in */
107 	int pgswapout;		/* pages swapped out */
108 	int forks;  		/* forks */
109 	int forks_ppwait;	/* forks where parent waits */
110 	int forks_sharevm;	/* forks where vmspace is shared */
111 	int pga_zerohit;	/* pagealloc where zero wanted and zero
112 				   was available */
113 	int pga_zeromiss;	/* pagealloc where zero wanted and zero
114 				   not available */
115 	int unused09;		/* formerly zeroaborts */
116 
117 	/* fault subcounters */
118 	int fltnoram;	/* [p] # of times fault was out of ram */
119 	int fltnoanon;	/* [p] # of times fault was out of anons */
120 	int fltnoamap;	/* [p] # of times fault was out of amap chunks */
121 	int fltpgwait;	/* [p] # of times fault had to wait on a page */
122 	int fltpgrele;	/* [p] # of times fault found a released page */
123 	int fltrelck;	/* [p] # of times fault relock called */
124 	int fltrelckok;	/* [p] # of times fault relock is a success */
125 	int fltanget;	/* [p] # of times fault gets anon page */
126 	int fltanretry;	/* [p] # of times fault retrys an anon get */
127 	int fltamcopy;	/* [p] # of times fault clears "needs copy" */
128 	int fltnamap;	/* [p] # of times fault maps a neighbor anon page */
129 	int fltnomap;	/* [p] # of times fault maps a neighbor obj page */
130 	int fltlget;	/* [p] # of times fault does a locked pgo_get */
131 	int fltget;	/* [p] # of times fault does an unlocked get */
132 	int flt_anon;	/* [p] # of times fault anon (case 1a) */
133 	int flt_acow;	/* [p] # of times fault anon cow (case 1b) */
134 	int flt_obj;	/* [p] # of times fault is on object page (2a) */
135 	int flt_prcopy;	/* [p] # of times fault promotes with copy (2b) */
136 	int flt_przero;	/* [p] # of times fault promotes with zerofill (2b) */
137 
138 	/* daemon counters */
139 	int pdwoke;	/* [F] # of times daemon woke up */
140 	int pdrevs;	/* number of times daemon rev'd clock hand */
141 	int pdswout;	/* number of times daemon called for swapout */
142 	int pdfreed;	/* number of pages daemon freed since boot */
143 	int pdscans;	/* number of pages daemon scanned since boot */
144 	int pdanscan;	/* number of anonymous pages scanned by daemon */
145 	int pdobscan;	/* number of object pages scanned by daemon */
146 	int pdreact;	/* number of pages daemon reactivated since boot */
147 	int pdbusy;	/* number of times daemon found a busy page */
148 	int pdpageouts;	/* number of times daemon started a pageout */
149 	int pdpending;	/* number of times daemon got a pending pagout */
150 	int pddeact;	/* number of pages daemon deactivates */
151 	int unused11;	/* formerly pdreanon */
152 	int unused12;	/* formerly pdrevnode */
153 	int unused13;	/* formerly pdrevtext */
154 
155 	int fpswtch;	/* FPU context switches */
156 	int kmapent;	/* number of kernel map entries */
157 };
158 
159 struct _ps_strings {
160 	void	*val;
161 };
162 
163 #ifdef _KERNEL
164 
165 /*
166  * Per-cpu UVM counters.
167  */
168 extern struct cpumem *uvmexp_counters;
169 
170 enum uvm_exp_counters {
171 	/* stat counters */
172 	faults,		/* page fault count */
173 	pageins,	/* pagein operation count */
174 
175 	/* fault subcounters */
176 	flt_noram,	/* number of times fault was out of ram */
177 	flt_noanon,	/* number of times fault was out of anons */
178 	flt_noamap,	/* number of times fault was out of amap chunks */
179 	flt_pgwait,	/* number of times fault had to wait on a page */
180 	flt_pgrele,	/* number of times fault found a released page */
181 	flt_relck,	/* number of times fault relock called */
182 	flt_relckok,	/* number of times fault relock is a success */
183 	flt_anget,	/* number of times fault gets anon page */
184 	flt_anretry,	/* number of times fault retrys an anon get */
185 	flt_amcopy,	/* number of times fault clears "needs copy" */
186 	flt_namap,	/* number of times fault maps a neighbor anon page */
187 	flt_nomap,	/* number of times fault maps a neighbor obj page */
188 	flt_lget,	/* number of times fault does a locked pgo_get */
189 	flt_get,	/* number of times fault does an unlocked get */
190 	flt_anon,	/* number of times fault anon (case 1a) */
191 	flt_acow,	/* number of times fault anon cow (case 1b) */
192 	flt_obj,	/* number of times fault is on object page (2a) */
193 	flt_prcopy,	/* number of times fault promotes with copy (2b) */
194 	flt_przero,	/* number of times fault promotes with zerofill (2b) */
195 
196 	exp_ncounters
197 };
198 
199 #endif /* _KERNEL */
200 #endif /*_UVM_UVMEXP_ */
201