Thu Apr 1 05:33:51 2021 UTC ()
Now that ports that use legacy intrcnt interrupt accounting have event
counters to show that data, for the live kernel case just show INTR
events for "vmstat -i".


(simonb)
diff -r1.243 -r1.244 src/usr.bin/vmstat/vmstat.c

cvs diff -r1.243 -r1.244 src/usr.bin/vmstat/vmstat.c (expand / switch to unified diff)

--- src/usr.bin/vmstat/vmstat.c 2021/03/03 08:25:16 1.243
+++ src/usr.bin/vmstat/vmstat.c 2021/04/01 05:33:50 1.244
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vmstat.c,v 1.243 2021/03/03 08:25:16 simonb Exp $ */ 1/* $NetBSD: vmstat.c,v 1.244 2021/04/01 05:33:50 simonb Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020 4 * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
5 * The NetBSD Foundation, Inc. 5 * The NetBSD Foundation, Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to The NetBSD Foundation by: 8 * This code is derived from software contributed to The NetBSD Foundation by:
9 * - Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9 * - Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
10 * NASA Ames Research Center. 10 * NASA Ames Research Center.
11 * - Simon Burge and Luke Mewburn of Wasabi Systems, Inc. 11 * - Simon Burge and Luke Mewburn of Wasabi Systems, Inc.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions 14 * modification, are permitted provided that the following conditions
@@ -61,27 +61,27 @@ @@ -61,27 +61,27 @@
61 * SUCH DAMAGE. 61 * SUCH DAMAGE.
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65#ifndef lint 65#ifndef lint
66__COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1991, 1993\ 66__COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1991, 1993\
67 The Regents of the University of California. All rights reserved."); 67 The Regents of the University of California. All rights reserved.");
68#endif /* not lint */ 68#endif /* not lint */
69 69
70#ifndef lint 70#ifndef lint
71#if 0 71#if 0
72static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95"; 72static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95";
73#else 73#else
74__RCSID("$NetBSD: vmstat.c,v 1.243 2021/03/03 08:25:16 simonb Exp $"); 74__RCSID("$NetBSD: vmstat.c,v 1.244 2021/04/01 05:33:50 simonb Exp $");
75#endif 75#endif
76#endif /* not lint */ 76#endif /* not lint */
77 77
78#define __POOL_EXPOSE 78#define __POOL_EXPOSE
79#define __NAMECACHE_PRIVATE 79#define __NAMECACHE_PRIVATE
80 80
81#include <sys/param.h> 81#include <sys/param.h>
82#include <sys/types.h> 82#include <sys/types.h>
83#include <sys/mount.h> 83#include <sys/mount.h>
84#include <sys/uio.h> 84#include <sys/uio.h>
85 85
86#include <sys/buf.h> 86#include <sys/buf.h>
87#include <sys/evcnt.h> 87#include <sys/evcnt.h>
@@ -1249,26 +1249,31 @@ cpustats(int *ovflwp) @@ -1249,26 +1249,31 @@ cpustats(int *ovflwp)
1249 stat_sy); 1249 stat_sy);
1250 PRWORD(ovflw, " %*.0f", 3, 1, stat_id); 1250 PRWORD(ovflw, " %*.0f", 3, 1, stat_id);
1251 *ovflwp = ovflw; 1251 *ovflwp = ovflw;
1252} 1252}
1253 1253
1254void 1254void
1255dointr(int verbose) 1255dointr(int verbose)
1256{ 1256{
1257 unsigned long *intrcnt, *ointrcnt; 1257 unsigned long *intrcnt, *ointrcnt;
1258 unsigned long long inttotal, uptime; 1258 unsigned long long inttotal, uptime;
1259 int nintr, inamlen; 1259 int nintr, inamlen;
1260 char *intrname, *ointrname; 1260 char *intrname, *ointrname;
1261 1261
 1262 if (memf == NULL) {
 1263 doevcnt(verbose, EVCNT_TYPE_INTR);
 1264 return;
 1265 }
 1266
1262 inttotal = 0; 1267 inttotal = 0;
1263 uptime = getuptime(); 1268 uptime = getuptime();
1264 nintr = intrnl[X_EINTRCNT].n_value - intrnl[X_INTRCNT].n_value; 1269 nintr = intrnl[X_EINTRCNT].n_value - intrnl[X_INTRCNT].n_value;
1265 inamlen = intrnl[X_EINTRNAMES].n_value - intrnl[X_INTRNAMES].n_value; 1270 inamlen = intrnl[X_EINTRNAMES].n_value - intrnl[X_INTRNAMES].n_value;
1266 if (nintr != 0 && inamlen != 0) { 1271 if (nintr != 0 && inamlen != 0) {
1267 (void)printf("%-34s %16s %8s\n", "interrupt", "total", "rate"); 1272 (void)printf("%-34s %16s %8s\n", "interrupt", "total", "rate");
1268 1273
1269 ointrcnt = intrcnt = malloc((size_t)nintr); 1274 ointrcnt = intrcnt = malloc((size_t)nintr);
1270 ointrname = intrname = malloc((size_t)inamlen); 1275 ointrname = intrname = malloc((size_t)inamlen);
1271 if (intrcnt == NULL || intrname == NULL) 1276 if (intrcnt == NULL || intrname == NULL)
1272 errx(1, "%s", ""); 1277 errx(1, "%s", "");
1273 kread(intrnl, X_INTRCNT, intrcnt, (size_t)nintr); 1278 kread(intrnl, X_INTRCNT, intrcnt, (size_t)nintr);
1274 kread(intrnl, X_INTRNAMES, intrname, (size_t)inamlen); 1279 kread(intrnl, X_INTRNAMES, intrname, (size_t)inamlen);