xref: /titanic_41/usr/src/uts/common/sys/sysinfo.h (revision 2449e17f82f6097fd2c665b64723e31ceecbeca6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #ifndef _SYS_SYSINFO_H
32 #define	_SYS_SYSINFO_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 11.14 */
35 
36 #include <sys/types.h>
37 #include <sys/t_lock.h>
38 #include <sys/kstat.h>
39 #include <sys/machlock.h>
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 /*
46  *	System Information.
47  */
48 #define	CPU_IDLE	0
49 #define	CPU_USER	1
50 #define	CPU_KERNEL	2
51 #define	CPU_WAIT	3
52 #define	CPU_STATES	4
53 
54 #define	W_IO		0
55 #define	W_SWAP		1
56 #define	W_PIO		2
57 #define	W_STATES	3
58 
59 typedef struct cpu_sysinfo {
60 	uint_t	cpu[CPU_STATES]; /* CPU utilization			*/
61 	uint_t	wait[W_STATES];	/* CPU wait time breakdown		*/
62 	uint_t	bread;		/* physical block reads			*/
63 	uint_t	bwrite;		/* physical block writes (sync+async)	*/
64 	uint_t	lread;		/* logical block reads			*/
65 	uint_t	lwrite;		/* logical block writes			*/
66 	uint_t	phread;		/* raw I/O reads			*/
67 	uint_t	phwrite;	/* raw I/O writes			*/
68 	uint_t	pswitch;	/* context switches			*/
69 	uint_t	trap;		/* traps				*/
70 	uint_t	intr;		/* device interrupts			*/
71 	uint_t	syscall;	/* system calls				*/
72 	uint_t	sysread;	/* read() + readv() system calls	*/
73 	uint_t	syswrite;	/* write() + writev() system calls	*/
74 	uint_t	sysfork;	/* forks				*/
75 	uint_t	sysvfork;	/* vforks				*/
76 	uint_t	sysexec;	/* execs				*/
77 	uint_t	readch;		/* bytes read by rdwr()			*/
78 	uint_t	writech;	/* bytes written by rdwr()		*/
79 	uint_t	rcvint;		/* XXX: UNUSED				*/
80 	uint_t	xmtint;		/* XXX: UNUSED				*/
81 	uint_t	mdmint;		/* XXX: UNUSED				*/
82 	uint_t	rawch;		/* terminal input characters		*/
83 	uint_t	canch;		/* chars handled in canonical mode	*/
84 	uint_t	outch;		/* terminal output characters		*/
85 	uint_t	msg;		/* msg count (msgrcv()+msgsnd() calls)	*/
86 	uint_t	sema;		/* semaphore ops count (semop() calls)	*/
87 	uint_t	namei;		/* pathname lookups			*/
88 	uint_t	ufsiget;	/* ufs_iget() calls			*/
89 	uint_t	ufsdirblk;	/* directory blocks read		*/
90 	uint_t	ufsipage;	/* inodes taken with attached pages	*/
91 	uint_t	ufsinopage;	/* inodes taked with no attached pages	*/
92 	uint_t	inodeovf;	/* inode table overflows		*/
93 	uint_t	fileovf;	/* file table overflows			*/
94 	uint_t	procovf;	/* proc table overflows			*/
95 	uint_t	intrthread;	/* interrupts as threads (below clock)	*/
96 	uint_t	intrblk;	/* intrs blkd/prempted/released (swtch)	*/
97 	uint_t	idlethread;	/* times idle thread scheduled		*/
98 	uint_t	inv_swtch;	/* involuntary context switches		*/
99 	uint_t	nthreads;	/* thread_create()s			*/
100 	uint_t	cpumigrate;	/* cpu migrations by threads 		*/
101 	uint_t	xcalls;		/* xcalls to other cpus 		*/
102 	uint_t	mutex_adenters;	/* failed mutex enters (adaptive)	*/
103 	uint_t	rw_rdfails;	/* rw reader failures			*/
104 	uint_t	rw_wrfails;	/* rw writer failures			*/
105 	uint_t	modload;	/* times loadable module loaded		*/
106 	uint_t	modunload;	/* times loadable module unloaded 	*/
107 	uint_t	bawrite;	/* physical block writes (async)	*/
108 /* Following are gathered only under #ifdef STATISTICS in source 	*/
109 	uint_t	rw_enters;	/* tries to acquire rw lock		*/
110 	uint_t	win_uo_cnt;	/* reg window user overflows		*/
111 	uint_t	win_uu_cnt;	/* reg window user underflows		*/
112 	uint_t	win_so_cnt;	/* reg window system overflows		*/
113 	uint_t	win_su_cnt;	/* reg window system underflows		*/
114 	uint_t	win_suo_cnt;	/* reg window system user overflows	*/
115 } cpu_sysinfo_t;
116 
117 typedef struct sysinfo {	/* (update freq) update action		*/
118 	uint_t	updates;	/* (1 sec) ++				*/
119 	uint_t	runque;		/* (1 sec) += num runnable procs	*/
120 	uint_t	runocc;		/* (1 sec) ++ if num runnable procs > 0	*/
121 	uint_t	swpque;		/* (1 sec) += num swapped procs		*/
122 	uint_t	swpocc;		/* (1 sec) ++ if num swapped procs > 0	*/
123 	uint_t	waiting;	/* (1 sec) += jobs waiting for I/O	*/
124 } sysinfo_t;
125 
126 typedef struct cpu_syswait {
127 	int	iowait;		/* procs waiting for block I/O		*/
128 	int	swap;		/* XXX: UNUSED				*/
129 	int	physio;		/* XXX: UNUSED 				*/
130 } cpu_syswait_t;
131 
132 typedef struct cpu_vminfo {
133 	uint_t	pgrec;		/* page reclaims (includes pageout)	*/
134 	uint_t	pgfrec;		/* page reclaims from free list		*/
135 	uint_t	pgin;		/* pageins				*/
136 	uint_t	pgpgin;		/* pages paged in			*/
137 	uint_t	pgout;		/* pageouts				*/
138 	uint_t	pgpgout;	/* pages paged out			*/
139 	uint_t	swapin;		/* swapins				*/
140 	uint_t	pgswapin;	/* pages swapped in			*/
141 	uint_t	swapout;	/* swapouts				*/
142 	uint_t	pgswapout;	/* pages swapped out			*/
143 	uint_t	zfod;		/* pages zero filled on demand		*/
144 	uint_t	dfree;		/* pages freed by daemon or auto	*/
145 	uint_t	scan;		/* pages examined by pageout daemon	*/
146 	uint_t	rev;		/* revolutions of the page daemon hand	*/
147 	uint_t	hat_fault;	/* minor page faults via hat_fault()	*/
148 	uint_t	as_fault;	/* minor page faults via as_fault()	*/
149 	uint_t	maj_fault;	/* major page faults			*/
150 	uint_t	cow_fault;	/* copy-on-write faults			*/
151 	uint_t	prot_fault;	/* protection faults			*/
152 	uint_t	softlock;	/* faults due to software locking req	*/
153 	uint_t	kernel_asflt;	/* as_fault()s in kernel addr space	*/
154 	uint_t	pgrrun;		/* times pager scheduled		*/
155 	uint_t  execpgin;	/* executable pages paged in		*/
156 	uint_t  execpgout;	/* executable pages paged out		*/
157 	uint_t  execfree;	/* executable pages freed		*/
158 	uint_t  anonpgin;	/* anon pages paged in			*/
159 	uint_t  anonpgout;	/* anon pages paged out			*/
160 	uint_t  anonfree;	/* anon pages freed			*/
161 	uint_t  fspgin;		/* fs pages paged in			*/
162 	uint_t  fspgout;	/* fs pages paged out			*/
163 	uint_t  fsfree;		/* fs pages free			*/
164 } cpu_vminfo_t;
165 
166 typedef struct vminfo {		/* (update freq) update action		*/
167 	uint64_t freemem; 	/* (1 sec) += freemem in pages		*/
168 	uint64_t swap_resv;	/* (1 sec) += reserved swap in pages	*/
169 	uint64_t swap_alloc;	/* (1 sec) += allocated swap in pages	*/
170 	uint64_t swap_avail;	/* (1 sec) += unreserved swap in pages	*/
171 	uint64_t swap_free;	/* (1 sec) += unallocated swap in pages	*/
172 } vminfo_t;
173 
174 typedef struct cpu_stat {
175 	uint_t		__cpu_stat_lock[2];	/* 32-bit kstat compat. */
176 	cpu_sysinfo_t	cpu_sysinfo;
177 	cpu_syswait_t	cpu_syswait;
178 	cpu_vminfo_t	cpu_vminfo;
179 } cpu_stat_t;
180 
181 typedef struct cpu_sys_stats {
182 	uint64_t cpu_ticks_idle; 	/* CPU utilization */
183 	uint64_t cpu_ticks_user;
184 	uint64_t cpu_ticks_kernel;
185 	uint64_t cpu_ticks_wait;
186 	uint64_t wait_ticks_io;		/* CPU wait time breakdown */
187 	uint64_t bread;			/* physical block reads */
188 	uint64_t bwrite;		/* physical block writes (sync+async) */
189 	uint64_t lread;			/* logical block reads */
190 	uint64_t lwrite;		/* logical block writes */
191 	uint64_t phread;		/* raw I/O Reads */
192 	uint64_t phwrite;		/* raw I/O writes */
193 	uint64_t pswitch;		/* context switches */
194 	uint64_t trap;			/* traps */
195 	uint64_t intr[PIL_MAX];		/* device interrupts per PIL */
196 	uint64_t syscall;		/* system calls */
197 	uint64_t sysread;		/* read() + readv() system calls */
198 	uint64_t syswrite;		/* write() + writev() system calls */
199 	uint64_t sysfork;		/* forks */
200 	uint64_t sysvfork;		/* vforks */
201 	uint64_t sysexec;		/* execs */
202 	uint64_t readch;		/* bytes read by rdwr() */
203 	uint64_t writech;		/* bytes written by rdwr() */
204 	uint64_t rcvint;		/* XXX: unused (mostly) */
205 	uint64_t xmtint;		/* XXX: unused */
206 	uint64_t mdmint;		/* XXX: unused */
207 	uint64_t rawch;			/* terminal input characters */
208 	uint64_t canch;			/* chars handled in canonical mode */
209 	uint64_t outch;			/* terminal output characters */
210 	uint64_t msg;			/* msg count (msgrcv() + msgsnd()) */
211 	uint64_t sema;			/* semaphore ops count (semop()) */
212 	uint64_t namei;			/* pathname lookups */
213 	uint64_t ufsiget;		/* ufs_iget() calls */
214 	uint64_t ufsdirblk;		/* directory blocks read */
215 	uint64_t ufsipage;		/* inodes taken with attached pages */
216 	uint64_t ufsinopage;		/* inodes taken with no attached pgs */
217 	uint64_t procovf;		/* failed forks */
218 	uint64_t intrblk;		/* ints blkd/prempted/rel'd (swtch) */
219 	uint64_t intrunpin;		/* intr thread unpins pinned thread */
220 	uint64_t idlethread;		/* times idle thread scheduled */
221 	uint64_t inv_swtch;		/* involuntary context switches */
222 	uint64_t nthreads;		/* thread_create()s */
223 	uint64_t cpumigrate;		/* cpu migrations by threads */
224 	uint64_t xcalls;		/* xcalls to other cpus */
225 	uint64_t mutex_adenters;	/* failed mutex enters (adaptive) */
226 	uint64_t rw_rdfails;		/* rw reader failures */
227 	uint64_t rw_wrfails;		/* rw writer failures */
228 	uint64_t modload;		/* times loadable module loaded */
229 	uint64_t modunload; 		/* times loadable module unloaded */
230 	uint64_t bawrite;		/* physical block writes (async) */
231 	uint64_t iowait; 		/* count of waiters for block I/O */
232 } cpu_sys_stats_t;
233 
234 typedef struct cpu_vm_stats {
235 	uint64_t pgrec;			/* page reclaims (includes pageout) */
236 	uint64_t pgfrec;		/* page reclaims from free list */
237 	uint64_t pgin;			/* pageins */
238 	uint64_t pgpgin;		/* pages paged in */
239 	uint64_t pgout;			/* pageouts */
240 	uint64_t pgpgout;		/* pages paged out */
241 	uint64_t swapin;		/* swapins */
242 	uint64_t pgswapin;		/* pages swapped in */
243 	uint64_t swapout;		/* swapouts */
244 	uint64_t pgswapout;		/* pages swapped out */
245 	uint64_t zfod;			/* pages zero filled on demand */
246 	uint64_t dfree;			/* pages freed by daemon or auto */
247 	uint64_t scan;			/* pages examined by pageout daemon */
248 	uint64_t rev;			/* revolutions of page daemon hand */
249 	uint64_t hat_fault;		/* minor page faults via hat_fault() */
250 	uint64_t as_fault;		/* minor page faults via as_fault() */
251 	uint64_t maj_fault;		/* major page faults */
252 	uint64_t cow_fault;		/* copy-on-write faults */
253 	uint64_t prot_fault;		/* protection faults */
254 	uint64_t softlock;		/* faults due to software locking req */
255 	uint64_t kernel_asflt;		/* as_fault()s in kernel addr space */
256 	uint64_t pgrrun;		/* times pager scheduled */
257 	uint64_t execpgin;		/* executable pages paged in */
258 	uint64_t execpgout;		/* executable pages paged out */
259 	uint64_t execfree;		/* executable pages freed */
260 	uint64_t anonpgin;		/* anon pages paged in */
261 	uint64_t anonpgout;		/* anon pages paged out */
262 	uint64_t anonfree;		/* anon pages freed */
263 	uint64_t fspgin;		/* fs pages paged in */
264 	uint64_t fspgout;		/* fs pages paged out */
265 	uint64_t fsfree;		/* fs pages free */
266 } cpu_vm_stats_t;
267 
268 typedef struct cpu_stats {
269 	cpu_sys_stats_t	sys;
270 	cpu_vm_stats_t	vm;
271 } cpu_stats_t;
272 
273 #ifdef	__cplusplus
274 }
275 #endif
276 
277 #endif	/* _SYS_SYSINFO_H */
278