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