10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57705SAlan.Hargreaves@Sun.COM * Common Development and Distribution License (the "License"). 67705SAlan.Hargreaves@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 220Sstevel@tonic-gate /* All Rights Reserved */ 230Sstevel@tonic-gate 240Sstevel@tonic-gate 250Sstevel@tonic-gate /* 26*11657SDonghai.Qiao@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 270Sstevel@tonic-gate * Use is subject to license terms. 280Sstevel@tonic-gate */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifndef _SYS_SYSINFO_H 310Sstevel@tonic-gate #define _SYS_SYSINFO_H 320Sstevel@tonic-gate 330Sstevel@tonic-gate #include <sys/types.h> 340Sstevel@tonic-gate #include <sys/t_lock.h> 350Sstevel@tonic-gate #include <sys/kstat.h> 360Sstevel@tonic-gate #include <sys/machlock.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate #ifdef __cplusplus 390Sstevel@tonic-gate extern "C" { 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * System Information. 440Sstevel@tonic-gate */ 450Sstevel@tonic-gate #define CPU_IDLE 0 460Sstevel@tonic-gate #define CPU_USER 1 470Sstevel@tonic-gate #define CPU_KERNEL 2 480Sstevel@tonic-gate #define CPU_WAIT 3 490Sstevel@tonic-gate #define CPU_STATES 4 500Sstevel@tonic-gate 510Sstevel@tonic-gate #define W_IO 0 520Sstevel@tonic-gate #define W_SWAP 1 530Sstevel@tonic-gate #define W_PIO 2 540Sstevel@tonic-gate #define W_STATES 3 550Sstevel@tonic-gate 560Sstevel@tonic-gate typedef struct cpu_sysinfo { 570Sstevel@tonic-gate uint_t cpu[CPU_STATES]; /* CPU utilization */ 580Sstevel@tonic-gate uint_t wait[W_STATES]; /* CPU wait time breakdown */ 597705SAlan.Hargreaves@Sun.COM /* 607705SAlan.Hargreaves@Sun.COM * The two stats lwrite and bwrite are used by sar(1) to 617705SAlan.Hargreaves@Sun.COM * generate the write cache hit percentage (%wcache value). 627705SAlan.Hargreaves@Sun.COM * 637705SAlan.Hargreaves@Sun.COM * The value is calculated as follows (unless lwrite < 0.5 and 647705SAlan.Hargreaves@Sun.COM * then %wcache is coded to 100%): 657705SAlan.Hargreaves@Sun.COM * 667705SAlan.Hargreaves@Sun.COM * (lwrite - bwrite)/lwrite * 100.0 677705SAlan.Hargreaves@Sun.COM * 687705SAlan.Hargreaves@Sun.COM * This calculation assumes that when a physical write occurs 697705SAlan.Hargreaves@Sun.COM * (bwrite incremented), that a logical write (lwrite 707705SAlan.Hargreaves@Sun.COM * incremented) has also occured. Note that a logical write 717705SAlan.Hargreaves@Sun.COM * (lwrite incremented) my occur on its own. 727705SAlan.Hargreaves@Sun.COM * 737705SAlan.Hargreaves@Sun.COM * Similar for lread/bread and %rcache. 747705SAlan.Hargreaves@Sun.COM */ 750Sstevel@tonic-gate uint_t bread; /* physical block reads */ 760Sstevel@tonic-gate uint_t bwrite; /* physical block writes (sync+async) */ 770Sstevel@tonic-gate uint_t lread; /* logical block reads */ 780Sstevel@tonic-gate uint_t lwrite; /* logical block writes */ 790Sstevel@tonic-gate uint_t phread; /* raw I/O reads */ 800Sstevel@tonic-gate uint_t phwrite; /* raw I/O writes */ 810Sstevel@tonic-gate uint_t pswitch; /* context switches */ 820Sstevel@tonic-gate uint_t trap; /* traps */ 830Sstevel@tonic-gate uint_t intr; /* device interrupts */ 840Sstevel@tonic-gate uint_t syscall; /* system calls */ 850Sstevel@tonic-gate uint_t sysread; /* read() + readv() system calls */ 860Sstevel@tonic-gate uint_t syswrite; /* write() + writev() system calls */ 870Sstevel@tonic-gate uint_t sysfork; /* forks */ 880Sstevel@tonic-gate uint_t sysvfork; /* vforks */ 890Sstevel@tonic-gate uint_t sysexec; /* execs */ 900Sstevel@tonic-gate uint_t readch; /* bytes read by rdwr() */ 910Sstevel@tonic-gate uint_t writech; /* bytes written by rdwr() */ 920Sstevel@tonic-gate uint_t rcvint; /* XXX: UNUSED */ 930Sstevel@tonic-gate uint_t xmtint; /* XXX: UNUSED */ 940Sstevel@tonic-gate uint_t mdmint; /* XXX: UNUSED */ 950Sstevel@tonic-gate uint_t rawch; /* terminal input characters */ 960Sstevel@tonic-gate uint_t canch; /* chars handled in canonical mode */ 970Sstevel@tonic-gate uint_t outch; /* terminal output characters */ 980Sstevel@tonic-gate uint_t msg; /* msg count (msgrcv()+msgsnd() calls) */ 990Sstevel@tonic-gate uint_t sema; /* semaphore ops count (semop() calls) */ 1000Sstevel@tonic-gate uint_t namei; /* pathname lookups */ 1010Sstevel@tonic-gate uint_t ufsiget; /* ufs_iget() calls */ 1020Sstevel@tonic-gate uint_t ufsdirblk; /* directory blocks read */ 1030Sstevel@tonic-gate uint_t ufsipage; /* inodes taken with attached pages */ 1040Sstevel@tonic-gate uint_t ufsinopage; /* inodes taked with no attached pages */ 1050Sstevel@tonic-gate uint_t inodeovf; /* inode table overflows */ 1060Sstevel@tonic-gate uint_t fileovf; /* file table overflows */ 1070Sstevel@tonic-gate uint_t procovf; /* proc table overflows */ 1080Sstevel@tonic-gate uint_t intrthread; /* interrupts as threads (below clock) */ 1090Sstevel@tonic-gate uint_t intrblk; /* intrs blkd/prempted/released (swtch) */ 1100Sstevel@tonic-gate uint_t idlethread; /* times idle thread scheduled */ 1110Sstevel@tonic-gate uint_t inv_swtch; /* involuntary context switches */ 1120Sstevel@tonic-gate uint_t nthreads; /* thread_create()s */ 1130Sstevel@tonic-gate uint_t cpumigrate; /* cpu migrations by threads */ 1140Sstevel@tonic-gate uint_t xcalls; /* xcalls to other cpus */ 1150Sstevel@tonic-gate uint_t mutex_adenters; /* failed mutex enters (adaptive) */ 1160Sstevel@tonic-gate uint_t rw_rdfails; /* rw reader failures */ 1170Sstevel@tonic-gate uint_t rw_wrfails; /* rw writer failures */ 1180Sstevel@tonic-gate uint_t modload; /* times loadable module loaded */ 1190Sstevel@tonic-gate uint_t modunload; /* times loadable module unloaded */ 1200Sstevel@tonic-gate uint_t bawrite; /* physical block writes (async) */ 1210Sstevel@tonic-gate /* Following are gathered only under #ifdef STATISTICS in source */ 1220Sstevel@tonic-gate uint_t rw_enters; /* tries to acquire rw lock */ 1230Sstevel@tonic-gate uint_t win_uo_cnt; /* reg window user overflows */ 1240Sstevel@tonic-gate uint_t win_uu_cnt; /* reg window user underflows */ 1250Sstevel@tonic-gate uint_t win_so_cnt; /* reg window system overflows */ 1260Sstevel@tonic-gate uint_t win_su_cnt; /* reg window system underflows */ 1270Sstevel@tonic-gate uint_t win_suo_cnt; /* reg window system user overflows */ 1280Sstevel@tonic-gate } cpu_sysinfo_t; 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate typedef struct sysinfo { /* (update freq) update action */ 1310Sstevel@tonic-gate uint_t updates; /* (1 sec) ++ */ 1320Sstevel@tonic-gate uint_t runque; /* (1 sec) += num runnable procs */ 1330Sstevel@tonic-gate uint_t runocc; /* (1 sec) ++ if num runnable procs > 0 */ 1340Sstevel@tonic-gate uint_t swpque; /* (1 sec) += num swapped procs */ 1350Sstevel@tonic-gate uint_t swpocc; /* (1 sec) ++ if num swapped procs > 0 */ 1360Sstevel@tonic-gate uint_t waiting; /* (1 sec) += jobs waiting for I/O */ 1370Sstevel@tonic-gate } sysinfo_t; 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate typedef struct cpu_syswait { 1400Sstevel@tonic-gate int iowait; /* procs waiting for block I/O */ 1410Sstevel@tonic-gate int swap; /* XXX: UNUSED */ 1420Sstevel@tonic-gate int physio; /* XXX: UNUSED */ 1430Sstevel@tonic-gate } cpu_syswait_t; 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate typedef struct cpu_vminfo { 1460Sstevel@tonic-gate uint_t pgrec; /* page reclaims (includes pageout) */ 1470Sstevel@tonic-gate uint_t pgfrec; /* page reclaims from free list */ 1480Sstevel@tonic-gate uint_t pgin; /* pageins */ 1490Sstevel@tonic-gate uint_t pgpgin; /* pages paged in */ 1500Sstevel@tonic-gate uint_t pgout; /* pageouts */ 1510Sstevel@tonic-gate uint_t pgpgout; /* pages paged out */ 1520Sstevel@tonic-gate uint_t swapin; /* swapins */ 1530Sstevel@tonic-gate uint_t pgswapin; /* pages swapped in */ 1540Sstevel@tonic-gate uint_t swapout; /* swapouts */ 1550Sstevel@tonic-gate uint_t pgswapout; /* pages swapped out */ 1560Sstevel@tonic-gate uint_t zfod; /* pages zero filled on demand */ 1570Sstevel@tonic-gate uint_t dfree; /* pages freed by daemon or auto */ 1580Sstevel@tonic-gate uint_t scan; /* pages examined by pageout daemon */ 1590Sstevel@tonic-gate uint_t rev; /* revolutions of the page daemon hand */ 1600Sstevel@tonic-gate uint_t hat_fault; /* minor page faults via hat_fault() */ 1610Sstevel@tonic-gate uint_t as_fault; /* minor page faults via as_fault() */ 1620Sstevel@tonic-gate uint_t maj_fault; /* major page faults */ 1630Sstevel@tonic-gate uint_t cow_fault; /* copy-on-write faults */ 1640Sstevel@tonic-gate uint_t prot_fault; /* protection faults */ 1650Sstevel@tonic-gate uint_t softlock; /* faults due to software locking req */ 1660Sstevel@tonic-gate uint_t kernel_asflt; /* as_fault()s in kernel addr space */ 1670Sstevel@tonic-gate uint_t pgrrun; /* times pager scheduled */ 1680Sstevel@tonic-gate uint_t execpgin; /* executable pages paged in */ 1690Sstevel@tonic-gate uint_t execpgout; /* executable pages paged out */ 1700Sstevel@tonic-gate uint_t execfree; /* executable pages freed */ 1710Sstevel@tonic-gate uint_t anonpgin; /* anon pages paged in */ 1720Sstevel@tonic-gate uint_t anonpgout; /* anon pages paged out */ 1730Sstevel@tonic-gate uint_t anonfree; /* anon pages freed */ 1740Sstevel@tonic-gate uint_t fspgin; /* fs pages paged in */ 1750Sstevel@tonic-gate uint_t fspgout; /* fs pages paged out */ 1760Sstevel@tonic-gate uint_t fsfree; /* fs pages free */ 1770Sstevel@tonic-gate } cpu_vminfo_t; 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate typedef struct vminfo { /* (update freq) update action */ 1800Sstevel@tonic-gate uint64_t freemem; /* (1 sec) += freemem in pages */ 1810Sstevel@tonic-gate uint64_t swap_resv; /* (1 sec) += reserved swap in pages */ 1820Sstevel@tonic-gate uint64_t swap_alloc; /* (1 sec) += allocated swap in pages */ 1830Sstevel@tonic-gate uint64_t swap_avail; /* (1 sec) += unreserved swap in pages */ 1840Sstevel@tonic-gate uint64_t swap_free; /* (1 sec) += unallocated swap in pages */ 185*11657SDonghai.Qiao@Sun.COM uint64_t updates; /* (1 sec) ++ */ 1860Sstevel@tonic-gate } vminfo_t; 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate typedef struct cpu_stat { 1890Sstevel@tonic-gate uint_t __cpu_stat_lock[2]; /* 32-bit kstat compat. */ 1900Sstevel@tonic-gate cpu_sysinfo_t cpu_sysinfo; 1910Sstevel@tonic-gate cpu_syswait_t cpu_syswait; 1920Sstevel@tonic-gate cpu_vminfo_t cpu_vminfo; 1930Sstevel@tonic-gate } cpu_stat_t; 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate typedef struct cpu_sys_stats { 1960Sstevel@tonic-gate uint64_t cpu_ticks_idle; /* CPU utilization */ 1970Sstevel@tonic-gate uint64_t cpu_ticks_user; 1980Sstevel@tonic-gate uint64_t cpu_ticks_kernel; 1990Sstevel@tonic-gate uint64_t cpu_ticks_wait; 2000Sstevel@tonic-gate uint64_t wait_ticks_io; /* CPU wait time breakdown */ 2010Sstevel@tonic-gate uint64_t bread; /* physical block reads */ 2020Sstevel@tonic-gate uint64_t bwrite; /* physical block writes (sync+async) */ 2030Sstevel@tonic-gate uint64_t lread; /* logical block reads */ 2040Sstevel@tonic-gate uint64_t lwrite; /* logical block writes */ 2050Sstevel@tonic-gate uint64_t phread; /* raw I/O Reads */ 2060Sstevel@tonic-gate uint64_t phwrite; /* raw I/O writes */ 2070Sstevel@tonic-gate uint64_t pswitch; /* context switches */ 2080Sstevel@tonic-gate uint64_t trap; /* traps */ 2090Sstevel@tonic-gate uint64_t intr[PIL_MAX]; /* device interrupts per PIL */ 2100Sstevel@tonic-gate uint64_t syscall; /* system calls */ 2110Sstevel@tonic-gate uint64_t sysread; /* read() + readv() system calls */ 2120Sstevel@tonic-gate uint64_t syswrite; /* write() + writev() system calls */ 2130Sstevel@tonic-gate uint64_t sysfork; /* forks */ 2140Sstevel@tonic-gate uint64_t sysvfork; /* vforks */ 2150Sstevel@tonic-gate uint64_t sysexec; /* execs */ 2160Sstevel@tonic-gate uint64_t readch; /* bytes read by rdwr() */ 2170Sstevel@tonic-gate uint64_t writech; /* bytes written by rdwr() */ 2180Sstevel@tonic-gate uint64_t rcvint; /* XXX: unused (mostly) */ 2190Sstevel@tonic-gate uint64_t xmtint; /* XXX: unused */ 2200Sstevel@tonic-gate uint64_t mdmint; /* XXX: unused */ 2210Sstevel@tonic-gate uint64_t rawch; /* terminal input characters */ 2220Sstevel@tonic-gate uint64_t canch; /* chars handled in canonical mode */ 2230Sstevel@tonic-gate uint64_t outch; /* terminal output characters */ 2240Sstevel@tonic-gate uint64_t msg; /* msg count (msgrcv() + msgsnd()) */ 2250Sstevel@tonic-gate uint64_t sema; /* semaphore ops count (semop()) */ 2260Sstevel@tonic-gate uint64_t namei; /* pathname lookups */ 2270Sstevel@tonic-gate uint64_t ufsiget; /* ufs_iget() calls */ 2280Sstevel@tonic-gate uint64_t ufsdirblk; /* directory blocks read */ 2290Sstevel@tonic-gate uint64_t ufsipage; /* inodes taken with attached pages */ 2300Sstevel@tonic-gate uint64_t ufsinopage; /* inodes taken with no attached pgs */ 2310Sstevel@tonic-gate uint64_t procovf; /* failed forks */ 2320Sstevel@tonic-gate uint64_t intrblk; /* ints blkd/prempted/rel'd (swtch) */ 2330Sstevel@tonic-gate uint64_t intrunpin; /* intr thread unpins pinned thread */ 2340Sstevel@tonic-gate uint64_t idlethread; /* times idle thread scheduled */ 2350Sstevel@tonic-gate uint64_t inv_swtch; /* involuntary context switches */ 2360Sstevel@tonic-gate uint64_t nthreads; /* thread_create()s */ 2370Sstevel@tonic-gate uint64_t cpumigrate; /* cpu migrations by threads */ 2380Sstevel@tonic-gate uint64_t xcalls; /* xcalls to other cpus */ 2390Sstevel@tonic-gate uint64_t mutex_adenters; /* failed mutex enters (adaptive) */ 2400Sstevel@tonic-gate uint64_t rw_rdfails; /* rw reader failures */ 2410Sstevel@tonic-gate uint64_t rw_wrfails; /* rw writer failures */ 2420Sstevel@tonic-gate uint64_t modload; /* times loadable module loaded */ 2430Sstevel@tonic-gate uint64_t modunload; /* times loadable module unloaded */ 2440Sstevel@tonic-gate uint64_t bawrite; /* physical block writes (async) */ 2450Sstevel@tonic-gate uint64_t iowait; /* count of waiters for block I/O */ 2460Sstevel@tonic-gate } cpu_sys_stats_t; 2470Sstevel@tonic-gate 2480Sstevel@tonic-gate typedef struct cpu_vm_stats { 2490Sstevel@tonic-gate uint64_t pgrec; /* page reclaims (includes pageout) */ 2500Sstevel@tonic-gate uint64_t pgfrec; /* page reclaims from free list */ 2510Sstevel@tonic-gate uint64_t pgin; /* pageins */ 2520Sstevel@tonic-gate uint64_t pgpgin; /* pages paged in */ 2530Sstevel@tonic-gate uint64_t pgout; /* pageouts */ 2540Sstevel@tonic-gate uint64_t pgpgout; /* pages paged out */ 2550Sstevel@tonic-gate uint64_t swapin; /* swapins */ 2560Sstevel@tonic-gate uint64_t pgswapin; /* pages swapped in */ 2570Sstevel@tonic-gate uint64_t swapout; /* swapouts */ 2580Sstevel@tonic-gate uint64_t pgswapout; /* pages swapped out */ 2590Sstevel@tonic-gate uint64_t zfod; /* pages zero filled on demand */ 2600Sstevel@tonic-gate uint64_t dfree; /* pages freed by daemon or auto */ 2610Sstevel@tonic-gate uint64_t scan; /* pages examined by pageout daemon */ 2620Sstevel@tonic-gate uint64_t rev; /* revolutions of page daemon hand */ 2630Sstevel@tonic-gate uint64_t hat_fault; /* minor page faults via hat_fault() */ 2640Sstevel@tonic-gate uint64_t as_fault; /* minor page faults via as_fault() */ 2650Sstevel@tonic-gate uint64_t maj_fault; /* major page faults */ 2660Sstevel@tonic-gate uint64_t cow_fault; /* copy-on-write faults */ 2670Sstevel@tonic-gate uint64_t prot_fault; /* protection faults */ 2680Sstevel@tonic-gate uint64_t softlock; /* faults due to software locking req */ 2690Sstevel@tonic-gate uint64_t kernel_asflt; /* as_fault()s in kernel addr space */ 2700Sstevel@tonic-gate uint64_t pgrrun; /* times pager scheduled */ 2710Sstevel@tonic-gate uint64_t execpgin; /* executable pages paged in */ 2720Sstevel@tonic-gate uint64_t execpgout; /* executable pages paged out */ 2730Sstevel@tonic-gate uint64_t execfree; /* executable pages freed */ 2740Sstevel@tonic-gate uint64_t anonpgin; /* anon pages paged in */ 2750Sstevel@tonic-gate uint64_t anonpgout; /* anon pages paged out */ 2760Sstevel@tonic-gate uint64_t anonfree; /* anon pages freed */ 2770Sstevel@tonic-gate uint64_t fspgin; /* fs pages paged in */ 2780Sstevel@tonic-gate uint64_t fspgout; /* fs pages paged out */ 2790Sstevel@tonic-gate uint64_t fsfree; /* fs pages free */ 2800Sstevel@tonic-gate } cpu_vm_stats_t; 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate typedef struct cpu_stats { 2830Sstevel@tonic-gate cpu_sys_stats_t sys; 2840Sstevel@tonic-gate cpu_vm_stats_t vm; 2850Sstevel@tonic-gate } cpu_stats_t; 2860Sstevel@tonic-gate 2870Sstevel@tonic-gate #ifdef __cplusplus 2880Sstevel@tonic-gate } 2890Sstevel@tonic-gate #endif 2900Sstevel@tonic-gate 2910Sstevel@tonic-gate #endif /* _SYS_SYSINFO_H */ 292