diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-11-28 14:05:25 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-11-28 14:05:25 +0000 |
commit | b4083bdd9e35a8a9ff1611292ce4b3e9c2cce55e (patch) | |
tree | 4d988c7afa8b50f881638553d84db33011ad94b0 /usr.bin | |
parent | 58d25f35b9ffc9852ecd68525217d077103eb8e4 (diff) |
Stop looking at intrcnt[] for vmstat -i; this means vmstat -i only works
on live kernels now, though.
ok deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/vmstat/vmstat.c | 84 |
1 files changed, 8 insertions, 76 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 0cc8e77d9ba..b48f1ecb6bb 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -1,5 +1,5 @@ /* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */ -/* $OpenBSD: vmstat.c,v 1.92 2004/11/09 23:20:18 pedro Exp $ */ +/* $OpenBSD: vmstat.c,v 1.93 2004/11/28 14:05:24 miod Exp $ */ /* * Copyright (c) 1980, 1986, 1991, 1993 @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)vmstat.c 8.1 (Berkeley) 6/6/93"; #else -static const char rcsid[] = "$OpenBSD: vmstat.c,v 1.92 2004/11/09 23:20:18 pedro Exp $"; +static const char rcsid[] = "$OpenBSD: vmstat.c,v 1.93 2004/11/28 14:05:24 miod Exp $"; #endif #endif /* not lint */ @@ -94,15 +94,7 @@ struct nlist namelist[] = { { "_pool_head" }, #define X_ALLEVENTS 8 /* no sysctl */ { "_allevents" }, -#define X_INTRNAMES 9 /* no sysctl */ - { "_intrnames" }, -#define X_EINTRNAMES 10 /* no sysctl */ - { "_eintrnames" }, -#define X_INTRCNT 11 /* no sysctl */ - { "_intrcnt" }, -#define X_EINTRCNT 12 /* no sysctl */ - { "_eintrcnt" }, -#define X_END 13 /* no sysctl */ +#define X_END 9 /* no sysctl */ { "" }, }; @@ -707,21 +699,9 @@ cpustats(void) (void)printf("%2.0f", cur.cp_time[CP_IDLE] * pct); } -static void dointr_sysctl(void); -static void dointr_kvm(void); - void dointr(void) { - if (nlistf == NULL && memf == NULL) - dointr_sysctl(); - else - dointr_kvm(); -} - -static void -dointr_sysctl(void) -{ struct evcntlist allevents; struct evcnt evcnt, *evptr; struct device dev; @@ -734,6 +714,11 @@ dointr_sysctl(void) size_t siz; int i; + if (nlistf != NULL || memf != NULL) { + errx(1, + "interrupt statistics are only available on live kernels"); + } + uptime = getuptime(); mib[0] = CTL_KERN; @@ -813,59 +798,6 @@ dointr_sysctl(void) inttotal / uptime); } -static void -dointr_kvm(void) -{ - long *intrcnt; - u_int64_t inttotal; - time_t uptime; - int nintr, inamlen; - char *intrname; - struct evcntlist allevents; - struct evcnt evcnt, *evptr; - struct device dev; - - uptime = getuptime(); - nintr = namelist[X_EINTRCNT].n_value - namelist[X_INTRCNT].n_value; - inamlen = - namelist[X_EINTRNAMES].n_value - namelist[X_INTRNAMES].n_value; - intrcnt = malloc((size_t)nintr); - intrname = malloc((size_t)inamlen); - if (intrcnt == NULL || intrname == NULL) - err(1, "malloc"); - kread(X_INTRCNT, intrcnt, (size_t)nintr); - kread(X_INTRNAMES, intrname, (size_t)inamlen); - (void)printf("%-16s %20s %8s\n", "interrupt", "total", "rate"); - inttotal = 0; - nintr /= sizeof(long); - while (--nintr >= 0) { - if (*intrcnt) - (void)printf("%-16.16s %20lu %8lu\n", intrname, - *intrcnt, *intrcnt / uptime); - intrname += strlen(intrname) + 1; - inttotal += *intrcnt++; - } - kread(X_ALLEVENTS, &allevents, sizeof allevents); - evptr = allevents.tqh_first; - while (evptr) { - if (kvm_read(kd, (long)evptr, (void *)&evcnt, - sizeof evcnt) != sizeof evcnt) - errx(1, "event chain trashed: %s", kvm_geterr(kd)); - if (strcmp(evcnt.ev_name, "intr") == 0) { - if (kvm_read(kd, (long)evcnt.ev_dev, (void *)&dev, - sizeof dev) != sizeof dev) - errx(1, "event chain trashed: %s", kvm_geterr(kd)); - if (evcnt.ev_count) - (void)printf("%-16.16s %20lu %8lu\n", dev.dv_xname, - evcnt.ev_count, evcnt.ev_count / uptime); - inttotal += evcnt.ev_count; - } - evptr = evcnt.ev_list.tqe_next; - } - (void)printf("%-16s %20llu %8llu\n", "Total", inttotal, - inttotal / uptime); -} - /* * These names are defined in <sys/malloc.h>. */ |