Annotation of src/usr.bin/vmstat/vmstat.c, Revision 1.137
1.11 deraadt 1: /* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */
1.137 ! tedu 2: /* $OpenBSD: vmstat.c,v 1.136 2015/01/16 06:40:14 deraadt Exp $ */
1.1 deraadt 3:
4: /*
5: * Copyright (c) 1980, 1986, 1991, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
1.77 millert 16: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 17: * may be used to endorse or promote products derived from this software
18: * without specific prior written permission.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: * SUCH DAMAGE.
31: */
1.48 art 32:
1.136 deraadt 33: #include <sys/param.h> /* MAXCOMLEN */
1.1 deraadt 34: #include <sys/time.h>
35: #include <sys/proc.h>
36: #include <sys/namei.h>
37: #include <sys/malloc.h>
38: #include <sys/fcntl.h>
39: #include <sys/ioctl.h>
40: #include <sys/sysctl.h>
41: #include <sys/device.h>
1.48 art 42: #include <sys/pool.h>
1.133 miod 43: #include <sys/sched.h>
1.128 mpi 44: #include <sys/vmmeter.h>
45:
1.1 deraadt 46: #include <time.h>
47: #include <nlist.h>
48: #include <kvm.h>
1.21 millert 49: #include <err.h>
1.1 deraadt 50: #include <errno.h>
51: #include <unistd.h>
52: #include <signal.h>
53: #include <stdio.h>
54: #include <ctype.h>
55: #include <stdlib.h>
56: #include <string.h>
57: #include <paths.h>
58: #include <limits.h>
1.6 tholo 59: #include "dkstats.h"
1.29 art 60:
1.1 deraadt 61: struct nlist namelist[] = {
1.70 deraadt 62: #define X_UVMEXP 0 /* sysctl */
1.29 art 63: { "_uvmexp" },
1.124 guenther 64: #define X_TIME_UPTIME 1
65: { "_time_uptime" },
1.70 deraadt 66: #define X_NCHSTATS 2 /* sysctl */
1.1 deraadt 67: { "_nchstats" },
1.70 deraadt 68: #define X_KMEMSTAT 3 /* sysctl */
69: { "_kmemstats" },
70: #define X_KMEMBUCKETS 4 /* sysctl */
71: { "_bucket" },
72: #define X_FORKSTAT 5 /* sysctl */
73: { "_forkstat" },
74: #define X_NSELCOLL 6 /* sysctl */
75: { "_nselcoll" },
76: #define X_POOLHEAD 7 /* sysctl */
77: { "_pool_head" },
1.124 guenther 78: #define X_NAPTIME 8
79: { "_naptime" },
1.1 deraadt 80: { "" },
81: };
82:
1.6 tholo 83: /* Objects defined in dkstats.c */
1.73 tdeval 84: extern struct _disk cur, last;
1.10 deraadt 85: extern char **dr_name;
86: extern int *dk_select, dk_ndrive;
1.1 deraadt 87:
1.29 art 88: struct uvmexp uvmexp, ouvmexp;
1.6 tholo 89: int ndrives;
1.1 deraadt 90:
91: int winlines = 20;
92:
93: kvm_t *kd;
94:
95: #define FORKSTAT 0x01
96: #define INTRSTAT 0x02
97: #define MEMSTAT 0x04
98: #define SUMSTAT 0x08
99: #define TIMESTAT 0x10
100: #define VMSTAT 0x20
101:
1.66 millert 102: void cpustats(void);
1.101 otto 103: time_t getuptime(void);
1.66 millert 104: void dkstats(void);
105: void dointr(void);
106: void domem(void);
107: void dopool(void);
108: void dosum(void);
109: void dovmstat(u_int, int);
110: void kread(int, void *, size_t);
111: void usage(void);
112: void dotimes(void);
113: void doforkst(void);
1.101 otto 114: void needhdr(int);
1.112 naddy 115: int pct(int64_t, int64_t);
1.66 millert 116: void printhdr(void);
1.1 deraadt 117:
1.66 millert 118: char **choosedrives(char **);
1.10 deraadt 119:
120: /* Namelist and memory file names. */
121: char *nlistf, *memf;
1.6 tholo 122:
1.50 art 123: extern char *__progname;
124:
1.65 art 125: int verbose = 0;
1.87 aaron 126: int zflag = 0;
1.65 art 127:
1.21 millert 128: int
1.72 deraadt 129: main(int argc, char *argv[])
1.1 deraadt 130: {
1.102 deraadt 131: char errbuf[_POSIX2_LINE_MAX];
1.126 chl 132: int c, todo = 0, reps = 0;
1.102 deraadt 133: const char *errstr;
134: u_int interval = 0;
1.1 deraadt 135:
1.87 aaron 136: while ((c = getopt(argc, argv, "c:fiM:mN:stw:vz")) != -1) {
1.1 deraadt 137: switch (c) {
138: case 'c':
1.137 ! tedu 139: reps = strtonum(optarg, 0, INT_MAX, &errstr);
! 140: if (errstr)
! 141: errx(1, "-c %s: %s", optarg, errstr);
1.1 deraadt 142: break;
143: case 'f':
144: todo |= FORKSTAT;
145: break;
146: case 'i':
147: todo |= INTRSTAT;
148: break;
149: case 'M':
150: memf = optarg;
151: break;
152: case 'm':
153: todo |= MEMSTAT;
154: break;
155: case 'N':
156: nlistf = optarg;
157: break;
158: case 's':
159: todo |= SUMSTAT;
160: break;
161: case 't':
162: todo |= TIMESTAT;
163: break;
164: case 'w':
1.102 deraadt 165: interval = (u_int)strtonum(optarg, 0, 1000, &errstr);
166: if (errstr)
1.104 pedro 167: errx(1, "-w %s: %s", optarg, errstr);
1.1 deraadt 168: break;
1.65 art 169: case 'v':
170: verbose = 1;
171: break;
1.87 aaron 172: case 'z':
173: zflag = 1;
174: break;
1.1 deraadt 175: case '?':
176: default:
177: usage();
178: }
179: }
180: argc -= optind;
181: argv += optind;
182:
183: if (todo == 0)
184: todo = VMSTAT;
185:
1.56 angelos 186: if (nlistf != NULL || memf != NULL) {
187:
188: kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
189: if (kd == 0)
190: errx(1, "kvm_openfiles: %s", errbuf);
191:
192: if ((c = kvm_nlist(kd, namelist)) != 0) {
193:
194: if (c > 0) {
195: (void)fprintf(stderr,
196: "%s: undefined symbols:", __progname);
197: for (c = 0;
198: c < sizeof(namelist)/sizeof(namelist[0]);
199: c++)
200: if (namelist[c].n_type == 0)
201: fprintf(stderr, " %s",
202: namelist[c].n_name);
203: (void)fputc('\n', stderr);
204: exit(1);
205: } else
206: errx(1, "kvm_nlist: %s", kvm_geterr(kd));
207: }
1.115 lum 208: }
1.1 deraadt 209:
210: if (todo & VMSTAT) {
211: struct winsize winsize;
212:
1.6 tholo 213: dkinit(0); /* Initialize disk stats, no disks selected. */
214: argv = choosedrives(argv); /* Select disks. */
1.1 deraadt 215: winsize.ws_row = 0;
1.102 deraadt 216: (void) ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize);
1.1 deraadt 217: if (winsize.ws_row > 0)
218: winlines = winsize.ws_row;
219:
220: }
1.25 deraadt 221:
1.1 deraadt 222: #define BACKWARD_COMPATIBILITY
223: #ifdef BACKWARD_COMPATIBILITY
224: if (*argv) {
1.102 deraadt 225: interval = (u_int)strtonum(*argv, 0, 1000, &errstr);
226: if (errstr)
1.137 ! tedu 227: errx(1, "interval %s: %s", *argv, errstr);
1.103 deraadt 228:
1.137 ! tedu 229: if (*++argv) {
! 230: reps = strtonum(*argv, 0, INT_MAX, &errstr);
! 231: if (errstr)
! 232: errx(1, "reps %s: %s", *argv, errstr);
! 233: }
1.1 deraadt 234: }
235: #endif
236:
237: if (interval) {
238: if (!reps)
239: reps = -1;
240: } else if (reps)
241: interval = 1;
242:
243: if (todo & FORKSTAT)
244: doforkst();
1.48 art 245: if (todo & MEMSTAT) {
1.1 deraadt 246: domem();
1.48 art 247: dopool();
248: }
1.1 deraadt 249: if (todo & SUMSTAT)
250: dosum();
251: if (todo & TIMESTAT)
252: dotimes();
253: if (todo & INTRSTAT)
254: dointr();
255: if (todo & VMSTAT)
256: dovmstat(interval, reps);
257: exit(0);
258: }
259:
260: char **
1.72 deraadt 261: choosedrives(char **argv)
1.1 deraadt 262: {
1.62 mpech 263: int i;
1.1 deraadt 264:
265: /*
266: * Choose drives to be displayed. Priority goes to (in order) drives
267: * supplied as arguments, default drives. If everything isn't filled
268: * in and there are drives not taken care of, display the first few
269: * that fit.
270: */
271: #define BACKWARD_COMPATIBILITY
272: for (ndrives = 0; *argv; ++argv) {
273: #ifdef BACKWARD_COMPATIBILITY
1.127 deraadt 274: if (isdigit((unsigned char)**argv))
1.1 deraadt 275: break;
276: #endif
277: for (i = 0; i < dk_ndrive; i++) {
278: if (strcmp(dr_name[i], *argv))
279: continue;
1.6 tholo 280: dk_select[i] = 1;
1.1 deraadt 281: ++ndrives;
282: break;
283: }
1.137 ! tedu 284: if (i == dk_ndrive)
! 285: errx(1, "invalid interval or drive name: %s", *argv);
1.1 deraadt 286: }
1.64 deraadt 287: for (i = 0; i < dk_ndrive && ndrives < 2; i++) {
1.6 tholo 288: if (dk_select[i])
1.1 deraadt 289: continue;
1.6 tholo 290: dk_select[i] = 1;
1.1 deraadt 291: ++ndrives;
292: }
293: return(argv);
294: }
295:
1.19 deraadt 296: time_t
1.72 deraadt 297: getuptime(void)
1.1 deraadt 298: {
1.124 guenther 299: struct timespec uptime;
300: time_t time_uptime, naptime;
1.1 deraadt 301:
1.124 guenther 302: if (nlistf == NULL && memf == NULL) {
303: if (clock_gettime(CLOCK_UPTIME, &uptime) == -1)
304: err(1, "clock_gettime");
305: return (uptime.tv_sec);
1.50 art 306: }
307:
1.124 guenther 308: kread(X_NAPTIME, &naptime, sizeof(naptime));
309: kread(X_TIME_UPTIME, &time_uptime, sizeof(time_uptime));
310: return (time_uptime - naptime);
1.1 deraadt 311: }
312:
1.105 cloder 313: int hz;
314: volatile sig_atomic_t hdrcnt;
1.1 deraadt 315:
316: void
1.72 deraadt 317: dovmstat(u_int interval, int reps)
1.1 deraadt 318: {
319: time_t uptime, halfuptime;
1.50 art 320: struct clockinfo clkinfo;
1.102 deraadt 321: struct vmtotal total;
1.1 deraadt 322: size_t size;
1.102 deraadt 323: int mib[2];
1.1 deraadt 324:
325: uptime = getuptime();
326: halfuptime = uptime / 2;
327: (void)signal(SIGCONT, needhdr);
328:
1.50 art 329: mib[0] = CTL_KERN;
330: mib[1] = KERN_CLOCKRATE;
331: size = sizeof(clkinfo);
332: if (sysctl(mib, 2, &clkinfo, &size, NULL, 0) < 0) {
1.56 angelos 333: warn("could not read kern.clockrate");
1.50 art 334: return;
335: }
336: hz = clkinfo.stathz;
1.1 deraadt 337:
338: for (hdrcnt = 1;;) {
1.6 tholo 339: /* Read new disk statistics */
340: dkreadstats();
1.73 tdeval 341: if (!--hdrcnt || last.dk_ndrive != cur.dk_ndrive)
342: printhdr();
1.56 angelos 343: if (nlistf == NULL && memf == NULL) {
344: size = sizeof(struct uvmexp);
1.52 angelos 345: mib[0] = CTL_VM;
346: mib[1] = VM_UVMEXP;
347: if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) {
1.56 angelos 348: warn("could not get vm.uvmexp");
349: bzero(&uvmexp, sizeof(struct uvmexp));
1.52 angelos 350: }
1.56 angelos 351: } else {
352: kread(X_UVMEXP, &uvmexp, sizeof(struct uvmexp));
1.52 angelos 353: }
1.1 deraadt 354: size = sizeof(total);
355: mib[0] = CTL_VM;
356: mib[1] = VM_METER;
357: if (sysctl(mib, 2, &total, &size, NULL, 0) < 0) {
1.56 angelos 358: warn("could not read vm.vmmeter");
1.1 deraadt 359: bzero(&total, sizeof(total));
360: }
1.114 tedu 361: (void)printf(" %u %u %u ",
1.1 deraadt 362: total.t_rq - 1, total.t_dw + total.t_pw, total.t_sw);
1.123 guenther 363: #define rate(x) ((unsigned)((((unsigned)x) + halfuptime) / uptime)) /* round */
1.102 deraadt 364: #define pgtok(a) ((a) * ((unsigned int)uvmexp.pagesize >> 10))
1.114 tedu 365: (void)printf("%6u %7u ",
1.128 mpi 366: pgtok(uvmexp.active + uvmexp.swpginuse),
367: pgtok(uvmexp.free));
1.106 sobrado 368: (void)printf("%4u ", rate(uvmexp.faults - ouvmexp.faults));
1.29 art 369: (void)printf("%3u ", rate(uvmexp.pdreact - ouvmexp.pdreact));
370: (void)printf("%3u ", rate(uvmexp.pageins - ouvmexp.pageins));
371: (void)printf("%3u %3u ",
372: rate(uvmexp.pdpageouts - ouvmexp.pdpageouts), 0);
373: (void)printf("%3u ", rate(uvmexp.pdscans - ouvmexp.pdscans));
374: dkstats();
1.64 deraadt 375: (void)printf("%4u %5u %4u ",
1.29 art 376: rate(uvmexp.intrs - ouvmexp.intrs),
377: rate(uvmexp.syscalls - ouvmexp.syscalls),
378: rate(uvmexp.swtch - ouvmexp.swtch));
1.1 deraadt 379: cpustats();
380: (void)printf("\n");
381: (void)fflush(stdout);
382: if (reps >= 0 && --reps <= 0)
383: break;
1.29 art 384: ouvmexp = uvmexp;
1.1 deraadt 385: uptime = interval;
386: /*
387: * We round upward to avoid losing low-frequency events
388: * (i.e., >= 1 per interval but < 1 per second).
389: */
1.14 deraadt 390: halfuptime = uptime == 1 ? 0 : (uptime + 1) / 2;
1.1 deraadt 391: (void)sleep(interval);
392: }
393: }
394:
1.21 millert 395: void
1.72 deraadt 396: printhdr(void)
1.1 deraadt 397: {
1.62 mpech 398: int i;
1.114 tedu 399: static int printedhdr;
400:
401: if (printedhdr && !isatty(STDOUT_FILENO))
402: return;
1.1 deraadt 403:
1.108 sobrado 404: (void)printf(" procs memory page%*s", 20, "");
1.6 tholo 405: if (ndrives > 0)
1.106 sobrado 406: (void)printf("%s %*straps cpu\n",
1.6 tholo 407: ((ndrives > 1) ? "disks" : "disk"),
1.106 sobrado 408: ((ndrives > 1) ? ndrives * 4 - 5 : 0), "");
1.1 deraadt 409: else
1.106 sobrado 410: (void)printf("%*s traps cpu\n",
1.6 tholo 411: ndrives * 3, "");
412:
1.106 sobrado 413: (void)printf(" r b w avm fre flt re pi po fr sr ");
1.1 deraadt 414: for (i = 0; i < dk_ndrive; i++)
1.6 tholo 415: if (dk_select[i])
1.67 ho 416: (void)printf("%c%c%c ", dr_name[i][0],
1.64 deraadt 417: dr_name[i][1],
1.1 deraadt 418: dr_name[i][strlen(dr_name[i]) - 1]);
1.79 tedu 419: (void)printf(" int sys cs us sy id\n");
1.1 deraadt 420: hdrcnt = winlines - 2;
1.114 tedu 421: printedhdr = 1;
1.1 deraadt 422: }
423:
424: /*
425: * Force a header to be prepended to the next output.
426: */
1.90 deraadt 427: /* ARGSUSED */
1.1 deraadt 428: void
1.78 deraadt 429: needhdr(int signo)
1.1 deraadt 430: {
431:
432: hdrcnt = 1;
433: }
434:
435: void
1.72 deraadt 436: dotimes(void)
1.1 deraadt 437: {
438: u_int pgintime, rectime;
1.102 deraadt 439: size_t size;
1.52 angelos 440: int mib[2];
1.1 deraadt 441:
1.56 angelos 442: /* XXX Why are these set to 0 ? This doesn't look right. */
1.12 tholo 443: pgintime = 0;
444: rectime = 0;
1.56 angelos 445:
446: if (nlistf == NULL && memf == NULL) {
447: size = sizeof(struct uvmexp);
1.52 angelos 448: mib[0] = CTL_VM;
449: mib[1] = VM_UVMEXP;
450: if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) {
1.56 angelos 451: warn("could not read vm.uvmexp");
452: bzero(&uvmexp, sizeof(struct uvmexp));
1.52 angelos 453: }
1.56 angelos 454: } else {
455: kread(X_UVMEXP, &uvmexp, sizeof(struct uvmexp));
1.52 angelos 456: }
457:
1.29 art 458: (void)printf("%u reactivates, %u total time (usec)\n",
459: uvmexp.pdreact, rectime);
1.89 miod 460: if (uvmexp.pdreact != 0)
461: (void)printf("average: %u usec / reclaim\n",
462: rectime / uvmexp.pdreact);
1.29 art 463: (void)printf("\n");
464: (void)printf("%u page ins, %u total time (msec)\n",
465: uvmexp.pageins, pgintime / 10);
1.89 miod 466: if (uvmexp.pageins != 0)
467: (void)printf("average: %8.1f msec / page in\n",
1.103 deraadt 468: pgintime / (uvmexp.pageins * 10.0));
1.1 deraadt 469: }
470:
1.21 millert 471: int
1.112 naddy 472: pct(int64_t top, int64_t bot)
1.1 deraadt 473: {
1.102 deraadt 474: int ans;
1.1 deraadt 475:
476: if (bot == 0)
477: return(0);
1.112 naddy 478: ans = top * 100 / bot;
1.1 deraadt 479: return (ans);
480: }
481:
482: void
1.72 deraadt 483: dosum(void)
1.1 deraadt 484: {
485: struct nchstats nchstats;
1.102 deraadt 486: int mib[2], nselcoll;
1.112 naddy 487: long long nchtotal;
1.52 angelos 488: size_t size;
1.1 deraadt 489:
1.56 angelos 490: if (nlistf == NULL && memf == NULL) {
491: size = sizeof(struct uvmexp);
1.52 angelos 492: mib[0] = CTL_VM;
493: mib[1] = VM_UVMEXP;
494: if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) {
1.56 angelos 495: warn("could not read vm.uvmexp");
496: bzero(&uvmexp, sizeof(struct uvmexp));
1.52 angelos 497: }
1.56 angelos 498: } else {
499: kread(X_UVMEXP, &uvmexp, sizeof(struct uvmexp));
1.52 angelos 500: }
501:
1.32 art 502: /* vm_page constants */
1.35 hugh 503: (void)printf("%11u bytes per page\n", uvmexp.pagesize);
1.32 art 504:
505: /* vm_page counters */
1.35 hugh 506: (void)printf("%11u pages managed\n", uvmexp.npages);
507: (void)printf("%11u pages free\n", uvmexp.free);
508: (void)printf("%11u pages active\n", uvmexp.active);
509: (void)printf("%11u pages inactive\n", uvmexp.inactive);
510: (void)printf("%11u pages being paged out\n", uvmexp.paging);
511: (void)printf("%11u pages wired\n", uvmexp.wired);
1.71 art 512: (void)printf("%11u pages zeroed\n", uvmexp.zeropages);
1.35 hugh 513: (void)printf("%11u pages reserved for pagedaemon\n",
1.48 art 514: uvmexp.reserve_pagedaemon);
1.35 hugh 515: (void)printf("%11u pages reserved for kernel\n",
1.48 art 516: uvmexp.reserve_kernel);
1.32 art 517:
518: /* swap */
1.35 hugh 519: (void)printf("%11u swap pages\n", uvmexp.swpages);
520: (void)printf("%11u swap pages in use\n", uvmexp.swpginuse);
521: (void)printf("%11u total anon's in system\n", uvmexp.nanon);
522: (void)printf("%11u free anon's\n", uvmexp.nfreeanon);
1.32 art 523:
524: /* stat counters */
1.35 hugh 525: (void)printf("%11u page faults\n", uvmexp.faults);
526: (void)printf("%11u traps\n", uvmexp.traps);
527: (void)printf("%11u interrupts\n", uvmexp.intrs);
528: (void)printf("%11u cpu context switches\n", uvmexp.swtch);
1.95 mickey 529: (void)printf("%11u fpu context switches\n", uvmexp.fpswtch);
1.35 hugh 530: (void)printf("%11u software interrupts\n", uvmexp.softs);
531: (void)printf("%11u syscalls\n", uvmexp.syscalls);
532: (void)printf("%11u pagein operations\n", uvmexp.pageins);
533: (void)printf("%11u forks\n", uvmexp.forks);
534: (void)printf("%11u forks where vmspace is shared\n",
1.48 art 535: uvmexp.forks_sharevm);
1.97 pedro 536: (void)printf("%11u kernel map entries\n", uvmexp.kmapent);
1.132 kettenis 537: (void)printf("%11u zeroed page hits\n", uvmexp.pga_zerohit);
538: (void)printf("%11u zeroed page misses\n", uvmexp.pga_zeromiss);
1.32 art 539:
540: /* daemon counters */
1.64 deraadt 541: (void)printf("%11u number of times the pagedaemon woke up\n",
1.48 art 542: uvmexp.pdwoke);
1.35 hugh 543: (void)printf("%11u revolutions of the clock hand\n", uvmexp.pdrevs);
544: (void)printf("%11u pages freed by pagedaemon\n", uvmexp.pdfreed);
545: (void)printf("%11u pages scanned by pagedaemon\n", uvmexp.pdscans);
546: (void)printf("%11u pages reactivated by pagedaemon\n", uvmexp.pdreact);
547: (void)printf("%11u busy pages found by pagedaemon\n", uvmexp.pdbusy);
1.29 art 548:
1.56 angelos 549: if (nlistf == NULL && memf == NULL) {
1.52 angelos 550: size = sizeof(nchstats);
551: mib[0] = CTL_KERN;
552: mib[1] = KERN_NCHSTATS;
553: if (sysctl(mib, 2, &nchstats, &size, NULL, 0) < 0) {
1.56 angelos 554: warn("could not read kern.nchstats");
1.52 angelos 555: bzero(&nchstats, sizeof(nchstats));
556: }
1.56 angelos 557: } else {
558: kread(X_NCHSTATS, &nchstats, sizeof(nchstats));
1.52 angelos 559: }
560:
1.1 deraadt 561: nchtotal = nchstats.ncs_goodhits + nchstats.ncs_neghits +
562: nchstats.ncs_badhits + nchstats.ncs_falsehits +
563: nchstats.ncs_miss + nchstats.ncs_long;
1.112 naddy 564: (void)printf("%11lld total name lookups\n", nchtotal);
1.52 angelos 565: (void)printf("%11s cache hits (%d%% pos + %d%% neg) system %d%% "
566: "per-directory\n",
1.112 naddy 567: "", pct(nchstats.ncs_goodhits, nchtotal),
568: pct(nchstats.ncs_neghits, nchtotal),
569: pct(nchstats.ncs_pass2, nchtotal));
1.35 hugh 570: (void)printf("%11s deletions %d%%, falsehits %d%%, toolong %d%%\n", "",
1.112 naddy 571: pct(nchstats.ncs_badhits, nchtotal),
572: pct(nchstats.ncs_falsehits, nchtotal),
573: pct(nchstats.ncs_long, nchtotal));
1.52 angelos 574:
1.56 angelos 575: if (nlistf == NULL && memf == NULL) {
1.52 angelos 576: size = sizeof(nselcoll);
577: mib[0] = CTL_KERN;
578: mib[1] = KERN_NSELCOLL;
579: if (sysctl(mib, 2, &nselcoll, &size, NULL, 0) < 0) {
1.56 angelos 580: warn("could not read kern.nselcoll");
1.52 angelos 581: nselcoll = 0;
582: }
1.56 angelos 583: } else {
584: kread(X_NSELCOLL, &nselcoll, sizeof(nselcoll));
1.52 angelos 585: }
1.50 art 586: (void)printf("%11d select collisions\n", nselcoll);
1.1 deraadt 587: }
588:
589: void
1.72 deraadt 590: doforkst(void)
1.1 deraadt 591: {
592: struct forkstat fks;
1.52 angelos 593: size_t size;
594: int mib[2];
595:
1.56 angelos 596: if (nlistf == NULL && memf == NULL) {
1.52 angelos 597: size = sizeof(struct forkstat);
598: mib[0] = CTL_KERN;
599: mib[1] = KERN_FORKSTAT;
600: if (sysctl(mib, 2, &fks, &size, NULL, 0) < 0) {
1.56 angelos 601: warn("could not read kern.forkstat");
1.52 angelos 602: bzero(&fks, sizeof(struct forkstat));
603: }
1.56 angelos 604: } else {
605: kread(X_FORKSTAT, &fks, sizeof(struct forkstat));
1.52 angelos 606: }
1.1 deraadt 607:
608: (void)printf("%d forks, %d pages, average %.2f\n",
609: fks.cntfork, fks.sizfork, (double)fks.sizfork / fks.cntfork);
610: (void)printf("%d vforks, %d pages, average %.2f\n",
1.72 deraadt 611: fks.cntvfork, fks.sizvfork,
612: (double)fks.sizvfork / (fks.cntvfork ? fks.cntvfork : 1));
1.119 deraadt 613: (void)printf("%d __tforks, %d pages, average %.2f\n",
614: fks.cnttfork, fks.siztfork,
615: (double)fks.siztfork / (fks.cnttfork ? fks.cnttfork : 1));
1.36 niklas 616: (void)printf("%d kthread creations, %d pages, average %.2f\n",
1.72 deraadt 617: fks.cntkthread, fks.sizkthread,
618: (double)fks.sizkthread / (fks.cntkthread ? fks.cntkthread : 1));
1.1 deraadt 619: }
620:
621: void
1.72 deraadt 622: dkstats(void)
1.1 deraadt 623: {
1.62 mpech 624: int dn, state;
1.1 deraadt 625: double etime;
626:
1.6 tholo 627: /* Calculate disk stat deltas. */
628: dkswap();
1.1 deraadt 629: etime = 0;
630: for (state = 0; state < CPUSTATES; ++state) {
1.6 tholo 631: etime += cur.cp_time[state];
1.1 deraadt 632: }
633: if (etime == 0)
634: etime = 1;
635: etime /= hz;
636: for (dn = 0; dn < dk_ndrive; ++dn) {
1.6 tholo 637: if (!dk_select[dn])
1.1 deraadt 638: continue;
1.82 tedu 639: (void)printf("%3.0f ",
640: (cur.dk_rxfer[dn] + cur.dk_rxfer[dn]) / etime);
1.1 deraadt 641: }
642: }
643:
644: void
1.72 deraadt 645: cpustats(void)
1.1 deraadt 646: {
1.102 deraadt 647: double percent, total;
1.62 mpech 648: int state;
1.1 deraadt 649:
650: total = 0;
651: for (state = 0; state < CPUSTATES; ++state)
1.6 tholo 652: total += cur.cp_time[state];
1.1 deraadt 653: if (total)
1.101 otto 654: percent = 100 / total;
1.1 deraadt 655: else
1.101 otto 656: percent = 0;
657: (void)printf("%2.0f ", (cur.cp_time[CP_USER] + cur.cp_time[CP_NICE]) * percent);
658: (void)printf("%2.0f ", (cur.cp_time[CP_SYS] + cur.cp_time[CP_INTR]) * percent);
659: (void)printf("%2.0f", cur.cp_time[CP_IDLE] * percent);
1.1 deraadt 660: }
661:
662: void
1.72 deraadt 663: dointr(void)
1.74 art 664: {
1.102 deraadt 665: int nintr, mib[4], i;
666: char intrname[128];
667: u_int64_t inttotal;
1.74 art 668: time_t uptime;
669: size_t siz;
670:
1.93 miod 671: if (nlistf != NULL || memf != NULL) {
672: errx(1,
673: "interrupt statistics are only available on live kernels");
674: }
675:
1.74 art 676: uptime = getuptime();
677:
678: mib[0] = CTL_KERN;
679: mib[1] = KERN_INTRCNT;
680: mib[2] = KERN_INTRCNT_NUM;
681: siz = sizeof(nintr);
682: if (sysctl(mib, 3, &nintr, &siz, NULL, 0) < 0) {
683: warnx("could not read kern.intrcnt.nintrcnt");
684: return;
685: }
686:
1.91 deraadt 687: (void)printf("%-16s %20s %8s\n", "interrupt", "total", "rate");
1.87 aaron 688:
1.74 art 689: inttotal = 0;
690: for (i = 0; i < nintr; i++) {
1.87 aaron 691: char name[128];
1.90 deraadt 692: u_quad_t cnt;
1.87 aaron 693: int vector;
1.74 art 694:
695: mib[0] = CTL_KERN;
696: mib[1] = KERN_INTRCNT;
697: mib[2] = KERN_INTRCNT_NAME;
698: mib[3] = i;
1.87 aaron 699: siz = sizeof(name);
700: if (sysctl(mib, 4, name, &siz, NULL, 0) < 0) {
1.74 art 701: warnx("could not read kern.intrcnt.name.%d", i);
1.87 aaron 702: return;
703: }
704:
705: mib[0] = CTL_KERN;
706: mib[1] = KERN_INTRCNT;
707: mib[2] = KERN_INTRCNT_VECTOR;
708: mib[3] = i;
709: siz = sizeof(vector);
710: if (sysctl(mib, 4, &vector, &siz, NULL, 0) < 0) {
711: strlcpy(intrname, name, sizeof(intrname));
712: } else {
713: snprintf(intrname, sizeof(intrname), "irq%d/%s",
714: vector, name);
1.74 art 715: }
716:
717: mib[0] = CTL_KERN;
718: mib[1] = KERN_INTRCNT;
719: mib[2] = KERN_INTRCNT_CNT;
720: mib[3] = i;
721: siz = sizeof(cnt);
722: if (sysctl(mib, 4, &cnt, &siz, NULL, 0) < 0) {
1.75 grange 723: warnx("could not read kern.intrcnt.cnt.%d", i);
1.90 deraadt 724: return;
1.74 art 725: }
1.90 deraadt 726:
1.87 aaron 727: if (cnt || zflag)
1.91 deraadt 728: (void)printf("%-16.16s %20llu %8llu\n", intrname,
1.90 deraadt 729: cnt, cnt / uptime);
1.74 art 730: inttotal += cnt;
731: }
732:
1.91 deraadt 733: (void)printf("%-16s %20llu %8llu\n", "Total", inttotal,
1.90 deraadt 734: inttotal / uptime);
1.1 deraadt 735: }
736:
737: /*
738: * These names are defined in <sys/malloc.h>.
739: */
1.101 otto 740: const char *kmemnames[] = INITKMEMNAMES;
1.1 deraadt 741:
742: void
1.72 deraadt 743: domem(void)
1.1 deraadt 744: {
1.102 deraadt 745: struct kmembuckets buckets[MINBUCKET + 16], *kp;
746: struct kmemstats kmemstats[M_LAST], *ks;
747: int i, j, len, size, first, mib[4];
1.50 art 748: u_long totuse = 0, totfree = 0;
1.102 deraadt 749: char buf[BUFSIZ], *bufp, *ap;
1.50 art 750: quad_t totreq = 0;
1.101 otto 751: const char *name;
1.50 art 752: size_t siz;
753:
754: if (memf == NULL && nlistf == NULL) {
1.53 deraadt 755: mib[0] = CTL_KERN;
1.50 art 756: mib[1] = KERN_MALLOCSTATS;
757: mib[2] = KERN_MALLOC_BUCKETS;
758: siz = sizeof(buf);
759: if (sysctl(mib, 3, buf, &siz, NULL, 0) < 0) {
1.56 angelos 760: warnx("could not read kern.malloc.buckets");
1.50 art 761: return;
762: }
763:
764: bufp = buf;
765: mib[2] = KERN_MALLOC_BUCKET;
766: siz = sizeof(struct kmembuckets);
767: i = 0;
768: while ((ap = strsep(&bufp, ",")) != NULL) {
1.53 deraadt 769: mib[3] = atoi(ap);
1.50 art 770:
771: if (sysctl(mib, 4, &buckets[MINBUCKET + i], &siz,
1.53 deraadt 772: NULL, 0) < 0) {
1.56 angelos 773: warn("could not read kern.malloc.bucket.%d", mib[3]);
1.50 art 774: return;
775: }
776: i++;
777: }
778: } else {
1.53 deraadt 779: kread(X_KMEMBUCKETS, buckets, sizeof(buckets));
1.50 art 780: }
1.1 deraadt 781:
1.18 kstailey 782: for (first = 1, i = MINBUCKET, kp = &buckets[i]; i < MINBUCKET + 16;
783: i++, kp++) {
1.65 art 784: if (kp->kb_calls == 0 && !verbose)
1.1 deraadt 785: continue;
1.18 kstailey 786: if (first) {
787: (void)printf("Memory statistics by bucket size\n");
788: (void)printf(
1.50 art 789: " Size In Use Free Requests HighWater Couldfree\n");
1.18 kstailey 790: first = 0;
791: }
1.1 deraadt 792: size = 1 << i;
1.60 art 793: (void)printf("%8d %8llu %6llu %18llu %7llu %10llu\n", size,
794: (unsigned long long)(kp->kb_total - kp->kb_totalfree),
795: (unsigned long long)kp->kb_totalfree,
796: (unsigned long long)kp->kb_calls,
797: (unsigned long long)kp->kb_highwat,
798: (unsigned long long)kp->kb_couldfree);
1.1 deraadt 799: totfree += size * kp->kb_totalfree;
1.18 kstailey 800: }
801:
802: /*
803: * If kmem statistics are not being gathered by the kernel,
804: * first will still be 1.
805: */
806: if (first) {
807: printf(
808: "Kmem statistics are not being gathered by the kernel.\n");
809: return;
1.1 deraadt 810: }
811:
1.52 angelos 812: if (memf == NULL && nlistf == NULL) {
813: bzero(kmemstats, sizeof(kmemstats));
814: for (i = 0; i < M_LAST; i++) {
1.53 deraadt 815: mib[0] = CTL_KERN;
1.52 angelos 816: mib[1] = KERN_MALLOCSTATS;
817: mib[2] = KERN_MALLOC_KMEMSTATS;
818: mib[3] = i;
819: siz = sizeof(struct kmemstats);
820:
1.103 deraadt 821: /*
1.52 angelos 822: * Skip errors -- these are presumed to be unallocated
823: * entries.
824: */
825: if (sysctl(mib, 4, &kmemstats[i], &siz, NULL, 0) < 0)
826: continue;
827: }
828: } else {
829: kread(X_KMEMSTAT, kmemstats, sizeof(kmemstats));
830: }
831:
1.1 deraadt 832: (void)printf("\nMemory usage type by bucket size\n");
833: (void)printf(" Size Type(s)\n");
834: kp = &buckets[MINBUCKET];
835: for (j = 1 << MINBUCKET; j < 1 << (MINBUCKET + 16); j <<= 1, kp++) {
836: if (kp->kb_calls == 0)
837: continue;
838: first = 1;
839: len = 8;
840: for (i = 0, ks = &kmemstats[0]; i < M_LAST; i++, ks++) {
841: if (ks->ks_calls == 0)
842: continue;
843: if ((ks->ks_size & j) == 0)
844: continue;
845: name = kmemnames[i] ? kmemnames[i] : "undefined";
846: len += 2 + strlen(name);
847: if (first)
848: printf("%8d %s", j, name);
849: else
850: printf(",");
851: if (len >= 80) {
852: printf("\n\t ");
853: len = 10 + strlen(name);
854: }
855: if (!first)
856: printf(" %s", name);
857: first = 0;
858: }
859: printf("\n");
860: }
861:
862: (void)printf(
1.26 deraadt 863: "\nMemory statistics by type Type Kern\n");
1.1 deraadt 864: (void)printf(
1.26 deraadt 865: " Type InUse MemUse HighUse Limit Requests Limit Limit Size(s)\n");
1.1 deraadt 866: for (i = 0, ks = &kmemstats[0]; i < M_LAST; i++, ks++) {
867: if (ks->ks_calls == 0)
868: continue;
1.24 mickey 869: (void)printf("%14s%6ld%6ldK%7ldK%6ldK%9ld%5u%6u",
1.1 deraadt 870: kmemnames[i] ? kmemnames[i] : "undefined",
871: ks->ks_inuse, (ks->ks_memuse + 1023) / 1024,
872: (ks->ks_maxused + 1023) / 1024,
873: (ks->ks_limit + 1023) / 1024, ks->ks_calls,
874: ks->ks_limblocks, ks->ks_mapblocks);
875: first = 1;
876: for (j = 1 << MINBUCKET; j < 1 << (MINBUCKET + 16); j <<= 1) {
877: if ((ks->ks_size & j) == 0)
878: continue;
879: if (first)
880: printf(" %d", j);
881: else
882: printf(",%d", j);
883: first = 0;
884: }
885: printf("\n");
886: totuse += ks->ks_memuse;
887: totreq += ks->ks_calls;
888: }
889: (void)printf("\nMemory Totals: In Use Free Requests\n");
1.50 art 890: (void)printf(" %7luK %6luK %8qu\n",
1.1 deraadt 891: (totuse + 1023) / 1024, (totfree + 1023) / 1024, totreq);
892: }
893:
1.54 art 894: static void
1.129 dlg 895: print_pool(struct kinfo_pool *pp, char *name)
1.54 art 896: {
897: static int first = 1;
1.102 deraadt 898: char maxp[32];
1.54 art 899: int ovflw;
900:
901: if (first) {
902: (void)printf("Memory resource pool statistics\n");
903: (void)printf(
904: "%-11s%5s%9s%5s%9s%6s%6s%6s%6s%6s%6s%5s\n",
905: "Name",
906: "Size",
907: "Requests",
908: "Fail",
1.110 otto 909: "InUse",
1.54 art 910: "Pgreq",
911: "Pgrel",
912: "Npage",
913: "Hiwat",
914: "Minpg",
915: "Maxpg",
916: "Idle");
917: first = 0;
918: }
1.65 art 919:
920: /* Skip unused pools unless verbose output. */
921: if (pp->pr_nget == 0 && !verbose)
922: return;
923:
1.54 art 924: if (pp->pr_maxpages == UINT_MAX)
1.69 deraadt 925: snprintf(maxp, sizeof maxp, "inf");
1.54 art 926: else
1.69 deraadt 927: snprintf(maxp, sizeof maxp, "%u", pp->pr_maxpages);
1.54 art 928: /*
929: * Print single word. `ovflow' is number of characters didn't fit
930: * on the last word. `fmt' is a format string to print this word.
931: * It must contain asterisk for field width. `width' is a width
932: * occupied by this word. `fixed' is a number of constant chars in
933: * `fmt'. `val' is a value to be printed using format string `fmt'.
934: */
935: #define PRWORD(ovflw, fmt, width, fixed, val) do { \
936: (ovflw) += printf((fmt), \
937: (width) - (fixed) - (ovflw) > 0 ? \
938: (width) - (fixed) - (ovflw) : 0, \
939: (val)) - (width); \
940: if ((ovflw) < 0) \
941: (ovflw) = 0; \
942: } while (/* CONSTCOND */0)
943:
944: ovflw = 0;
945: PRWORD(ovflw, "%-*s", 11, 0, name);
946: PRWORD(ovflw, " %*u", 5, 1, pp->pr_size);
947: PRWORD(ovflw, " %*lu", 9, 1, pp->pr_nget);
948: PRWORD(ovflw, " %*lu", 5, 1, pp->pr_nfail);
1.110 otto 949: PRWORD(ovflw, " %*lu", 9, 1, pp->pr_nget - pp->pr_nput);
1.54 art 950: PRWORD(ovflw, " %*lu", 6, 1, pp->pr_npagealloc);
951: PRWORD(ovflw, " %*lu", 6, 1, pp->pr_npagefree);
952: PRWORD(ovflw, " %*d", 6, 1, pp->pr_npages);
953: PRWORD(ovflw, " %*d", 6, 1, pp->pr_hiwat);
954: PRWORD(ovflw, " %*d", 6, 1, pp->pr_minpages);
955: PRWORD(ovflw, " %*s", 6, 1, maxp);
1.103 deraadt 956: PRWORD(ovflw, " %*lu\n", 5, 1, pp->pr_nidle);
1.54 art 957: }
958:
1.55 art 959: static void dopool_kvm(void);
960: static void dopool_sysctl(void);
961:
1.48 art 962: void
963: dopool(void)
964: {
1.55 art 965: if (nlistf == NULL && memf == NULL)
966: dopool_sysctl();
967: else
968: dopool_kvm();
969: }
970:
971: void
972: dopool_sysctl(void)
973: {
1.117 chl 974: int mib[4], npools, i;
1.63 art 975: long total = 0, inuse = 0;
1.129 dlg 976: struct kinfo_pool pool;
1.55 art 977: size_t size;
978:
979: mib[0] = CTL_KERN;
980: mib[1] = KERN_POOL;
981: mib[2] = KERN_POOL_NPOOLS;
982: size = sizeof(npools);
983: if (sysctl(mib, 3, &npools, &size, NULL, 0) < 0) {
1.92 pedro 984: warn("can't figure out number of pools in kernel");
1.55 art 985: return;
986: }
987:
988: for (i = 1; npools; i++) {
989: char name[32];
990:
991: mib[0] = CTL_KERN;
992: mib[1] = KERN_POOL;
993: mib[2] = KERN_POOL_POOL;
994: mib[3] = i;
1.129 dlg 995: size = sizeof(pool);
1.55 art 996: if (sysctl(mib, 4, &pool, &size, NULL, 0) < 0) {
997: if (errno == ENOENT)
998: continue;
1.92 pedro 999: warn("error getting pool");
1.55 art 1000: return;
1001: }
1002: npools--;
1003: mib[2] = KERN_POOL_NAME;
1004: size = sizeof(name);
1005: if (sysctl(mib, 4, &name, &size, NULL, 0) < 0) {
1.92 pedro 1006: warn("error getting pool name");
1.55 art 1007: return;
1008: }
1009: print_pool(&pool, name);
1.63 art 1010:
1011: inuse += (pool.pr_nget - pool.pr_nput) * pool.pr_size;
1.129 dlg 1012: total += pool.pr_npages * pool.pr_pgsize;
1.55 art 1013: }
1.63 art 1014:
1015: inuse /= 1024;
1016: total /= 1024;
1017: printf("\nIn use %ldK, total allocated %ldK; utilization %.1f%%\n",
1018: inuse, total, (double)(100 * inuse) / total);
1.55 art 1019: }
1020:
1021: void
1022: dopool_kvm(void)
1023: {
1.120 tedu 1024: SIMPLEQ_HEAD(,pool) pool_head;
1.48 art 1025: struct pool pool, *pp = &pool;
1.129 dlg 1026: struct kinfo_pool pi;
1.102 deraadt 1027: long total = 0, inuse = 0;
1028: u_long addr;
1.48 art 1029:
1030: kread(X_POOLHEAD, &pool_head, sizeof(pool_head));
1.120 tedu 1031: addr = (u_long)SIMPLEQ_FIRST(&pool_head);
1.48 art 1032:
1.55 art 1033: while (addr != 0) {
1.54 art 1034: char name[32];
1.56 angelos 1035:
1.48 art 1036: if (kvm_read(kd, addr, (void *)pp, sizeof *pp) != sizeof *pp) {
1037: (void)fprintf(stderr,
1038: "vmstat: pool chain trashed: %s\n",
1039: kvm_geterr(kd));
1040: exit(1);
1041: }
1.102 deraadt 1042: if (kvm_read(kd, (u_long)pp->pr_wchan, name, sizeof name) < 0) {
1.48 art 1043: (void)fprintf(stderr,
1044: "vmstat: pool name trashed: %s\n",
1045: kvm_geterr(kd));
1046: exit(1);
1047: }
1048: name[31] = '\0';
1049:
1.129 dlg 1050: memset(&pi, 0, sizeof(pi));
1051: pi.pr_size = pp->pr_size;
1.135 tedu 1052: pi.pr_pgsize = pp->pr_pgsize;
1.129 dlg 1053: pi.pr_itemsperpage = pp->pr_itemsperpage;
1.130 dlg 1054: pi.pr_npages = pp->pr_npages;
1.129 dlg 1055: pi.pr_minpages = pp->pr_minpages;
1056: pi.pr_maxpages = pp->pr_maxpages;
1057: pi.pr_hardlimit = pp->pr_hardlimit;
1058: pi.pr_nout = pp->pr_nout;
1059: pi.pr_nitems = pp->pr_nitems;
1060: pi.pr_nget = pp->pr_nget;
1061: pi.pr_nput = pp->pr_nput;
1062: pi.pr_nfail = pp->pr_nfail;
1063: pi.pr_npagealloc = pp->pr_npagealloc;
1064: pi.pr_npagefree = pp->pr_npagefree;
1065: pi.pr_hiwat = pp->pr_hiwat;
1066: pi.pr_nidle = pp->pr_nidle;
1067:
1068: print_pool(&pi, name);
1.48 art 1069:
1.129 dlg 1070: inuse += (pi.pr_nget - pi.pr_nput) * pi.pr_size;
1071: total += pi.pr_npages * pi.pr_pgsize;
1.56 angelos 1072:
1.120 tedu 1073: addr = (u_long)SIMPLEQ_NEXT(pp, pr_poollist);
1.48 art 1074: }
1075:
1076: inuse /= 1024;
1077: total /= 1024;
1078: printf("\nIn use %ldK, total allocated %ldK; utilization %.1f%%\n",
1079: inuse, total, (double)(100 * inuse) / total);
1080: }
1081:
1.1 deraadt 1082: /*
1083: * kread reads something from the kernel, given its nlist index.
1084: */
1085: void
1.72 deraadt 1086: kread(int nlx, void *addr, size_t size)
1.1 deraadt 1087: {
1088: char *sym;
1089:
1090: if (namelist[nlx].n_type == 0 || namelist[nlx].n_value == 0) {
1091: sym = namelist[nlx].n_name;
1092: if (*sym == '_')
1093: ++sym;
1.50 art 1094: errx(1, "symbol %s not defined", sym);
1.1 deraadt 1095: }
1096: if (kvm_read(kd, namelist[nlx].n_value, addr, size) != size) {
1097: sym = namelist[nlx].n_name;
1098: if (*sym == '_')
1099: ++sym;
1.50 art 1100: errx(1, "%s: %s", sym, kvm_geterr(kd));
1.1 deraadt 1101: }
1102: }
1103:
1104: void
1.72 deraadt 1105: usage(void)
1.1 deraadt 1106: {
1.88 jmc 1107: (void)fprintf(stderr, "usage: %s [-fimstvz] [-c count] [-M core] "
1.109 sobrado 1108: "[-N system] [-w wait] [disk ...]\n", __progname);
1.1 deraadt 1109: exit(1);
1110: }