=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/vmstat/vmstat.c,v retrieving revision 1.51 retrieving revision 1.52 diff -c -r1.51 -r1.52 *** src/usr.bin/vmstat/vmstat.c 2001/04/30 13:54:51 1.51 --- src/usr.bin/vmstat/vmstat.c 2001/05/11 06:46:40 1.52 *************** *** 1,5 **** /* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */ ! /* $OpenBSD: vmstat.c,v 1.51 2001/04/30 13:54:51 art Exp $ */ /* * Copyright (c) 1980, 1986, 1991, 1993 --- 1,5 ---- /* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */ ! /* $OpenBSD: vmstat.c,v 1.52 2001/05/11 06:46:40 angelos Exp $ */ /* * Copyright (c) 1980, 1986, 1991, 1993 *************** *** 410,416 **** /* Read new disk statistics */ dkreadstats(); #ifdef UVM ! kread(X_UVMEXP, &uvmexp, sizeof(uvmexp)); #else kread(X_SUM, &sum, sizeof(sum)); #endif --- 410,427 ---- /* Read new disk statistics */ dkreadstats(); #ifdef UVM ! if (nlist == NULL && memf == NULL) { ! kread(X_UVMEXP, &uvmexp, sizeof(uvmexp)); ! } else { ! size = sizeof(uvmexp); ! mib[0] = CTL_VM; ! mib[1] = VM_UVMEXP; ! if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) { ! printf("Can't get kerninfo: %s\n", ! strerror(errno)); ! bzero(&uvmexp, sizeof(uvmexp)); ! } ! } #else kread(X_SUM, &sum, sizeof(sum)); #endif *************** *** 514,524 **** dotimes() { u_int pgintime, rectime; pgintime = 0; rectime = 0; #ifdef UVM ! kread(X_UVMEXP, &uvmexp, sizeof(uvmexp)); (void)printf("%u reactivates, %u total time (usec)\n", uvmexp.pdreact, rectime); (void)printf("average: %u usec / reclaim\n", rectime / uvmexp.pdreact); --- 525,548 ---- dotimes() { u_int pgintime, rectime; + int mib[2]; + size_t size; pgintime = 0; rectime = 0; #ifdef UVM ! if (nlist == NULL && memf == NULL) { ! kread(X_UVMEXP, &uvmexp, sizeof(uvmexp)); ! } else { ! size = sizeof(uvmexp); ! mib[0] = CTL_VM; ! mib[1] = VM_UVMEXP; ! if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) { ! printf("Can't get kerninfo: %s\n", strerror(errno)); ! bzero(&uvmexp, sizeof(uvmexp)); ! } ! } ! (void)printf("%u reactivates, %u total time (usec)\n", uvmexp.pdreact, rectime); (void)printf("average: %u usec / reclaim\n", rectime / uvmexp.pdreact); *************** *** 559,568 **** { struct nchstats nchstats; long nchtotal; ! int nselcoll; #ifdef UVM ! kread(X_UVMEXP, &uvmexp, sizeof(uvmexp)); /* vm_page constants */ (void)printf("%11u bytes per page\n", uvmexp.pagesize); --- 583,604 ---- { struct nchstats nchstats; long nchtotal; ! size_t size; ! int mib[2], nselcoll; #ifdef UVM ! if (nlist == NULL && memf == NULL) { ! kread(X_UVMEXP, &nchstats, sizeof(uvmexp)); ! } else { ! size = sizeof(uvmexp); ! mib[0] = CTL_VM; ! mib[1] = VM_UVMEXP; ! if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) { ! printf("Can't get kerninfo: %s\n", strerror(errno)); ! bzero(&uvmexp, sizeof(uvmexp)); ! } ! } ! /* vm_page constants */ (void)printf("%11u bytes per page\n", uvmexp.pagesize); *************** *** 641,653 **** (void)printf("%11u bytes per page\n", sum.v_page_size); #endif ! kread(X_NCHSTATS, &nchstats, sizeof(nchstats)); nchtotal = nchstats.ncs_goodhits + nchstats.ncs_neghits + nchstats.ncs_badhits + nchstats.ncs_falsehits + nchstats.ncs_miss + nchstats.ncs_long; (void)printf("%11ld total name lookups\n", nchtotal); ! (void)printf( ! "%11s cache hits (%d%% pos + %d%% neg) system %d%% per-directory\n", "", PCT(nchstats.ncs_goodhits, nchtotal), PCT(nchstats.ncs_neghits, nchtotal), PCT(nchstats.ncs_pass2, nchtotal)); --- 677,700 ---- (void)printf("%11u bytes per page\n", sum.v_page_size); #endif ! if (nlist == NULL && memf == NULL) { ! kread(X_NCHSTATS, &nchstats, sizeof(nchstats)); ! } else { ! size = sizeof(nchstats); ! mib[0] = CTL_KERN; ! mib[1] = KERN_NCHSTATS; ! if (sysctl(mib, 2, &nchstats, &size, NULL, 0) < 0) { ! printf("Can't get kerninfo: %s\n", strerror(errno)); ! bzero(&nchstats, sizeof(nchstats)); ! } ! } ! nchtotal = nchstats.ncs_goodhits + nchstats.ncs_neghits + nchstats.ncs_badhits + nchstats.ncs_falsehits + nchstats.ncs_miss + nchstats.ncs_long; (void)printf("%11ld total name lookups\n", nchtotal); ! (void)printf("%11s cache hits (%d%% pos + %d%% neg) system %d%% " ! "per-directory\n", "", PCT(nchstats.ncs_goodhits, nchtotal), PCT(nchstats.ncs_neghits, nchtotal), PCT(nchstats.ncs_pass2, nchtotal)); *************** *** 655,661 **** PCT(nchstats.ncs_badhits, nchtotal), PCT(nchstats.ncs_falsehits, nchtotal), PCT(nchstats.ncs_long, nchtotal)); ! kread(X_NSELCOLL, &nselcoll, sizeof(nselcoll)); (void)printf("%11d select collisions\n", nselcoll); } --- 702,719 ---- PCT(nchstats.ncs_badhits, nchtotal), PCT(nchstats.ncs_falsehits, nchtotal), PCT(nchstats.ncs_long, nchtotal)); ! ! if (nlist == NULL && memf == NULL) { ! kread(X_NSELCOLL, &nselcoll, sizeof(nselcoll)); ! } else { ! size = sizeof(nselcoll); ! mib[0] = CTL_KERN; ! mib[1] = KERN_NSELCOLL; ! if (sysctl(mib, 2, &nselcoll, &size, NULL, 0) < 0) { ! printf("Can't get kerninfo: %s\n", strerror(errno)); ! nselcoll = 0; ! } ! } (void)printf("%11d select collisions\n", nselcoll); } *************** *** 663,670 **** doforkst() { struct forkstat fks; ! kread(X_FORKSTAT, &fks, sizeof(struct forkstat)); (void)printf("%d forks, %d pages, average %.2f\n", fks.cntfork, fks.sizfork, (double)fks.sizfork / fks.cntfork); (void)printf("%d vforks, %d pages, average %.2f\n", --- 721,741 ---- doforkst() { struct forkstat fks; + size_t size; + int mib[2]; ! if (nlist == NULL && memf == NULL) { ! kread(X_FORKSTAT, &fks, sizeof(struct forkstat)); ! } else { ! size = sizeof(struct forkstat); ! mib[0] = CTL_KERN; ! mib[1] = KERN_FORKSTAT; ! if (sysctl(mib, 2, &fks, &size, NULL, 0) < 0) { ! printf("Can't get kerninfo: %s\n", strerror(errno)); ! bzero(&fks, sizeof(struct forkstat)); ! } ! } ! (void)printf("%d forks, %d pages, average %.2f\n", fks.cntfork, fks.sizfork, (double)fks.sizfork / fks.cntfork); (void)printf("%d vforks, %d pages, average %.2f\n", *************** *** 924,930 **** return; } ! kread(X_KMEMSTAT, kmemstats, sizeof(kmemstats)); (void)printf("\nMemory usage type by bucket size\n"); (void)printf(" Size Type(s)\n"); kp = &buckets[MINBUCKET]; --- 995,1020 ---- return; } ! if (memf == NULL && nlistf == NULL) { ! bzero(kmemstats, sizeof(kmemstats)); ! for (i = 0; i < M_LAST; i++) { ! mib[0] = CTL_KERN; ! mib[1] = KERN_MALLOCSTATS; ! mib[2] = KERN_MALLOC_KMEMSTATS; ! mib[3] = i; ! siz = sizeof(struct kmemstats); ! ! /* ! * Skip errors -- these are presumed to be unallocated ! * entries. ! */ ! if (sysctl(mib, 4, &kmemstats[i], &siz, NULL, 0) < 0) ! continue; ! } ! } else { ! kread(X_KMEMSTAT, kmemstats, sizeof(kmemstats)); ! } ! (void)printf("\nMemory usage type by bucket size\n"); (void)printf(" Size Type(s)\n"); kp = &buckets[MINBUCKET];