2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1980, 1986, 1991, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/param.h>
35 #include <sys/namei.h>
36 #include <sys/malloc.h>
37 #include <sys/signal.h>
38 #include <sys/fcntl.h>
39 #include <sys/ioctl.h>
40 #include <sys/resource.h>
41 #include <sys/sysctl.h>
45 #include <sys/vmmeter.h>
48 #include <vm/vm_param.h>
69 #define VMSTAT_XO_VERSION "1"
71 static char da[] = "da";
73 enum x_stats { X_SUM, X_HZ, X_STATHZ, X_NCHSTATS, X_INTRNAMES, X_SINTRNAMES,
74 X_INTRCNT, X_SINTRCNT, X_NINTRCNT };
76 static struct nlist namelist[] = {
77 [X_SUM] = { .n_name = "_vm_cnt", },
78 [X_HZ] = { .n_name = "_hz", },
79 [X_STATHZ] = { .n_name = "_stathz", },
80 [X_NCHSTATS] = { .n_name = "_nchstats", },
81 [X_INTRNAMES] = { .n_name = "_intrnames", },
82 [X_SINTRNAMES] = { .n_name = "_sintrnames", },
83 [X_INTRCNT] = { .n_name = "_intrcnt", },
84 [X_SINTRCNT] = { .n_name = "_sintrcnt", },
85 [X_NINTRCNT] = { .n_name = "_nintrcnt", },
89 static struct devstat_match *matches;
90 static struct device_selection *dev_select;
91 static struct statinfo cur, last;
92 static devstat_select_mode select_mode;
93 static size_t size_cp_times;
94 static long *cur_cp_times, *last_cp_times;
95 static long generation, select_generation;
96 static int hz, hdrcnt, maxshowdevs;
97 static int num_devices, num_devices_specified;
98 static int num_matches, num_selected, num_selections;
99 static char **specified_devices;
101 static struct __vmmeter {
107 uint64_t v_vm_faults;
108 uint64_t v_io_faults;
109 uint64_t v_cow_faults;
110 uint64_t v_cow_optim;
115 uint64_t v_swappgsin;
116 uint64_t v_swappgsout;
119 uint64_t v_vnodepgsin;
120 uint64_t v_vnodepgsout;
122 uint64_t v_reactivated;
123 uint64_t v_pdwakeups;
125 uint64_t v_pdshortfalls;
133 uint64_t v_forkpages;
134 uint64_t v_vforkpages;
135 uint64_t v_rforkpages;
136 uint64_t v_kthreadpages;
139 u_int v_free_reserved;
144 u_long v_user_wire_count;
145 u_int v_active_count;
146 u_int v_inactive_target;
147 u_int v_inactive_count;
148 u_int v_laundry_count;
149 u_int v_pageout_free_min;
150 u_int v_interrupt_free_min;
154 #define VMSTAT_DEFAULT_LINES 20 /* Default number of `winlines'. */
155 static volatile sig_atomic_t wresized; /* Tty resized when non-zero. */
156 static int winlines = VMSTAT_DEFAULT_LINES; /* Current number of tty rows. */
165 #define FORKSTAT 0x01
166 #define INTRSTAT 0x02
169 #define TIMESTAT 0x10
171 #define ZMEMSTAT 0x40
174 static void cpustats(void);
175 static void pcpustats(u_long, int);
176 static void devstats(void);
177 static void doforkst(void);
178 static void dointr(unsigned int, int);
179 static void doobjstat(void);
180 static void dosum(void);
181 static void dovmstat(unsigned int, int);
182 static void domemstat_malloc(void);
183 static void domemstat_zone(void);
184 static void kread(int, void *, size_t);
185 static void kreado(int, void *, size_t, size_t);
186 static void kreadptr(uintptr_t, void *, size_t);
187 static void needhdr(int);
188 static void needresize(int);
189 static void doresize(void);
190 static void printhdr(int, u_long);
191 static void usage(void);
193 static long pct(long, long);
194 static long long getuptime(void);
196 static char **getdrivedata(char **);
199 main(int argc, char *argv[])
201 char *bp, *buf, *memf, *nlistf;
203 int bufsize, c, reps, todo;
205 unsigned int interval;
206 char errbuf[_POSIX2_LINE_MAX];
208 memf = nlistf = NULL;
209 interval = reps = todo = 0;
212 argc = xo_parse_args(argc, argv);
218 while ((c = getopt(argc, argv, "ac:fhHiM:mN:n:oPp:sw:z")) != -1) {
252 maxshowdevs = atoi(optarg);
254 xo_errx(1, "number of devices %d is < 0",
261 if (devstat_buildmatch(optarg, &matches, &num_matches)
263 xo_errx(1, "%s", devstat_errbuf);
269 /* Convert to milliseconds. */
284 xo_set_version(VMSTAT_XO_VERSION);
286 xo_set_options(NULL, "no-humanize");
291 kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
293 xo_errx(1, "kvm_openfiles: %s", errbuf);
297 if (kd != NULL && (c = kvm_nlist(kd, namelist)) != 0) {
303 * 'cnt' was renamed to 'vm_cnt'. If 'vm_cnt' is not
304 * found try looking up older 'cnt' symbol.
306 if (namelist[X_SUM].n_type == 0 &&
307 strcmp(namelist[X_SUM].n_name, "_vm_cnt") == 0) {
308 namelist[X_SUM].n_name = "_cnt";
313 * 'nintrcnt' doesn't exist in older kernels, but
316 if (namelist[X_NINTRCNT].n_type == 0 && c == 1)
319 for (c = 0; c < (int)(nitems(namelist)); c++)
320 if (namelist[c].n_type == 0)
321 bufsize += strlen(namelist[c].n_name)
324 buf = bp = alloca(bufsize);
326 for (c = 0; c < (int)(nitems(namelist)); c++)
327 if (namelist[c].n_type == 0) {
330 len = strlen(namelist[c].n_name);
332 memcpy(bp, namelist[c].n_name, len);
336 xo_error("undefined symbols:\n", buf);
338 xo_warnx("kvm_nlist: %s", kvm_geterr(kd));
344 xo_errx(1, "Cannot use -P with crash dumps");
348 * Make sure that the userland devstat version matches the
349 * kernel devstat version. If not, exit and print a
350 * message informing the user of his mistake.
352 if (devstat_checkversion(NULL) < 0)
353 xo_errx(1, "%s", devstat_errbuf);
356 argv = getdrivedata(argv);
383 dointr(interval, reps);
385 dovmstat(interval, reps);
391 mysysctl(const char *name, void *oldp, size_t *oldlenp)
395 error = sysctlbyname(name, oldp, oldlenp, NULL, 0);
396 if (error != 0 && errno != ENOMEM)
397 xo_err(1, "sysctl(%s)", name);
402 getdrivedata(char **argv)
405 if ((num_devices = devstat_getnumdevs(NULL)) < 0)
406 xo_errx(1, "%s", devstat_errbuf);
408 cur.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
409 last.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
411 if (devstat_getdevs(NULL, &cur) == -1)
412 xo_errx(1, "%s", devstat_errbuf);
414 num_devices = cur.dinfo->numdevs;
415 generation = cur.dinfo->generation;
417 specified_devices = malloc(sizeof(char *));
418 for (num_devices_specified = 0; *argv; ++argv) {
421 num_devices_specified++;
422 specified_devices = reallocf(specified_devices,
423 sizeof(char *) * num_devices_specified);
424 if (specified_devices == NULL) {
425 xo_errx(1, "%s", "reallocf (specified_devices)");
427 specified_devices[num_devices_specified - 1] = *argv;
431 if (nflag == 0 && maxshowdevs < num_devices_specified)
432 maxshowdevs = num_devices_specified;
435 * People are generally only interested in disk statistics when
436 * they're running vmstat. So, that's what we're going to give
437 * them if they don't specify anything by default. We'll also give
438 * them any other random devices in the system so that we get to
439 * maxshowdevs devices, if that many devices exist. If the user
440 * specifies devices on the command line, either through a pattern
441 * match or by naming them explicitly, we will give the user only
444 if ((num_devices_specified == 0) && (num_matches == 0)) {
445 if (devstat_buildmatch(da, &matches, &num_matches) != 0)
446 xo_errx(1, "%s", devstat_errbuf);
447 select_mode = DS_SELECT_ADD;
449 select_mode = DS_SELECT_ONLY;
452 * At this point, selectdevs will almost surely indicate that the
453 * device list has changed, so we don't look for return values of 0
454 * or 1. If we get back -1, though, there is an error.
456 if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
457 &select_generation, generation, cur.dinfo->devices,
458 num_devices, matches, num_matches, specified_devices,
459 num_devices_specified, select_mode,
460 maxshowdevs, 0) == -1)
461 xo_errx(1, "%s", devstat_errbuf);
466 /* Return system uptime in nanoseconds */
472 (void)clock_gettime(CLOCK_UPTIME, &sp);
473 return((long long)sp.tv_sec * 1000000000LL + sp.tv_nsec);
477 fill_vmmeter(struct __vmmeter *vmmp)
479 struct vmmeter vm_cnt;
483 kread(X_SUM, &vm_cnt, sizeof(vm_cnt));
484 #define GET_COUNTER(name) \
485 vmmp->name = kvm_counter_u64_fetch(kd, (u_long)vm_cnt.name)
486 GET_COUNTER(v_swtch);
488 GET_COUNTER(v_syscall);
491 GET_COUNTER(v_vm_faults);
492 GET_COUNTER(v_io_faults);
493 GET_COUNTER(v_cow_faults);
494 GET_COUNTER(v_cow_optim);
496 GET_COUNTER(v_ozfod);
497 GET_COUNTER(v_swapin);
498 GET_COUNTER(v_swapout);
499 GET_COUNTER(v_swappgsin);
500 GET_COUNTER(v_swappgsout);
501 GET_COUNTER(v_vnodein);
502 GET_COUNTER(v_vnodeout);
503 GET_COUNTER(v_vnodepgsin);
504 GET_COUNTER(v_vnodepgsout);
505 GET_COUNTER(v_intrans);
506 GET_COUNTER(v_tfree);
507 GET_COUNTER(v_forks);
508 GET_COUNTER(v_vforks);
509 GET_COUNTER(v_rforks);
510 GET_COUNTER(v_kthreads);
511 GET_COUNTER(v_forkpages);
512 GET_COUNTER(v_vforkpages);
513 GET_COUNTER(v_rforkpages);
514 GET_COUNTER(v_kthreadpages);
517 #define GET_VM_STATS(cat, name) do { \
518 size = sizeof(vmmp->name); \
519 mysysctl("vm.stats." #cat "." #name, &vmmp->name, &size); \
522 GET_VM_STATS(sys, v_swtch);
523 GET_VM_STATS(sys, v_trap);
524 GET_VM_STATS(sys, v_syscall);
525 GET_VM_STATS(sys, v_intr);
526 GET_VM_STATS(sys, v_soft);
529 GET_VM_STATS(vm, v_vm_faults);
530 GET_VM_STATS(vm, v_io_faults);
531 GET_VM_STATS(vm, v_cow_faults);
532 GET_VM_STATS(vm, v_cow_optim);
533 GET_VM_STATS(vm, v_zfod);
534 GET_VM_STATS(vm, v_ozfod);
535 GET_VM_STATS(vm, v_swapin);
536 GET_VM_STATS(vm, v_swapout);
537 GET_VM_STATS(vm, v_swappgsin);
538 GET_VM_STATS(vm, v_swappgsout);
539 GET_VM_STATS(vm, v_vnodein);
540 GET_VM_STATS(vm, v_vnodeout);
541 GET_VM_STATS(vm, v_vnodepgsin);
542 GET_VM_STATS(vm, v_vnodepgsout);
543 GET_VM_STATS(vm, v_intrans);
544 GET_VM_STATS(vm, v_reactivated);
545 GET_VM_STATS(vm, v_pdwakeups);
546 GET_VM_STATS(vm, v_pdpages);
547 GET_VM_STATS(vm, v_pdshortfalls);
548 GET_VM_STATS(vm, v_dfree);
549 GET_VM_STATS(vm, v_pfree);
550 GET_VM_STATS(vm, v_tfree);
551 GET_VM_STATS(vm, v_page_size);
552 GET_VM_STATS(vm, v_page_count);
553 GET_VM_STATS(vm, v_free_reserved);
554 GET_VM_STATS(vm, v_free_target);
555 GET_VM_STATS(vm, v_free_min);
556 GET_VM_STATS(vm, v_free_count);
557 GET_VM_STATS(vm, v_wire_count);
558 GET_VM_STATS(vm, v_user_wire_count);
559 GET_VM_STATS(vm, v_active_count);
560 GET_VM_STATS(vm, v_inactive_target);
561 GET_VM_STATS(vm, v_inactive_count);
562 GET_VM_STATS(vm, v_laundry_count);
563 GET_VM_STATS(vm, v_pageout_free_min);
564 GET_VM_STATS(vm, v_interrupt_free_min);
565 /*GET_VM_STATS(vm, v_free_severe);*/
566 GET_VM_STATS(vm, v_forks);
567 GET_VM_STATS(vm, v_vforks);
568 GET_VM_STATS(vm, v_rforks);
569 GET_VM_STATS(vm, v_kthreads);
570 GET_VM_STATS(vm, v_forkpages);
571 GET_VM_STATS(vm, v_vforkpages);
572 GET_VM_STATS(vm, v_rforkpages);
573 GET_VM_STATS(vm, v_kthreadpages);
579 fill_vmtotal(struct vmtotal *vmtp)
585 xo_errx(1, "not implemented");
587 size = sizeof(*vmtp);
588 mysysctl("vm.vmtotal", vmtp, &size);
589 if (size != sizeof(*vmtp))
590 xo_errx(1, "vm.total size mismatch");
594 /* Determine how many cpu columns, and what index they are in kern.cp_times */
596 getcpuinfo(u_long *maskp, int *maxidp)
601 int empty, i, j, maxcpu, maxid;
604 xo_errx(1, "not implemented");
606 size = sizeof(maxcpu);
607 mysysctl("kern.smp.maxcpus", &maxcpu, &size);
608 if (size != sizeof(maxcpu))
609 xo_errx(1, "sysctl kern.smp.maxcpus");
610 size = sizeof(long) * maxcpu * CPUSTATES;
611 times = malloc(size);
613 xo_err(1, "malloc %zd bytes", size);
614 mysysctl("kern.cp_times", times, &size);
615 maxid = (size / CPUSTATES / sizeof(long)) - 1;
616 for (i = 0; i <= maxid; i++) {
618 for (j = 0; empty && j < CPUSTATES; j++) {
619 if (times[i * CPUSTATES + j] != 0)
632 dovmstat(unsigned int interval, int reps)
634 struct clockinfo clockrate;
635 struct vmtotal total;
636 struct devinfo *tmp_dinfo;
639 time_t uptime, halfuptime;
640 int maxid, rate_adj, retval;
642 uptime = getuptime() / 1000000000LL;
643 halfuptime = uptime / 2;
649 * If the user stops the program (control-Z) and then resumes it,
650 * print out the header again.
652 (void)signal(SIGCONT, needhdr);
655 * If our standard output is a tty, then install a SIGWINCH handler
656 * and set wresized so that our first iteration through the main
657 * vmstat loop will peek at the terminal's current rows to find out
658 * how many lines can fit in a screenful of output.
660 if (isatty(fileno(stdout)) != 0) {
662 (void)signal(SIGWINCH, needresize);
665 winlines = VMSTAT_DEFAULT_LINES;
669 if (namelist[X_STATHZ].n_type != 0 &&
670 namelist[X_STATHZ].n_value != 0)
671 kread(X_STATHZ, &hz, sizeof(hz));
673 kread(X_HZ, &hz, sizeof(hz));
675 size = sizeof(clockrate);
676 mysysctl("kern.clockrate", &clockrate, &size);
677 if (size != sizeof(clockrate))
678 xo_errx(1, "clockrate size mismatch");
683 getcpuinfo(&cpumask, &maxid);
684 size_cp_times = sizeof(long) * (maxid + 1) * CPUSTATES;
685 cur_cp_times = calloc(1, size_cp_times);
686 last_cp_times = calloc(1, size_cp_times);
690 printhdr(maxid, cpumask);
692 if (kvm_getcptime(kd, cur.cp_time) < 0)
693 xo_errx(1, "kvm_getcptime: %s", kvm_geterr(kd));
695 size = sizeof(cur.cp_time);
696 mysysctl("kern.cp_time", &cur.cp_time, &size);
697 if (size != sizeof(cur.cp_time))
698 xo_errx(1, "cp_time size mismatch");
701 size = size_cp_times;
702 mysysctl("kern.cp_times", cur_cp_times, &size);
703 if (size != size_cp_times)
704 xo_errx(1, "cp_times mismatch");
707 tmp_dinfo = last.dinfo;
708 last.dinfo = cur.dinfo;
709 cur.dinfo = tmp_dinfo;
710 last.snap_time = cur.snap_time;
713 * Here what we want to do is refresh our device stats.
714 * getdevs() returns 1 when the device list has changed.
715 * If the device list has changed, we want to go through
716 * the selection process again, in case a device that we
717 * were previously displaying has gone away.
719 switch (devstat_getdevs(NULL, &cur)) {
721 xo_errx(1, "%s", devstat_errbuf);
724 num_devices = cur.dinfo->numdevs;
725 generation = cur.dinfo->generation;
727 retval = devstat_selectdevs(&dev_select, &num_selected,
728 &num_selections, &select_generation,
729 generation, cur.dinfo->devices,
730 num_devices, matches, num_matches,
732 num_devices_specified, select_mode,
736 xo_errx(1, "%s", devstat_errbuf);
739 printhdr(maxid, cpumask);
750 fill_vmtotal(&total);
751 xo_open_container("processes");
752 xo_emit("{:runnable/%2d} {:waiting/%2ld} "
753 "{:swapped-out/%2ld}", total.t_rq - 1, total.t_dw +
754 total.t_pw, total.t_sw);
755 xo_close_container("processes");
756 xo_open_container("memory");
757 #define rate(x) (unsigned long)(((x) * rate_adj + halfuptime) / uptime)
758 xo_emit(" {[:4}{h,hn-decimal:available-memory/%ju}{]:}",
759 (uintmax_t)total.t_avm * sum.v_page_size);
760 xo_emit(" {[:4}{h,hn-decimal:free-memory/%ju}{]:}",
761 (uintmax_t)total.t_free * sum.v_page_size);
762 xo_emit(" {[:4}{h,hn-decimal,hn-1000:total-page-faults/%lu}{]:} ",
763 rate(sum.v_vm_faults - osum.v_vm_faults));
764 xo_close_container("memory");
766 xo_open_container("paging-rates");
767 xo_emit("{:page-reactivated/%3lu} ",
768 rate(sum.v_reactivated - osum.v_reactivated));
769 xo_emit("{:paged-in/%3lu} ",
770 rate(sum.v_swapin + sum.v_vnodein -
771 (osum.v_swapin + osum.v_vnodein)));
772 xo_emit("{:paged-out/%3lu}",
773 rate(sum.v_swapout + sum.v_vnodeout -
774 (osum.v_swapout + osum.v_vnodeout)));
775 xo_emit(" {[:4}{h,hn-decimal,hn-1000:freed/%lu}{]:}",
776 rate(sum.v_tfree - osum.v_tfree));
777 xo_emit(" {[:4}{h,hn-decimal,hn-1000:scanned/%lu}{]:}",
778 rate(sum.v_pdpages - osum.v_pdpages));
779 xo_close_container("paging-rates");
782 xo_open_container("fault-rates");
783 xo_emit(" {[:4}{h,hn-decimal,hn-1000:interrupts/%lu}{]:}"
784 " {[:4}{h,hn-decimal,hn-1000:system-calls/%lu}{]:}"
785 " {[:4}{h,hn-decimal,hn-1000:context-switches/%lu}{]:}",
786 rate(sum.v_intr - osum.v_intr),
787 rate(sum.v_syscall - osum.v_syscall),
788 rate(sum.v_swtch - osum.v_swtch));
789 xo_close_container("fault-rates");
791 pcpustats(cpumask, maxid);
796 if (reps >= 0 && --reps <= 0)
802 * We round upward to avoid losing low-frequency events
803 * (i.e., >= 1 per interval but < 1 per millisecond).
806 halfuptime = (uptime + 1) / 2;
809 (void)usleep(interval * 1000);
814 printhdr(int maxid, u_long cpumask)
818 num_shown = MIN(num_selected, maxshowdevs);
819 xo_emit(" {T:procs} {T:memory} {T:/page%*s}", 19, "");
821 xo_emit(" {T:/disks %*s} ", num_shown * 5 - 7, "");
822 else if (num_shown == 1)
823 xo_emit(" {T:disks} ");
824 xo_emit(" {T:faults} ");
826 for (i = 0; i <= maxid; i++) {
827 if (cpumask & (1ul << i))
828 xo_emit(" {T:/cpu%d} ", i);
832 xo_emit(" {T:cpu}\n");
833 xo_emit(" {T:r} {T:b} {T:w} {T:avm} {T:fre} {T:flt} {T:re}"
834 " {T:pi} {T:po} {T:fr} {T:sr} ");
835 for (i = 0; i < num_devices; i++)
836 if ((dev_select[i].selected) &&
837 (dev_select[i].selected <= maxshowdevs))
838 xo_emit("{T:/%3.3s%d} ", dev_select[i].device_name,
839 dev_select[i].unit_number);
840 xo_emit(" {T:in} {T:sy} {T:cs}");
842 for (i = 0; i <= maxid; i++) {
843 if (cpumask & (1ul << i))
844 xo_emit(" {T:us} {T:sy} {T:id}");
848 xo_emit(" {T:us} {T:sy} {T:id}\n");
855 * Force a header to be prepended to the next output.
858 needhdr(int dummy __unused)
865 * When the terminal is resized, force an update of the maximum number of rows
866 * printed between each header repetition. Then force a new header to be
867 * prepended to the next output.
870 needresize(int signo __unused)
878 * Update the global `winlines' count of terminal rows.
887 status = ioctl(fileno(stdout), TIOCGWINSZ, &w);
888 if (status == -1 && errno == EINTR)
890 else if (status == -1)
893 winlines = w.ws_row - 3;
895 winlines = VMSTAT_DEFAULT_LINES;
900 * Inhibit doresize() calls until we are rescheduled by SIGWINCH.
906 pct(long top, long bot)
912 ans = (quad_t)top * 100 / bot;
916 #define PCT(top, bot) pct((long)(top), (long)(bot))
921 struct nchstats lnchstats;
926 xo_open_container("summary-statistics");
927 xo_emit("{:context-switches/%9u} {N:cpu context switches}\n",
929 xo_emit("{:interrupts/%9u} {N:device interrupts}\n",
931 xo_emit("{:software-interrupts/%9u} {N:software interrupts}\n",
933 xo_emit("{:traps/%9u} {N:traps}\n", sum.v_trap);
934 xo_emit("{:system-calls/%9u} {N:system calls}\n",
936 xo_emit("{:kernel-threads/%9u} {N:kernel threads created}\n",
938 xo_emit("{:forks/%9u} {N: fork() calls}\n", sum.v_forks);
939 xo_emit("{:vforks/%9u} {N:vfork() calls}\n",
941 xo_emit("{:rforks/%9u} {N:rfork() calls}\n",
943 xo_emit("{:swap-ins/%9u} {N:swap pager pageins}\n",
945 xo_emit("{:swap-in-pages/%9u} {N:swap pager pages paged in}\n",
947 xo_emit("{:swap-outs/%9u} {N:swap pager pageouts}\n",
949 xo_emit("{:swap-out-pages/%9u} {N:swap pager pages paged out}\n",
951 xo_emit("{:vnode-page-ins/%9u} {N:vnode pager pageins}\n",
953 xo_emit("{:vnode-page-in-pages/%9u} {N:vnode pager pages paged in}\n",
955 xo_emit("{:vnode-page-outs/%9u} {N:vnode pager pageouts}\n",
957 xo_emit("{:vnode-page-out-pages/%9u} {N:vnode pager pages paged out}\n",
959 xo_emit("{:page-daemon-wakeups/%9u} {N:page daemon wakeups}\n",
961 xo_emit("{:page-daemon-pages/%9u} {N:pages examined by the page "
962 "daemon}\n", sum.v_pdpages);
963 xo_emit("{:page-reclamation-shortfalls/%9u} {N:clean page reclamation "
964 "shortfalls}\n", sum.v_pdshortfalls);
965 xo_emit("{:reactivated/%9u} {N:pages reactivated by the page daemon}\n",
967 xo_emit("{:copy-on-write-faults/%9u} {N:copy-on-write faults}\n",
969 xo_emit("{:copy-on-write-optimized-faults/%9u} {N:copy-on-write "
970 "optimized faults}\n", sum.v_cow_optim);
971 xo_emit("{:zero-fill-pages/%9u} {N:zero fill pages zeroed}\n",
973 xo_emit("{:zero-fill-prezeroed/%9u} {N:zero fill pages prezeroed}\n",
975 xo_emit("{:intransit-blocking/%9u} {N:intransit blocking page faults}\n",
977 xo_emit("{:total-faults/%9u} {N:total VM faults taken}\n",
979 xo_emit("{:faults-requiring-io/%9u} {N:page faults requiring I\\/O}\n",
981 xo_emit("{:faults-from-thread-creation/%9u} {N:pages affected by "
982 "kernel thread creation}\n", sum.v_kthreadpages);
983 xo_emit("{:faults-from-fork/%9u} {N:pages affected by fork}()\n",
985 xo_emit("{:faults-from-vfork/%9u} {N:pages affected by vfork}()\n",
987 xo_emit("{:pages-rfork/%9u} {N:pages affected by rfork}()\n",
989 xo_emit("{:pages-freed/%9u} {N:pages freed}\n",
991 xo_emit("{:pages-freed-by-daemon/%9u} {N:pages freed by daemon}\n",
993 xo_emit("{:pages-freed-on-exit/%9u} {N:pages freed by exiting processes}\n",
995 xo_emit("{:active-pages/%9u} {N:pages active}\n",
997 xo_emit("{:inactive-pages/%9u} {N:pages inactive}\n",
998 sum.v_inactive_count);
999 xo_emit("{:laundry-pages/%9u} {N:pages in the laundry queue}\n",
1000 sum.v_laundry_count);
1001 xo_emit("{:wired-pages/%9u} {N:pages wired down}\n",
1003 xo_emit("{:virtual-user-wired-pages/%9lu} {N:virtual user pages wired "
1004 "down}\n", sum.v_user_wire_count);
1005 xo_emit("{:free-pages/%9u} {N:pages free}\n",
1007 xo_emit("{:bytes-per-page/%9u} {N:bytes per page}\n", sum.v_page_size);
1009 kread(X_NCHSTATS, &lnchstats, sizeof(lnchstats));
1011 size = sizeof(lnchstats);
1012 mysysctl("vfs.cache.nchstats", &lnchstats, &size);
1013 if (size != sizeof(lnchstats))
1014 xo_errx(1, "vfs.cache.nchstats size mismatch");
1016 nchtotal = lnchstats.ncs_goodhits + lnchstats.ncs_neghits +
1017 lnchstats.ncs_badhits + lnchstats.ncs_falsehits +
1018 lnchstats.ncs_miss + lnchstats.ncs_long;
1019 xo_emit("{:total-name-lookups/%9ld} {N:total name lookups}\n",
1021 xo_emit("{P:/%9s} {N:cache hits} "
1022 "({:positive-cache-hits/%ld}% pos + "
1023 "{:negative-cache-hits/%ld}% {N:neg}) "
1024 "system {:cache-hit-percent/%ld}% per-directory\n",
1025 "", PCT(lnchstats.ncs_goodhits, nchtotal),
1026 PCT(lnchstats.ncs_neghits, nchtotal),
1027 PCT(lnchstats.ncs_pass2, nchtotal));
1028 xo_emit("{P:/%9s} {L:deletions} {:deletions/%ld}%, "
1029 "{L:falsehits} {:false-hits/%ld}%, "
1030 "{L:toolong} {:too-long/%ld}%\n", "",
1031 PCT(lnchstats.ncs_badhits, nchtotal),
1032 PCT(lnchstats.ncs_falsehits, nchtotal),
1033 PCT(lnchstats.ncs_long, nchtotal));
1034 xo_close_container("summary-statistics");
1042 xo_open_container("fork-statistics");
1043 xo_emit("{:fork/%u} {N:forks}, {:fork-pages/%u} {N:pages}, "
1044 "{L:average} {:fork-average/%.2f}\n",
1045 sum.v_forks, sum.v_forkpages,
1046 sum.v_forks == 0 ? 0.0 :
1047 (double)sum.v_forkpages / sum.v_forks);
1048 xo_emit("{:vfork/%u} {N:vforks}, {:vfork-pages/%u} {N:pages}, "
1049 "{L:average} {:vfork-average/%.2f}\n",
1050 sum.v_vforks, sum.v_vforkpages,
1051 sum.v_vforks == 0 ? 0.0 :
1052 (double)sum.v_vforkpages / sum.v_vforks);
1053 xo_emit("{:rfork/%u} {N:rforks}, {:rfork-pages/%u} {N:pages}, "
1054 "{L:average} {:rfork-average/%.2f}\n",
1055 sum.v_rforks, sum.v_rforkpages,
1056 sum.v_rforks == 0 ? 0.0 :
1057 (double)sum.v_rforkpages / sum.v_rforks);
1058 xo_close_container("fork-statistics");
1064 long double busy_seconds, transfers_per_second;
1068 for (state = 0; state < CPUSTATES; ++state) {
1069 tmp = cur.cp_time[state];
1070 cur.cp_time[state] -= last.cp_time[state];
1071 last.cp_time[state] = tmp;
1074 busy_seconds = cur.snap_time - last.snap_time;
1076 xo_open_list("device");
1077 for (dn = 0; dn < num_devices; dn++) {
1078 if (dev_select[dn].selected == 0 ||
1079 dev_select[dn].selected > maxshowdevs)
1082 di = dev_select[dn].position;
1084 if (devstat_compute_statistics(&cur.dinfo->devices[di],
1085 &last.dinfo->devices[di], busy_seconds,
1086 DSM_TRANSFERS_PER_SECOND, &transfers_per_second,
1088 xo_errx(1, "%s", devstat_errbuf);
1090 xo_open_instance("device");
1091 xo_emit("{ekq:name/%s%d}",
1092 dev_select[dn].device_name,
1093 dev_select[dn].unit_number);
1094 xo_emit("{[:5}{h,hn-decimal,hn-1000:transfers/%ju}{]:}",
1095 (uintmax_t)transfers_per_second);
1096 xo_close_instance("device");
1098 xo_close_list("device");
1102 percent(const char *name, long pctv, int *over)
1106 snprintf(fmt, sizeof(fmt), " {:%s/%%%ulld/%%lld}", name,
1107 (*over && pctv <= 9) ? 1 : 2);
1109 if (*over && pctv <= 9)
1111 else if (pctv >= 100)
1122 for (state = 0; state < CPUSTATES; ++state)
1123 total += cur.cp_time[state];
1127 xo_open_container("cpu-statistics");
1128 percent("user", 100LL * (cur.cp_time[CP_USER] + cur.cp_time[CP_NICE]) /
1130 percent("system", 100LL * (cur.cp_time[CP_SYS] + cur.cp_time[CP_INTR]) /
1132 percent("idle", 100LL * cur.cp_time[CP_IDLE] / total, &over);
1133 xo_close_container("cpu-statistics");
1137 pcpustats(u_long cpumask, int maxid)
1142 /* devstats does this for cp_time */
1143 for (i = 0; i <= maxid; i++) {
1144 if ((cpumask & (1ul << i)) == 0)
1146 for (state = 0; state < CPUSTATES; ++state) {
1147 tmp = cur_cp_times[i * CPUSTATES + state];
1148 cur_cp_times[i * CPUSTATES + state] -= last_cp_times[i *
1150 last_cp_times[i * CPUSTATES + state] = tmp;
1155 xo_open_list("cpu");
1156 for (i = 0; i <= maxid; i++) {
1157 if ((cpumask & (1ul << i)) == 0)
1159 xo_open_instance("cpu");
1160 xo_emit("{ke:name/%d}", i);
1162 for (state = 0; state < CPUSTATES; ++state)
1163 total += cur_cp_times[i * CPUSTATES + state];
1167 100LL * (cur_cp_times[i * CPUSTATES + CP_USER] +
1168 cur_cp_times[i * CPUSTATES + CP_NICE]) / total, &over);
1170 100LL * (cur_cp_times[i * CPUSTATES + CP_SYS] +
1171 cur_cp_times[i * CPUSTATES + CP_INTR]) / total, &over);
1173 100LL * cur_cp_times[i * CPUSTATES + CP_IDLE] / total,
1175 xo_close_instance("cpu");
1177 xo_close_list("cpu");
1181 read_intrcnts(unsigned long **intrcnts)
1187 kread(X_SINTRCNT, &intrcntlen, sizeof(intrcntlen));
1188 if ((*intrcnts = malloc(intrcntlen)) == NULL)
1190 if (namelist[X_NINTRCNT].n_type == 0)
1191 kread(X_INTRCNT, *intrcnts, intrcntlen);
1193 kread(X_INTRCNT, &kaddr, sizeof(kaddr));
1194 kreadptr(kaddr, *intrcnts, intrcntlen);
1197 for (*intrcnts = NULL, intrcntlen = 1024; ; intrcntlen *= 2) {
1198 *intrcnts = reallocf(*intrcnts, intrcntlen);
1199 if (*intrcnts == NULL)
1200 err(1, "reallocf()");
1201 if (mysysctl("hw.intrcnt", *intrcnts, &intrcntlen) == 0)
1206 return (intrcntlen / sizeof(unsigned long));
1210 print_intrcnts(unsigned long *intrcnts, unsigned long *old_intrcnts,
1211 char *intrnames, unsigned int nintr, size_t istrnamlen, long long period_ms)
1213 uint64_t inttotal, old_inttotal, total_count, total_rate;
1214 unsigned long count, rate;
1219 xo_open_list("interrupt");
1220 for (i = 0; i < nintr; i++) {
1221 if (intrnames[0] != '\0' && (*intrcnts != 0 || aflag)) {
1222 count = *intrcnts - *old_intrcnts;
1223 rate = ((uint64_t)count * 1000 + period_ms / 2) / period_ms;
1224 xo_open_instance("interrupt");
1225 xo_emit("{d:name/%-*s}{ket:name/%s} "
1226 "{:total/%20lu} {:rate/%10lu}\n",
1227 (int)istrnamlen, intrnames, intrnames, count, rate);
1228 xo_close_instance("interrupt");
1230 intrnames += strlen(intrnames) + 1;
1231 inttotal += *intrcnts++;
1232 old_inttotal += *old_intrcnts++;
1234 total_count = inttotal - old_inttotal;
1235 total_rate = (total_count * 1000 + period_ms / 2) / period_ms;
1236 xo_close_list("interrupt");
1237 xo_emit("{L:/%-*s} {:total-interrupts/%20ju} "
1238 "{:total-rate/%10ju}\n", (int)istrnamlen,
1239 "Total", (uintmax_t)total_count, (uintmax_t)total_rate);
1243 dointr(unsigned int interval, int reps)
1245 unsigned long *intrcnts, *old_intrcnts;
1246 char *intrname, *intrnames;
1247 long long period_ms, old_uptime, uptime;
1248 size_t clen, inamlen, istrnamlen;
1252 old_intrcnts = NULL;
1253 uptime = getuptime();
1255 /* Get the names of each interrupt source */
1257 kread(X_SINTRNAMES, &inamlen, sizeof(inamlen));
1258 if ((intrnames = malloc(inamlen)) == NULL)
1259 xo_err(1, "malloc()");
1260 if (namelist[X_NINTRCNT].n_type == 0)
1261 kread(X_INTRNAMES, intrnames, inamlen);
1263 kread(X_INTRNAMES, &kaddr, sizeof(kaddr));
1264 kreadptr(kaddr, intrnames, inamlen);
1267 for (intrnames = NULL, inamlen = 1024; ; inamlen *= 2) {
1268 if ((intrnames = reallocf(intrnames, inamlen)) == NULL)
1269 xo_err(1, "reallocf()");
1270 if (mysysctl("hw.intrnames", intrnames, &inamlen) == 0)
1275 /* Determine the length of the longest interrupt name */
1276 intrname = intrnames;
1277 istrnamlen = strlen("interrupt");
1278 while (intrname < intrnames + inamlen) {
1279 clen = strlen(intrname);
1280 if (clen > istrnamlen)
1282 intrname += strlen(intrname) + 1;
1284 xo_emit("{T:/%-*s} {T:/%20s} {T:/%10s}\n",
1285 (int)istrnamlen, "interrupt", "total", "rate");
1288 * Loop reps times printing differential interrupt counts. If reps is
1289 * zero, then run just once, printing total counts
1291 xo_open_container("interrupt-statistics");
1293 period_ms = uptime / 1000000;
1295 nintr = read_intrcnts(&intrcnts);
1297 * Initialize old_intrcnts to 0 for the first pass, so
1298 * print_intrcnts will print total interrupts since boot
1300 if (old_intrcnts == NULL) {
1301 old_intrcnts = calloc(nintr, sizeof(unsigned long));
1302 if (old_intrcnts == NULL)
1303 xo_err(1, "calloc()");
1306 print_intrcnts(intrcnts, old_intrcnts, intrnames, nintr,
1307 istrnamlen, period_ms);
1311 old_intrcnts = intrcnts;
1312 if (reps >= 0 && --reps <= 0)
1314 usleep(interval * 1000);
1315 old_uptime = uptime;
1316 uptime = getuptime();
1317 period_ms = (uptime - old_uptime) / 1000000;
1320 xo_close_container("interrupt-statistics");
1324 domemstat_malloc(void)
1326 struct memory_type_list *mtlp;
1327 struct memory_type *mtp;
1331 mtlp = memstat_mtl_alloc();
1333 xo_warn("memstat_mtl_alloc");
1337 if (memstat_sysctl_malloc(mtlp, 0) < 0) {
1338 xo_warnx("memstat_sysctl_malloc: %s",
1339 memstat_strerror(memstat_mtl_geterror(mtlp)));
1343 if (memstat_kvm_malloc(mtlp, kd) < 0) {
1344 error = memstat_mtl_geterror(mtlp);
1345 if (error == MEMSTAT_ERROR_KVM)
1346 xo_warnx("memstat_kvm_malloc: %s",
1349 xo_warnx("memstat_kvm_malloc: %s",
1350 memstat_strerror(error));
1353 xo_open_container("malloc-statistics");
1354 xo_emit("{T:/%16s} {T:/%4s} {T:/%5s} {T:/%3s} {T:Size(s)}\n",
1355 "Type", "Use", "Memory", "Req");
1356 xo_open_list("memory");
1357 zones = memstat_malloc_zone_get_count();
1358 for (mtp = memstat_mtl_first(mtlp); mtp != NULL;
1359 mtp = memstat_mtl_next(mtp)) {
1360 if (memstat_get_numallocs(mtp) == 0 &&
1361 memstat_get_count(mtp) == 0)
1363 xo_open_instance("memory");
1364 xo_emit("{k:type/%16s/%s} "
1365 "{[:4}{h,hn-decimal,hn-1000:in-use/%ju}{]:} "
1366 "{[:5}{h,hn-decimal:memory-use/%ju}{]:} "
1367 "{[:4}{h,hn-decimal,hn-1000:requests/%ju}{]:} ",
1368 memstat_get_name(mtp), (uintmax_t)memstat_get_count(mtp),
1369 (uintmax_t)memstat_get_bytes(mtp),
1370 (uintmax_t)memstat_get_numallocs(mtp));
1372 xo_open_list("size");
1373 for (i = 0; i < zones; i++) {
1374 if (memstat_malloc_zone_used(mtp, i)) {
1377 xo_emit("{lh:size/%d}", memstat_malloc_zone_get_size(i));
1381 xo_close_list("size");
1382 xo_close_instance("memory");
1385 xo_close_list("memory");
1386 xo_close_container("malloc-statistics");
1387 memstat_mtl_free(mtlp);
1391 domemstat_zone(void)
1393 struct memory_type_list *mtlp;
1394 struct memory_type *mtp;
1397 mtlp = memstat_mtl_alloc();
1399 xo_warn("memstat_mtl_alloc");
1403 if (memstat_sysctl_uma(mtlp, 0) < 0) {
1404 xo_warnx("memstat_sysctl_uma: %s",
1405 memstat_strerror(memstat_mtl_geterror(mtlp)));
1409 if (memstat_kvm_uma(mtlp, kd) < 0) {
1410 error = memstat_mtl_geterror(mtlp);
1411 if (error == MEMSTAT_ERROR_KVM)
1412 xo_warnx("memstat_kvm_uma: %s",
1415 xo_warnx("memstat_kvm_uma: %s",
1416 memstat_strerror(error));
1419 xo_open_container("memory-zone-statistics");
1420 xo_emit("{T:/%-19s} {T:/%7s} {T:/%7s} {T:/%8s} {T:/%8s} {T:/%8s} "
1421 "{T:/%4s} {T:/%4s} {T:/%4s}\n", "ITEM", "SIZE",
1422 "LIMIT", "USED", "FREE", "REQ", "FAIL", "SLEEP", "XDOM");
1423 xo_open_list("zone");
1424 for (mtp = memstat_mtl_first(mtlp); mtp != NULL;
1425 mtp = memstat_mtl_next(mtp)) {
1426 len = strlen(memstat_get_name(mtp));
1427 xo_open_instance("zone");
1428 xo_emit("{k:name/%s}:{d:size/%*ju}{e:size/%ju},"
1429 "{:limit/%7ju},{:used/%8ju},"
1430 "{:free/%8ju},{:requests/%8ju},"
1431 "{:fail/%4ju},{:sleep/%4ju},{:xdomain/%4ju}\n",
1432 memstat_get_name(mtp), MAX(1, 26 - len),
1433 (uintmax_t)memstat_get_size(mtp),
1434 (uintmax_t)memstat_get_size(mtp),
1435 (uintmax_t)memstat_get_countlimit(mtp),
1436 (uintmax_t)memstat_get_count(mtp),
1437 (uintmax_t)memstat_get_free(mtp),
1438 (uintmax_t)memstat_get_numallocs(mtp),
1439 (uintmax_t)memstat_get_failures(mtp),
1440 (uintmax_t)memstat_get_sleeps(mtp),
1441 (uintmax_t)memstat_get_xdomain(mtp));
1442 xo_close_instance("zone");
1444 memstat_mtl_free(mtlp);
1445 xo_close_list("zone");
1446 xo_close_container("memory-zone-statistics");
1450 display_object(struct kinfo_vmobject *kvo)
1454 xo_open_instance("object");
1455 xo_emit("{:resident/%5ju} ", (uintmax_t)kvo->kvo_resident);
1456 xo_emit("{:active/%5ju} ", (uintmax_t)kvo->kvo_active);
1457 xo_emit("{:inactive/%5ju} ", (uintmax_t)kvo->kvo_inactive);
1458 xo_emit("{:refcount/%3d} ", kvo->kvo_ref_count);
1459 xo_emit("{:shadowcount/%3d} ", kvo->kvo_shadow_count);
1461 #define MEMATTR_STR(type, val) \
1462 if (kvo->kvo_memattr == (type)) { \
1465 #ifdef VM_MEMATTR_UNCACHEABLE
1466 MEMATTR_STR(VM_MEMATTR_UNCACHEABLE, "UC")
1468 #ifdef VM_MEMATTR_WRITE_COMBINING
1469 MEMATTR_STR(VM_MEMATTR_WRITE_COMBINING, "WC")
1471 #ifdef VM_MEMATTR_WRITE_THROUGH
1472 MEMATTR_STR(VM_MEMATTR_WRITE_THROUGH, "WT")
1474 #ifdef VM_MEMATTR_WRITE_PROTECTED
1475 MEMATTR_STR(VM_MEMATTR_WRITE_PROTECTED, "WP")
1477 #ifdef VM_MEMATTR_WRITE_BACK
1478 MEMATTR_STR(VM_MEMATTR_WRITE_BACK, "WB")
1480 #ifdef VM_MEMATTR_WEAK_UNCACHEABLE
1481 MEMATTR_STR(VM_MEMATTR_WEAK_UNCACHEABLE, "UC-")
1483 #ifdef VM_MEMATTR_WB_WA
1484 MEMATTR_STR(VM_MEMATTR_WB_WA, "WB")
1486 #ifdef VM_MEMATTR_NOCACHE
1487 MEMATTR_STR(VM_MEMATTR_NOCACHE, "NC")
1489 #ifdef VM_MEMATTR_DEVICE
1490 MEMATTR_STR(VM_MEMATTR_DEVICE, "DEV")
1492 #ifdef VM_MEMATTR_DEVICE_NP
1493 MEMATTR_STR(VM_MEMATTR_DEVICE, "NP")
1495 #ifdef VM_MEMATTR_CACHEABLE
1496 MEMATTR_STR(VM_MEMATTR_CACHEABLE, "C")
1498 #ifdef VM_MEMATTR_PREFETCHABLE
1499 MEMATTR_STR(VM_MEMATTR_PREFETCHABLE, "PRE")
1505 xo_emit("{:attribute/%-3s} ", str);
1506 switch (kvo->kvo_type) {
1507 case KVME_TYPE_NONE:
1510 case KVME_TYPE_DEFAULT:
1513 case KVME_TYPE_VNODE:
1516 case KVME_TYPE_SWAP:
1519 case KVME_TYPE_DEVICE:
1522 case KVME_TYPE_PHYS:
1525 case KVME_TYPE_DEAD:
1531 case KVME_TYPE_MGTDEVICE:
1534 case KVME_TYPE_UNKNOWN:
1539 xo_emit("{:type/%-2s} ", str);
1540 xo_emit("{:path/%-s}\n", kvo->kvo_path);
1541 xo_close_instance("object");
1547 struct kinfo_vmobject *kvo;
1550 kvo = kinfo_getvmobject(&cnt);
1552 xo_warn("Failed to fetch VM object list");
1555 xo_emit("{T:RES/%5s} {T:ACT/%5s} {T:INACT/%5s} {T:REF/%3s} {T:SHD/%3s} "
1556 "{T:CM/%3s} {T:TP/%2s} {T:PATH/%s}\n");
1557 xo_open_list("object");
1558 for (i = 0; i < cnt; i++)
1559 display_object(&kvo[i]);
1561 xo_close_list("object");
1565 * kread reads something from the kernel, given its nlist index.
1568 kreado(int nlx, void *addr, size_t size, size_t offset)
1572 if (namelist[nlx].n_type == 0 || namelist[nlx].n_value == 0) {
1573 sym = namelist[nlx].n_name;
1576 xo_errx(1, "symbol %s not defined", sym);
1578 if ((size_t)kvm_read(kd, namelist[nlx].n_value + offset, addr,
1580 sym = namelist[nlx].n_name;
1583 xo_errx(1, "%s: %s", sym, kvm_geterr(kd));
1588 kread(int nlx, void *addr, size_t size)
1591 kreado(nlx, addr, size, 0);
1595 kreadptr(uintptr_t addr, void *buf, size_t size)
1598 if ((size_t)kvm_read(kd, addr, buf, size) != size)
1599 xo_errx(1, "%s", kvm_geterr(kd));
1606 "usage: vmstat [-afHhimoPsz] [-M core [-N system]] [-c count] [-n devs]\n",
1607 " [-p type,if,pass] [-w wait] [disks] [wait [count]]\n");