diff options
author | Thorsten Lockert <tholo@cvs.openbsd.org> | 1996-02-20 04:48:37 +0000 |
---|---|---|
committer | Thorsten Lockert <tholo@cvs.openbsd.org> | 1996-02-20 04:48:37 +0000 |
commit | a31c9394f3f47b27cb4c1d84d40c4b75ff73fd1e (patch) | |
tree | 87d08de6c8f6a5bf46d7cf1f21c9b90a187657fd /usr.bin/vmstat/vmstat.c | |
parent | e6a99228726e49ee62207a66c2d4bf659b4a7f77 (diff) |
Support getting interrupts per device on the i386 platform, similar to
implementation on pc532
Diffstat (limited to 'usr.bin/vmstat/vmstat.c')
-rw-r--r-- | usr.bin/vmstat/vmstat.c | 86 |
1 files changed, 64 insertions, 22 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 50f34de99df..2ad30c48afd 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -105,11 +105,11 @@ struct nlist namelist[] = { { "_bucket" }, #define X_ALLEVENTS 14 { "_allevents" }, +#define X_FORKSTAT 15 + { "_forkstat" }, #ifdef notdef -#define X_DEFICIT 15 +#define X_DEFICIT 16 { "_deficit" }, -#define X_FORKSTAT 16 - { "_forkstat" }, #define X_REC 17 { "_rectime" }, #define X_PGIN 18 @@ -118,7 +118,7 @@ struct nlist namelist[] = { { "_xstats" }, #define X_END 20 #else -#define X_END 15 +#define X_END 16 #endif #if defined(hp300) || defined(luna68k) #define X_HPDINIT (X_END) @@ -140,6 +140,12 @@ struct nlist namelist[] = { #define X_IVT (X_END) { "_ivt" }, #endif +#if defined(i386) +#define X_INTRHAND (X_END) + { "_intrhand" }, +#define X_INTRSTRAY (X_END+1) + { "_intrstray" }, +#endif { "" }, }; @@ -167,9 +173,7 @@ kvm_t *kd; void cpustats(), dkstats(), dointr(), domem(), dosum(); void dovmstat(), kread(), usage(); -#ifdef notdef void dotimes(), doforkst(); -#endif main(argc, argv) register int argc; @@ -210,11 +214,9 @@ main(argc, argv) case 's': todo |= SUMSTAT; break; -#ifndef notdef case 't': todo |= TIMESTAT; break; -#endif case 'w': interval = atoi(optarg); break; @@ -286,18 +288,14 @@ main(argc, argv) } else if (reps) interval = 1; -#ifdef notdef if (todo & FORKSTAT) doforkst(); -#endif if (todo & MEMSTAT) domem(); if (todo & SUMSTAT) dosum(); -#ifdef notdef if (todo & TIMESTAT) dotimes(); -#endif if (todo & INTRSTAT) dointr(); if (todo & VMSTAT) @@ -505,25 +503,28 @@ needhdr() hdrcnt = 1; } -#ifdef notdef void dotimes() { u_int pgintime, rectime; +#ifdef NEWVM + pgintime = 0; + rectime = 0; +#else kread(X_REC, &rectime, sizeof(rectime)); kread(X_PGIN, &pgintime, sizeof(pgintime)); +#endif kread(X_SUM, &sum, sizeof(sum)); - (void)printf("%u reclaims, %u total time (usec)\n", - sum.v_pgrec, rectime); - (void)printf("average: %u usec / reclaim\n", rectime / sum.v_pgrec); + (void)printf("%u reactivates, %u total time (usec)\n", + sum.v_reactivated, rectime); + (void)printf("average: %u usec / reclaim\n", rectime / sum.v_reactivated); (void)printf("\n"); (void)printf("%u page ins, %u total time (msec)\n", - sum.v_pgin, pgintime / 10); + sum.v_pageins, pgintime / 10); (void)printf("average: %8.1f msec / page in\n", - pgintime / (sum.v_pgin * 10.0)); + pgintime / (sum.v_pageins * 10.0)); } -#endif pct(top, bot) long top, bot; @@ -647,7 +648,6 @@ dosum() #endif } -#ifdef notdef void doforkst() { @@ -657,9 +657,10 @@ doforkst() (void)printf("%d forks, %d pages, average %.2f\n", fks.cntfork, fks.sizfork, (double)fks.sizfork / fks.cntfork); (void)printf("%d vforks, %d pages, average %.2f\n", - fks.cntvfork, fks.sizvfork, (double)fks.sizvfork / fks.cntvfork); + fks.cntvfork, fks.sizvfork, (double)fks.sizvfork / (fks.cntvfork ? fks.cntvfork : 1)); + (void)printf("%d rforks, %d pages, average %.2f\n", + fks.cntrfork, fks.sizrfork, (double)fks.sizrfork / (fks.cntrfork ? fks.cntrfork : 1)); } -#endif void dkstats() @@ -744,6 +745,47 @@ dointr() inttotal, inttotal / uptime); } } +#elif defined(i386) +/* To get struct intrhand */ +#define _KERNEL +#include <machine/psl.h> +#undef _KERNEL +void +dointr() +{ + struct intrhand *intrhand[16], *ihp, ih; + long inttotal, uptime; + int intrstray[16]; + char iname[17]; + int i; + + iname[16] = '\0'; + uptime = getuptime(); + kread(X_INTRHAND, intrhand, sizeof(intrhand)); + kread(X_INTRSTRAY, intrstray, sizeof(intrstray)); + + (void)printf("interrupt total rate\n"); + inttotal = 0; + for (i = 0; i < 16; i++) { + ihp = intrhand[i]; + while (ihp) { + if (kvm_read(kd, (u_long)ihp, &ih, sizeof(ih)) != sizeof(ih)) + errx(1, "vmstat: ih: %s", kvm_geterr(kd)); + if (kvm_read(kd, (u_long)ih.ih_what, iname, 16) != 16) + errx(1, "vmstat: ih_what: %s", kvm_geterr(kd)); + printf("%-16.16s %8ld %8ld\n", iname, ih.ih_count, ih.ih_count / uptime); + inttotal += ih.ih_count; + ihp = ih.ih_next; + } + } + for (i = 0; i < 16; i++) + if (intrstray[i]) { + printf("Stray irq %-2d %8ld %8ld\n", + i, intrstray[i], intrstray[i] / uptime); + inttotal += intrstray[i]; + } + printf("Total %8ld %8ld\n", inttotal, inttotal / uptime); +} #else void dointr() |