summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2004-06-11 05:54:55 +0000
committerderaadt <deraadt@openbsd.org>2004-06-11 05:54:55 +0000
commit55fc245cc3674245c8dabcdebc18c848d088ed00 (patch)
tree04f7f40168200fc6df3275767ebcc36a5778d557
parentonly print /# if > 1 cpu on a machine (diff)
downloadwireguard-openbsd-55fc245cc3674245c8dabcdebc18c848d088ed00.tar.xz
wireguard-openbsd-55fc245cc3674245c8dabcdebc18c848d088ed00.zip
on i386 machines, attempt to peek inside apic_intrhand[] as well, so that
MP machines get interrupt counters. will be replaced by a MI subsystem one day. most code from drahn, few final bugs fixed by me
-rw-r--r--usr.bin/systat/vmstat.c50
-rw-r--r--usr.bin/vmstat/vmstat.c44
2 files changed, 83 insertions, 11 deletions
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index 29acfba60a7..3ee13725395 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmstat.c,v 1.47 2004/05/22 18:06:12 henning Exp $ */
+/* $OpenBSD: vmstat.c,v 1.48 2004/06/11 05:55:43 deraadt Exp $ */
/* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */
/*-
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#endif
-static char rcsid[] = "$OpenBSD: vmstat.c,v 1.47 2004/05/22 18:06:12 henning Exp $";
+static char rcsid[] = "$OpenBSD: vmstat.c,v 1.48 2004/06/11 05:55:43 deraadt Exp $";
#endif /* not lint */
/*
@@ -147,6 +147,8 @@ static struct nlist namelist[] = {
#if defined(__i386__)
#define X_INTRHAND 4 /* no sysctl */
{ "_intrhand" },
+#define X_APICINTRHAND 5 /* no sysctl */
+ { "_apic_intrhand" },
#endif
{ "" },
};
@@ -186,6 +188,10 @@ initkre(void)
if (namelist[0].n_type == 0) {
if ((ret = kvm_nlist(kd, namelist)) == -1)
errx(1, "%s", kvm_geterr(kd));
+#if defined(__i386__)
+ else if (ret > 1 && namelist[X_APICINTRHAND].n_value == 0)
+ nlisterr(namelist);
+#endif
else if (ret)
nlisterr(namelist);
if (namelist[0].n_type == 0) {
@@ -199,6 +205,7 @@ initkre(void)
if (nintr == 0) {
#if defined(__i386__)
struct intrhand *intrhand[16], *ihp, ih;
+ struct intrhand *apicintrhand[256];
char iname[16];
int namelen, n;
@@ -213,6 +220,20 @@ initkre(void)
ihp = ih.ih_next;
}
}
+ if (namelist[X_APICINTRHAND].n_value) {
+ NREAD(X_APICINTRHAND, apicintrhand, sizeof(apicintrhand));
+ for (namelen = 0, i = 0; i < 256; i++) {
+ ihp = apicintrhand[i];
+ while (ihp) {
+ nintr++;
+ KREAD(ihp, &ih, sizeof(ih));
+ KREAD(ih.ih_what, iname, 16);
+ namelen += strlen(iname) + 1;
+ printf("apic handler %x %s\n", i, iname);
+ ihp = ih.ih_next;
+ }
+ }
+ }
intrloc = calloc(nintr, sizeof (long));
intrname = calloc(nintr, sizeof (char *));
cp = intrnamebuf = malloc(namelen);
@@ -227,6 +248,19 @@ initkre(void)
ihp = ih.ih_next;
}
}
+ if (namelist[X_APICINTRHAND].n_value) {
+ for (i = 0, n = 0; i < 256; i++) {
+ ihp = apicintrhand[i];
+ while (ihp) {
+ KREAD(ihp, &ih, sizeof(ih));
+ KREAD(ih.ih_what, iname, 16);
+ intrname[n++] = cp;
+ strlcpy(cp, iname, intrnamebuf + namelen - cp);
+ cp += strlen(iname) + 1;
+ ihp = ih.ih_next;
+ }
+ }
+ }
#else
nintr = (namelist[X_EINTRCNT].n_value -
namelist[X_INTRCNT].n_value) / sizeof (int);
@@ -638,6 +672,7 @@ getinfo(struct Info *s, enum state st)
size_t size;
#if defined(__i386__)
struct intrhand *intrhand[16], *ihp, ih;
+ struct intrhand *apicintrhand[256];
int i, n;
#endif
@@ -652,6 +687,17 @@ getinfo(struct Info *s, enum state st)
ihp = ih.ih_next;
}
}
+ if (namelist[X_APICINTRHAND].n_value) {
+ NREAD(X_APICINTRHAND, apicintrhand, sizeof(apicintrhand));
+ for (i = 0, n = 0; i < 256; i++) {
+ ihp = apicintrhand[i];
+ while (ihp) {
+ KREAD(ihp, &ih, sizeof(ih));
+ s->intrcnt[n++] = ih.ih_count;
+ ihp = ih.ih_next;
+ }
+ }
+ }
#else
NREAD(X_INTRCNT, s->intrcnt, nintr * sizeof(int));
#endif
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 05b47fe6865..d17941f0257 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.82 2004/02/15 02:45:47 tedu Exp $ */
+/* $OpenBSD: vmstat.c,v 1.83 2004/06/11 05:54:55 deraadt 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.82 2004/02/15 02:45:47 tedu Exp $";
+static const char rcsid[] = "$OpenBSD: vmstat.c,v 1.83 2004/06/11 05:54:55 deraadt Exp $";
#endif
#endif /* not lint */
@@ -106,7 +106,9 @@ struct nlist namelist[] = {
#if defined(__i386__)
#define X_INTRHAND (X_END) /* no sysctl */
{ "_intrhand" },
-#define X_INTRSTRAY (X_END+1) /* no sysctl */
+#define X_APICINTRHAND (X_END+1) /* no sysctl */
+ { "_apic_intrhand" },
+#define X_INTRSTRAY (X_END+2) /* no sysctl */
{ "_intrstray" },
#endif
{ "" },
@@ -705,6 +707,7 @@ void
dointr(void)
{
struct intrhand *intrhand[16], *ihp, ih;
+ struct intrhand *apicintrhand[256];
u_long inttotal = 0;
time_t uptime;
u_long intrstray[16];
@@ -724,17 +727,40 @@ dointr(void)
ihp = intrhand[i];
while (ihp) {
if (kvm_read(kd, (u_long)ihp, &ih,
- sizeof(ih)) != sizeof(ih))
+ sizeof(ih)) != sizeof(ih))
errx(1, "vmstat: ih: %s",
- kvm_geterr(kd));
+ kvm_geterr(kd));
if (kvm_read(kd, (u_long)ih.ih_what, iname,
- 16) != 16)
+ 16) != 16)
errx(1, "vmstat: ih_what: %s",
- kvm_geterr(kd));
+ kvm_geterr(kd));
snprintf(fname, sizeof fname, "irq%d/%s", i,
- iname);
+ iname);
printf("%-16.16s %10lu %8lu\n", fname,
- ih.ih_count, ih.ih_count / uptime);
+ ih.ih_count, ih.ih_count / uptime);
+ inttotal += ih.ih_count;
+ ihp = ih.ih_next;
+ }
+ }
+ }
+ {
+ kread(X_APICINTRHAND, apicintrhand, sizeof(apicintrhand));
+
+ for (i = 0; i < 256; i++) {
+ ihp = apicintrhand[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));
+ snprintf(fname, sizeof fname, "irq%d/%s", i,
+ iname);
+ printf("%-16.16s %10lu %8lu\n", fname,
+ ih.ih_count, ih.ih_count / uptime);
inttotal += ih.ih_count;
ihp = ih.ih_next;
}