summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/sysinfo.h
blob: 57e72812999cd3d0351a6f80e0b8c5345c1a73ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved  	*/


/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SYS_SYSINFO_H
#define	_SYS_SYSINFO_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 11.14 */

#include <sys/types.h>
#include <sys/t_lock.h>
#include <sys/kstat.h>
#include <sys/machlock.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 *	System Information.
 */
#define	CPU_IDLE	0
#define	CPU_USER	1
#define	CPU_KERNEL	2
#define	CPU_WAIT	3
#define	CPU_STATES	4

#define	W_IO		0
#define	W_SWAP		1
#define	W_PIO		2
#define	W_STATES	3

typedef struct cpu_sysinfo {
	uint_t	cpu[CPU_STATES]; /* CPU utilization			*/
	uint_t	wait[W_STATES];	/* CPU wait time breakdown		*/
	uint_t	bread;		/* physical block reads			*/
	uint_t	bwrite;		/* physical block writes (sync+async)	*/
	uint_t	lread;		/* logical block reads			*/
	uint_t	lwrite;		/* logical block writes			*/
	uint_t	phread;		/* raw I/O reads			*/
	uint_t	phwrite;	/* raw I/O writes			*/
	uint_t	pswitch;	/* context switches			*/
	uint_t	trap;		/* traps				*/
	uint_t	intr;		/* device interrupts			*/
	uint_t	syscall;	/* system calls				*/
	uint_t	sysread;	/* read() + readv() system calls	*/
	uint_t	syswrite;	/* write() + writev() system calls	*/
	uint_t	sysfork;	/* forks				*/
	uint_t	sysvfork;	/* vforks				*/
	uint_t	sysexec;	/* execs				*/
	uint_t	readch;		/* bytes read by rdwr()			*/
	uint_t	writech;	/* bytes written by rdwr()		*/
	uint_t	rcvint;		/* XXX: UNUSED				*/
	uint_t	xmtint;		/* XXX: UNUSED				*/
	uint_t	mdmint;		/* XXX: UNUSED				*/
	uint_t	rawch;		/* terminal input characters		*/
	uint_t	canch;		/* chars handled in canonical mode	*/
	uint_t	outch;		/* terminal output characters		*/
	uint_t	msg;		/* msg count (msgrcv()+msgsnd() calls)	*/
	uint_t	sema;		/* semaphore ops count (semop() calls)	*/
	uint_t	namei;		/* pathname lookups			*/
	uint_t	ufsiget;	/* ufs_iget() calls			*/
	uint_t	ufsdirblk;	/* directory blocks read		*/
	uint_t	ufsipage;	/* inodes taken with attached pages	*/
	uint_t	ufsinopage;	/* inodes taked with no attached pages	*/
	uint_t	inodeovf;	/* inode table overflows		*/
	uint_t	fileovf;	/* file table overflows			*/
	uint_t	procovf;	/* proc table overflows			*/
	uint_t	intrthread;	/* interrupts as threads (below clock)	*/
	uint_t	intrblk;	/* intrs blkd/prempted/released (swtch)	*/
	uint_t	idlethread;	/* times idle thread scheduled		*/
	uint_t	inv_swtch;	/* involuntary context switches		*/
	uint_t	nthreads;	/* thread_create()s			*/
	uint_t	cpumigrate;	/* cpu migrations by threads 		*/
	uint_t	xcalls;		/* xcalls to other cpus 		*/
	uint_t	mutex_adenters;	/* failed mutex enters (adaptive)	*/
	uint_t	rw_rdfails;	/* rw reader failures			*/
	uint_t	rw_wrfails;	/* rw writer failures			*/
	uint_t	modload;	/* times loadable module loaded		*/
	uint_t	modunload;	/* times loadable module unloaded 	*/
	uint_t	bawrite;	/* physical block writes (async)	*/
/* Following are gathered only under #ifdef STATISTICS in source 	*/
	uint_t	rw_enters;	/* tries to acquire rw lock		*/
	uint_t	win_uo_cnt;	/* reg window user overflows		*/
	uint_t	win_uu_cnt;	/* reg window user underflows		*/
	uint_t	win_so_cnt;	/* reg window system overflows		*/
	uint_t	win_su_cnt;	/* reg window system underflows		*/
	uint_t	win_suo_cnt;	/* reg window system user overflows	*/
} cpu_sysinfo_t;

typedef struct sysinfo {	/* (update freq) update action		*/
	uint_t	updates;	/* (1 sec) ++				*/
	uint_t	runque;		/* (1 sec) += num runnable procs	*/
	uint_t	runocc;		/* (1 sec) ++ if num runnable procs > 0	*/
	uint_t	swpque;		/* (1 sec) += num swapped procs		*/
	uint_t	swpocc;		/* (1 sec) ++ if num swapped procs > 0	*/
	uint_t	waiting;	/* (1 sec) += jobs waiting for I/O	*/
} sysinfo_t;

typedef struct cpu_syswait {
	int	iowait;		/* procs waiting for block I/O		*/
	int	swap;		/* XXX: UNUSED				*/
	int	physio;		/* XXX: UNUSED 				*/
} cpu_syswait_t;

typedef struct cpu_vminfo {
	uint_t	pgrec;		/* page reclaims (includes pageout)	*/
	uint_t	pgfrec;		/* page reclaims from free list		*/
	uint_t	pgin;		/* pageins				*/
	uint_t	pgpgin;		/* pages paged in			*/
	uint_t	pgout;		/* pageouts				*/
	uint_t	pgpgout;	/* pages paged out			*/
	uint_t	swapin;		/* swapins				*/
	uint_t	pgswapin;	/* pages swapped in			*/
	uint_t	swapout;	/* swapouts				*/
	uint_t	pgswapout;	/* pages swapped out			*/
	uint_t	zfod;		/* pages zero filled on demand		*/
	uint_t	dfree;		/* pages freed by daemon or auto	*/
	uint_t	scan;		/* pages examined by pageout daemon	*/
	uint_t	rev;		/* revolutions of the page daemon hand	*/
	uint_t	hat_fault;	/* minor page faults via hat_fault()	*/
	uint_t	as_fault;	/* minor page faults via as_fault()	*/
	uint_t	maj_fault;	/* major page faults			*/
	uint_t	cow_fault;	/* copy-on-write faults			*/
	uint_t	prot_fault;	/* protection faults			*/
	uint_t	softlock;	/* faults due to software locking req	*/
	uint_t	kernel_asflt;	/* as_fault()s in kernel addr space	*/
	uint_t	pgrrun;		/* times pager scheduled		*/
	uint_t  execpgin;	/* executable pages paged in		*/
	uint_t  execpgout;	/* executable pages paged out		*/
	uint_t  execfree;	/* executable pages freed		*/
	uint_t  anonpgin;	/* anon pages paged in			*/
	uint_t  anonpgout;	/* anon pages paged out			*/
	uint_t  anonfree;	/* anon pages freed			*/
	uint_t  fspgin;		/* fs pages paged in			*/
	uint_t  fspgout;	/* fs pages paged out			*/
	uint_t  fsfree;		/* fs pages free			*/
} cpu_vminfo_t;

typedef struct vminfo {		/* (update freq) update action		*/
	uint64_t freemem; 	/* (1 sec) += freemem in pages		*/
	uint64_t swap_resv;	/* (1 sec) += reserved swap in pages	*/
	uint64_t swap_alloc;	/* (1 sec) += allocated swap in pages	*/
	uint64_t swap_avail;	/* (1 sec) += unreserved swap in pages	*/
	uint64_t swap_free;	/* (1 sec) += unallocated swap in pages	*/
} vminfo_t;

typedef struct cpu_stat {
	uint_t		__cpu_stat_lock[2];	/* 32-bit kstat compat. */
	cpu_sysinfo_t	cpu_sysinfo;
	cpu_syswait_t	cpu_syswait;
	cpu_vminfo_t	cpu_vminfo;
} cpu_stat_t;

typedef struct cpu_sys_stats {
	uint64_t cpu_ticks_idle; 	/* CPU utilization */
	uint64_t cpu_ticks_user;
	uint64_t cpu_ticks_kernel;
	uint64_t cpu_ticks_wait;
	uint64_t wait_ticks_io;		/* CPU wait time breakdown */
	uint64_t bread;			/* physical block reads */
	uint64_t bwrite;		/* physical block writes (sync+async) */
	uint64_t lread;			/* logical block reads */
	uint64_t lwrite;		/* logical block writes */
	uint64_t phread;		/* raw I/O Reads */
	uint64_t phwrite;		/* raw I/O writes */
	uint64_t pswitch;		/* context switches */
	uint64_t trap;			/* traps */
	uint64_t intr[PIL_MAX];		/* device interrupts per PIL */
	uint64_t syscall;		/* system calls */
	uint64_t sysread;		/* read() + readv() system calls */
	uint64_t syswrite;		/* write() + writev() system calls */
	uint64_t sysfork;		/* forks */
	uint64_t sysvfork;		/* vforks */
	uint64_t sysexec;		/* execs */
	uint64_t readch;		/* bytes read by rdwr() */
	uint64_t writech;		/* bytes written by rdwr() */
	uint64_t rcvint;		/* XXX: unused (mostly) */
	uint64_t xmtint;		/* XXX: unused */
	uint64_t mdmint;		/* XXX: unused */
	uint64_t rawch;			/* terminal input characters */
	uint64_t canch;			/* chars handled in canonical mode */
	uint64_t outch;			/* terminal output characters */
	uint64_t msg;			/* msg count (msgrcv() + msgsnd()) */
	uint64_t sema;			/* semaphore ops count (semop()) */
	uint64_t namei;			/* pathname lookups */
	uint64_t ufsiget;		/* ufs_iget() calls */
	uint64_t ufsdirblk;		/* directory blocks read */
	uint64_t ufsipage;		/* inodes taken with attached pages */
	uint64_t ufsinopage;		/* inodes taken with no attached pgs */
	uint64_t procovf;		/* failed forks */
	uint64_t intrblk;		/* ints blkd/prempted/rel'd (swtch) */
	uint64_t intrunpin;		/* intr thread unpins pinned thread */
	uint64_t idlethread;		/* times idle thread scheduled */
	uint64_t inv_swtch;		/* involuntary context switches */
	uint64_t nthreads;		/* thread_create()s */
	uint64_t cpumigrate;		/* cpu migrations by threads */
	uint64_t xcalls;		/* xcalls to other cpus */
	uint64_t mutex_adenters;	/* failed mutex enters (adaptive) */
	uint64_t rw_rdfails;		/* rw reader failures */
	uint64_t rw_wrfails;		/* rw writer failures */
	uint64_t modload;		/* times loadable module loaded */
	uint64_t modunload; 		/* times loadable module unloaded */
	uint64_t bawrite;		/* physical block writes (async) */
	uint64_t iowait; 		/* count of waiters for block I/O */
} cpu_sys_stats_t;

typedef struct cpu_vm_stats {
	uint64_t pgrec;			/* page reclaims (includes pageout) */
	uint64_t pgfrec;		/* page reclaims from free list */
	uint64_t pgin;			/* pageins */
	uint64_t pgpgin;		/* pages paged in */
	uint64_t pgout;			/* pageouts */
	uint64_t pgpgout;		/* pages paged out */
	uint64_t swapin;		/* swapins */
	uint64_t pgswapin;		/* pages swapped in */
	uint64_t swapout;		/* swapouts */
	uint64_t pgswapout;		/* pages swapped out */
	uint64_t zfod;			/* pages zero filled on demand */
	uint64_t dfree;			/* pages freed by daemon or auto */
	uint64_t scan;			/* pages examined by pageout daemon */
	uint64_t rev;			/* revolutions of page daemon hand */
	uint64_t hat_fault;		/* minor page faults via hat_fault() */
	uint64_t as_fault;		/* minor page faults via as_fault() */
	uint64_t maj_fault;		/* major page faults */
	uint64_t cow_fault;		/* copy-on-write faults */
	uint64_t prot_fault;		/* protection faults */
	uint64_t softlock;		/* faults due to software locking req */
	uint64_t kernel_asflt;		/* as_fault()s in kernel addr space */
	uint64_t pgrrun;		/* times pager scheduled */
	uint64_t execpgin;		/* executable pages paged in */
	uint64_t execpgout;		/* executable pages paged out */
	uint64_t execfree;		/* executable pages freed */
	uint64_t anonpgin;		/* anon pages paged in */
	uint64_t anonpgout;		/* anon pages paged out */
	uint64_t anonfree;		/* anon pages freed */
	uint64_t fspgin;		/* fs pages paged in */
	uint64_t fspgout;		/* fs pages paged out */
	uint64_t fsfree;		/* fs pages free */
} cpu_vm_stats_t;

typedef struct cpu_stats {
	cpu_sys_stats_t	sys;
	cpu_vm_stats_t	vm;
} cpu_stats_t;

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_SYSINFO_H */