Date: Tue, 03 Sep 2019 14:06:12 -0000 From: Michael <mike@reifenberger.com> To: rgrimes@freebsd.org, "Rodney W. Grimes" <freebsd@gndrsh.dnsmgr.net>, Michael Reifenberger <mr@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r345804 - head/usr.bin/systat Message-ID: <CE944E7A-6D12-4283-93CC-8B69F4BC2BC5@reifenberger.com> In-Reply-To: <201904021408.x32E8Ho9021667@gndrsh.dnsmgr.net> References: <201904021408.x32E8Ho9021667@gndrsh.dnsmgr.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, Am 2=2E April 2019 16:08:17 MESZ schrieb "Rodney W=2E Grimes" <freebsd@gnd= rsh=2Ednsmgr=2Enet>: >> Author: mr >> Date: Tue Apr 2 14:01:03 2019 >> New Revision: 345804 >> URL: https://svnweb=2Efreebsd=2Eorg/changeset/base/345804 >>=20 >> Log: >> systat -zarc to display disk activities like -vm >> =20 >> PR: 213310 >> Submitted by: ota >> MFH: 4 weeks > >? MFC: Yes, indeed=2E > >> Differential Revision: https://reviews=2Efreebsd=2Eorg/D18726 >>=20 >> Modified: >> head/usr=2Ebin/systat/devs=2Ec >> head/usr=2Ebin/systat/devs=2Eh >> head/usr=2Ebin/systat/iostat=2Ec >> head/usr=2Ebin/systat/swap=2Ec >> head/usr=2Ebin/systat/systat=2Eh >> head/usr=2Ebin/systat/vmstat=2Ec >> head/usr=2Ebin/systat/zarc=2Ec >>=20 >> Modified: head/usr=2Ebin/systat/devs=2Ec >> >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/usr=2Ebin/systat/devs=2Ec Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/devs=2Ec Tue Apr 2 14:01:03 2019 (r345804) >> @@ -2,6 +2,7 @@ >> * SPDX-License-Identifier: BSD-3-Clause >> * >> * Copyright (c) 1998 Kenneth D=2E Merry=2E >> + * 2015 Yoshihiro Ota >> * All rights reserved=2E > > >Can we get in contact with Yoshihiro Ota about his >copyright statements, and correcting this to make >it clear that it is Kenneth D=2E Merry that is asserting >"All rights reserved" and if Ota does nor does not wish to assert >"All rights reserved"=2E > >As committed this makes a grey area on Kenneth's assertion, >also leaving out the word copyright on Yoshihiro's line is a bit iffy=2E > >I am only commenting once, this issue appears several times=2E >We can go back out to D18726 to discuss it if need be=2E > You could add a comment in the PR too, I intended to keep it open until MF= C >> * >> * Redistribution and use in source and binary forms, with or >without >> @@ -69,7 +70,6 @@ static const char sccsid[] =3D "@(#)disks=2Ec 8=2E1 >(Berkele >> #include <sys/resource=2Eh> >> =20 >> #include <ctype=2Eh> >> -#include <devstat=2Eh> >> #include <err=2Eh> >> #include <stdlib=2Eh> >> #include <string=2Eh> >> @@ -84,6 +84,8 @@ typedef enum { >> DS_MATCHTYPE_PATTERN >> } last_match_type; >> =20 >> +struct statinfo cur_dev, last_dev, run_dev; >> + >> last_match_type last_type; >> struct device_selection *dev_select; >> long generation; >> @@ -101,10 +103,8 @@ static int dsselect(const char *args, >devstat_select_m >> int maxshowdevs, struct statinfo *s1); >> =20 >> int >> -dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 >__unused, >> - struct statinfo *s3 __unused) >> +dsinit(int maxshowdevs) >> { >> - >> /* >> * Make sure that the userland devstat version matches the kernel >> * devstat version=2E If not, exit and print a message informing >> @@ -113,6 +113,18 @@ dsinit(int maxshowdevs, struct statinfo *s1, >struct st >> if (devstat_checkversion(NULL) < 0) >> errx(1, "%s", devstat_errbuf); >> =20 >> + if( cur_dev=2Edinfo ) // init was alreay ran >> + return(1); >> + >> + if ((num_devices =3D devstat_getnumdevs(NULL)) < 0) { >> + warnx("%s", devstat_errbuf); >> + return(0); >> + } >> + >> + cur_dev=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> + last_dev=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> + run_dev=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> + >> generation =3D 0; >> num_devices =3D 0; >> num_selected =3D 0; >> @@ -120,11 +132,11 @@ dsinit(int maxshowdevs, struct statinfo *s1, >struct st >> select_generation =3D 0; >> last_type =3D DS_MATCHTYPE_NONE; >> =20 >> - if (devstat_getdevs(NULL, s1) =3D=3D -1) >> + if (devstat_getdevs(NULL, &cur_dev) =3D=3D -1) >> errx(1, "%s", devstat_errbuf); >> =20 >> - num_devices =3D s1->dinfo->numdevs; >> - generation =3D s1->dinfo->generation; >> + num_devices =3D cur_dev=2Edinfo->numdevs; >> + generation =3D cur_dev=2Edinfo->generation; >> =20 >> dev_select =3D NULL; >> =20 >> @@ -134,13 +146,31 @@ dsinit(int maxshowdevs, struct statinfo *s1, >struct st >> * or 1=2E If we get back -1, though, there is an error=2E >> */ >> if (devstat_selectdevs(&dev_select, &num_selected, &num_selections, >> - &select_generation, generation, s1->dinfo->devices, >num_devices, >> + &select_generation, generation, cur_dev=2Edinfo->devices, >num_devices, >> NULL, 0, NULL, 0, DS_SELECT_ADD, maxshowdevs, 0) =3D=3D -1) >> errx(1, "%d %s", __LINE__, devstat_errbuf); >> =20 >> return(1); >> } >> =20 >> + >> +void >> +dsgetinfo(struct statinfo* dev) >> +{ >> + switch (devstat_getdevs(NULL, dev)) { >> + case -1: >> + errx(1, "%s", devstat_errbuf); >> + break; >> + case 1: >> + num_devices =3D dev->dinfo->numdevs; >> + generation =3D dev->dinfo->generation; >> + cmdkre("refresh", NULL); >> + break; >> + default: >> + break; >> + } >> +} >> + >> int >> dscmd(const char *cmd, const char *args, int maxshowdevs, struct >statinfo *s1) >> { >> @@ -330,4 +360,84 @@ dsselect(const char *args, devstat_select_mode >select_ >> return(2); >> } >> return(1); >> +} >> + >> + >> +void >> +dslabel(int maxdrives, int diskcol, int diskrow) >> +{ >> + int i, j; >> + >> + mvprintw(diskrow, diskcol, "Disks"); >> + mvprintw(diskrow + 1, diskcol, "KB/t"); >> + mvprintw(diskrow + 2, diskcol, "tps"); >> + mvprintw(diskrow + 3, diskcol, "MB/s"); >> + mvprintw(diskrow + 4, diskcol, "%%busy"); >> + /* >> + * For now, we don't support a fourth disk statistic=2E So there's >> + * no point in providing a label for it=2E If someone can think of a >> + * fourth useful disk statistic, there is room to add it=2E >> + */ >> + /* mvprintw(diskrow + 4, diskcol, " msps"); */ >> + j =3D 0; >> + for (i =3D 0; i < num_devices && j < maxdrives; i++) >> + if (dev_select[i]=2Eselected) { >> + char tmpstr[80]; >> + sprintf(tmpstr, "%s%d", dev_select[i]=2Edevice_name, >> + dev_select[i]=2Eunit_number); >> + mvprintw(diskrow, diskcol + 5 + 6 * j, >> + " %5=2E5s", tmpstr); >> + j++; >> + } >> +} >> + >> +static void >> +dsshow2(int diskcol, int diskrow, int dn, int lc, struct statinfo >*now, struct statinfo *then) >> +{ >> + long double transfers_per_second; >> + long double kb_per_transfer, mb_per_second; >> + long double elapsed_time, device_busy; >> + int di; >> + >> + di =3D dev_select[dn]=2Eposition; >> + >> + if (then !=3D NULL) { >> + /* Calculate relative to previous sample */ >> + elapsed_time =3D now->snap_time - then->snap_time; >> + } else { >> + /* Calculate relative to device creation */ >> + elapsed_time =3D now->snap_time - devstat_compute_etime( >> + &now->dinfo->devices[di]=2Ecreation_time, NULL); >> + } >> + >> + if (devstat_compute_statistics(&now->dinfo->devices[di], then ? >> + &then->dinfo->devices[di] : NULL, elapsed_time, >> + DSM_KB_PER_TRANSFER, &kb_per_transfer, >> + DSM_TRANSFERS_PER_SECOND, &transfers_per_second, >> + DSM_MB_PER_SECOND, &mb_per_second, >> + DSM_BUSY_PCT, &device_busy, >> + DSM_NONE) !=3D 0) >> + errx(1, "%s", devstat_errbuf); >> + >> + lc =3D diskcol + lc * 6; >> + putlongdouble(kb_per_transfer, diskrow + 1, lc, 5, 2, 0); >> + putlongdouble(transfers_per_second, diskrow + 2, lc, 5, 0, 0); >> + putlongdouble(mb_per_second, diskrow + 3, lc, 5, 2, 0); >> + putlongdouble(device_busy, diskrow + 4, lc, 5, 0, 0); >> +} >> + >> +static void >> +dsshow3(int diskcol, int diskrow, int dn, int lc, struct statinfo >*now, struct statinfo *then) >> +{ >> + dsshow2(diskcol, diskrow, dn, lc, now, then); >> +} >> + >> +void >> +dsshow(int maxdrives, int diskcol, int diskrow, struct statinfo >*now, struct statinfo *then) >> +{ >> + int i, lc; >> + >> + for (i =3D 0, lc =3D 0; i < num_devices && lc < maxdrives; i++) >> + if (dev_select[i]=2Eselected) >> + dsshow3(diskcol, diskrow, i, ++lc, now, then); >> } >>=20 >> Modified: head/usr=2Ebin/systat/devs=2Eh >> >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/usr=2Ebin/systat/devs=2Eh Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/devs=2Eh Tue Apr 2 14:01:03 2019 (r345804) >> @@ -2,6 +2,7 @@ >> * SPDX-License-Identifier: BSD-2-Clause-FreeBSD >> * >> * Copyright (c) 1998 David E=2E O'Brien >> + * 2015 Yoshihiro Ota >> * All rights reserved=2E >> * >> * Redistribution and use in source and binary forms, with or >without >> @@ -28,5 +29,18 @@ >> * $FreeBSD$ >> */ >> =20 >> -int dsinit(int, struct statinfo *, struct statinfo *, struct >statinfo *); >> +#ifndef DEVS_H >> +#define DEVS_H >> + >> +#include <devstat=2Eh> >> + >> +int dsinit(int); >> +void dsgetinfo(struct statinfo *); >> int dscmd(const char *, const char *, int, struct statinfo *); >> + >> +void dslabel(int, int, int); >> +void dsshow(int, int, int, struct statinfo *, struct statinfo *); >> + >> +extern struct statinfo cur_dev, last_dev, run_dev; >> + >> +#endif >>=20 >> Modified: head/usr=2Ebin/systat/iostat=2Ec >> >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/usr=2Ebin/systat/iostat=2Ec Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/iostat=2Ec Tue Apr 2 14:01:03 2019 (r345804) >> @@ -79,8 +79,6 @@ static const char sccsid[] =3D "@(#)iostat=2Ec 8=2E1 >(Berkel >> #include "extern=2Eh" >> #include "devs=2Eh" >> =20 >> -struct statinfo cur, last; >> - >> static int linesperregion; >> static double etime; >> static int numbers =3D 0; /* default display bar graphs */ >> @@ -111,17 +109,11 @@ closeiostat(WINDOW *w) >> int >> initiostat(void) >> { >> - if ((num_devices =3D devstat_getnumdevs(NULL)) < 0) >> - return(0); >> - >> - cur=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> - last=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> - >> /* >> * This value for maxshowdevs (100) is bogus=2E I'm not sure exactly >> * how to calculate it, though=2E >> */ >> - if (dsinit(100, &cur, &last, NULL) !=3D 1) >> + if (dsinit(7) !=3D 1) >> return(0); >> =20 >> return(1); >> @@ -133,17 +125,17 @@ fetchiostat(void) >> struct devinfo *tmp_dinfo; >> size_t len; >> =20 >> - len =3D sizeof(cur=2Ecp_time); >> - if (sysctlbyname("kern=2Ecp_time", &cur=2Ecp_time, &len, NULL, 0) >> - || len !=3D sizeof(cur=2Ecp_time)) { >> + len =3D sizeof(cur_dev=2Ecp_time); >> + if (sysctlbyname("kern=2Ecp_time", &cur_dev=2Ecp_time, &len, NULL, 0) >> + || len !=3D sizeof(cur_dev=2Ecp_time)) { >> perror("kern=2Ecp_time"); >> exit (1); >> } >> - tmp_dinfo =3D last=2Edinfo; >> - last=2Edinfo =3D cur=2Edinfo; >> - cur=2Edinfo =3D tmp_dinfo; >> + tmp_dinfo =3D last_dev=2Edinfo; >> + last_dev=2Edinfo =3D cur_dev=2Edinfo; >> + cur_dev=2Edinfo =3D tmp_dinfo; >> =20 >> - last=2Esnap_time =3D cur=2Esnap_time; >> + last_dev=2Esnap_time =3D cur_dev=2Esnap_time; >> =20 >> /* >> * Here what we want to do is refresh our device stats=2E >> @@ -152,7 +144,7 @@ fetchiostat(void) >> * the selection process again, in case a device that we >> * were previously displaying has gone away=2E >> */ >> - switch (devstat_getdevs(NULL, &cur)) { >> + switch (devstat_getdevs(NULL, &cur_dev)) { >> case -1: >> errx(1, "%s", devstat_errbuf); >> break; >> @@ -162,8 +154,8 @@ fetchiostat(void) >> default: >> break; >> } >> - num_devices =3D cur=2Edinfo->numdevs; >> - generation =3D cur=2Edinfo->generation; >> + num_devices =3D cur_dev=2Edinfo->numdevs; >> + generation =3D cur_dev=2Edinfo->generation; >> =20 >> } >> =20 >> @@ -260,11 +252,11 @@ showiostat(void) >> long t; >> int i, row, _col; >> =20 >> -#define X(fld) t =3D cur=2Efld[i]; cur=2Efld[i] -=3D last=2Efld[i]; >last=2Efld[i] =3D t >> +#define X(fld) t =3D cur_dev=2Efld[i]; cur_dev=2Efld[i] -=3D >last_dev=2Efld[i]; last_dev=2Efld[i] =3D t >> etime =3D 0; >> for(i =3D 0; i < CPUSTATES; i++) { >> X(cp_time); >> - etime +=3D cur=2Ecp_time[i]; >> + etime +=3D cur_dev=2Ecp_time[i]; >> } >> if (etime =3D=3D 0=2E0) >> etime =3D 1=2E0; >> @@ -313,10 +305,10 @@ devstats(int row, int _col, int dn) >> =20 >> di =3D dev_select[dn]=2Eposition; >> =20 >> - busy_seconds =3D cur=2Esnap_time - last=2Esnap_time; >> + busy_seconds =3D cur_dev=2Esnap_time - last_dev=2Esnap_time; >> =20 >> - if (devstat_compute_statistics(&cur=2Edinfo->devices[di], >> - &last=2Edinfo->devices[di], busy_seconds, >> + if (devstat_compute_statistics(&cur_dev=2Edinfo->devices[di], >> + &last_dev=2Edinfo->devices[di], busy_seconds, >> DSM_KB_PER_TRANSFER, &kb_per_transfer, >> DSM_TRANSFERS_PER_SECOND, &transfers_per_second, >> DSM_MB_PER_SECOND, &mb_per_second, DSM_NONE) !=3D 0) >> @@ -349,12 +341,12 @@ stat1(int row, int o) >> =20 >> dtime =3D 0=2E0; >> for (i =3D 0; i < CPUSTATES; i++) >> - dtime +=3D cur=2Ecp_time[i]; >> + dtime +=3D cur_dev=2Ecp_time[i]; >> if (dtime =3D=3D 0=2E0) >> dtime =3D 1=2E0; >> wmove(wnd, row, INSET); >> #define CPUSCALE 0=2E5 >> - histogram(100=2E0 * cur=2Ecp_time[o] / dtime, 50, CPUSCALE); >> + histogram(100=2E0 * cur_dev=2Ecp_time[o] / dtime, 50, CPUSCALE); >> } >> =20 >> static void >> @@ -388,7 +380,7 @@ cmdiostat(const char *cmd, const char *args) >> numbers =3D 1; >> else if (prefix(cmd, "bars")) >> numbers =3D 0; >> - else if (!dscmd(cmd, args, 100, &cur)) >> + else if (!dscmd(cmd, args, 100, &cur_dev)) >> return (0); >> wclear(wnd); >> labeliostat(); >>=20 >> Modified: head/usr=2Ebin/systat/swap=2Ec >> >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/usr=2Ebin/systat/swap=2Ec Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/swap=2Ec Tue Apr 2 14:01:03 2019 (r345804) >> @@ -3,6 +3,7 @@ >> * >> * Copyright (c) 1980, 1992, 1993 >> * The Regents of the University of California=2E All rights >reserved=2E >> + * Copyright (c) 2017 Yoshihiro Ota >> * >> * Redistribution and use in source and binary forms, with or >without >> * modification, are permitted provided that the following >conditions >> @@ -55,6 +56,7 @@ static const char sccsid[] =3D "@(#)swap=2Ec 8=2E3 >(Berkeley >> =20 >> #include "systat=2Eh" >> #include "extern=2Eh" >> +#include "devs=2Eh" >> =20 >> kvm_t *kd; >> =20 >> @@ -137,13 +139,15 @@ initswap(void) >> oulen =3D ulen; >> =20 >> once =3D 1; >> + >> + dsinit(12); >> + >> return (1); >> } >> =20 >> void >> fetchswap(void) >> { >> - >> okvnsw =3D kvnsw; >> if ((kvnsw =3D kvm_getswapinfo(kd, kvmsw, NSWAP, 0)) < 0) { >> error("systat: kvm_getswapinfo failed"); >> @@ -153,6 +157,15 @@ fetchswap(void) >> odlen =3D dlen; >> oulen =3D ulen; >> calclens(); >> + >> + struct devinfo *tmp_dinfo; >> + >> + tmp_dinfo =3D last_dev=2Edinfo; >> + last_dev=2Edinfo =3D cur_dev=2Edinfo; >> + cur_dev=2Edinfo =3D tmp_dinfo; >> + >> + last_dev=2Esnap_time =3D cur_dev=2Esnap_time; >> + dsgetinfo( &cur_dev ); >> } >> =20 >> void >> @@ -178,6 +191,7 @@ labelswap(void) >> name =3D kvmsw[i]=2Eksw_devname; >> mvwprintw(wnd, i + 1, 0, "%*s", -dlen, name); >> } >> + dslabel(12, 0, 18); >> } >> =20 >> void >> @@ -217,4 +231,5 @@ showswap(void) >> waddch(wnd, 'X'); >> wclrtoeol(wnd); >> } >> + dsshow(12, 0, 18, &cur_dev, &last_dev); >> } >>=20 >> Modified: head/usr=2Ebin/systat/systat=2Eh >> >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/usr=2Ebin/systat/systat=2Eh Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/systat=2Eh Tue Apr 2 14:01:03 2019 (r345804) >> @@ -68,3 +68,7 @@ extern int use_kvm; >> #define NVAL(indx) namelist[(indx)]=2En_value >> #define NPTR(indx) (void *)NVAL((indx)) >> #define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len)) >> + >> +extern void putint(int, int, int, int); >> +extern void putfloat(double, int, int, int, int, int); >> +extern void putlongdouble(long double, int, int, int, int, int); >>=20 >> Modified: head/usr=2Ebin/systat/vmstat=2Ec >> >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/usr=2Ebin/systat/vmstat=2Ec Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/vmstat=2Ec Tue Apr 2 14:01:03 2019 (r345804) >> @@ -66,7 +66,6 @@ static const char sccsid[] =3D "@(#)vmstat=2Ec 8=2E2 >(Berkel >> #include <time=2Eh> >> #include <unistd=2Eh> >> #include <utmpx=2Eh> >> -#include <devstat=2Eh> >> #include "systat=2Eh" >> #include "extern=2Eh" >> #include "devs=2Eh" >> @@ -125,7 +124,6 @@ static struct Info { >> static u_long kmem_size; >> static u_int v_page_count; >> =20 >> -struct statinfo cur, last, run; >> =20 >> #define total s=2ETotal >> #define nchtotal s=2Enchstats >> @@ -137,13 +135,9 @@ enum divisor { IEC =3D 0, SI =3D HN_DIVISOR_1000 }= ; >> static void allocinfo(struct Info *); >> static void copyinfo(struct Info *, struct Info *); >> static float cputime(int); >> -static void dinfo(int, int, struct statinfo *, struct statinfo *); >> static void do_putuint64(uint64_t, int, int, int, int); >> static void getinfo(struct Info *); >> -static void putint(int, int, int, int); >> static void putuint64(uint64_t, int, int, int); >> -static void putfloat(double, int, int, int, int, int); >> -static void putlongdouble(long double, int, int, int, int, int); >> static int ucount(void); >> =20 >> static int ncpu; >> @@ -209,18 +203,9 @@ initkre(void) >> int i; >> size_t sz; >> =20 >> - if ((num_devices =3D devstat_getnumdevs(NULL)) < 0) { >> - warnx("%s", devstat_errbuf); >> + if (dsinit(MAXDRIVES) !=3D 1) >> return(0); >> - } >> =20 >> - cur=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> - last=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> - run=2Edinfo =3D calloc(1, sizeof(struct devinfo)); >> - >> - if (dsinit(MAXDRIVES, &cur, &last, &run) !=3D 1) >> - return(0); >> - >> if (nintr =3D=3D 0) { >> if (sysctlbyname("hw=2Eintrcnt", NULL, &sz, NULL, 0) =3D=3D -1) { >> error("sysctl(hw=2Eintrcnt=2E=2E=2E) failed: %s", >> @@ -371,27 +356,7 @@ labelkre(void) >> mvprintw(NAMEIROW, NAMEICOL, "Namei Name-cache Dir-cache"); >> mvprintw(NAMEIROW + 1, NAMEICOL, >> " Calls hits %% hits %%"); >> - mvprintw(DISKROW, DISKCOL, "Disks"); >> - mvprintw(DISKROW + 1, DISKCOL, "KB/t"); >> - mvprintw(DISKROW + 2, DISKCOL, "tps"); >> - mvprintw(DISKROW + 3, DISKCOL, "MB/s"); >> - mvprintw(DISKROW + 4, DISKCOL, "%%busy"); >> - /* >> - * For now, we don't support a fourth disk statistic=2E So there's >> - * no point in providing a label for it=2E If someone can think of a >> - * fourth useful disk statistic, there is room to add it=2E >> - */ >> - /* mvprintw(DISKROW + 4, DISKCOL, " msps"); */ >> - j =3D 0; >> - for (i =3D 0; i < num_devices && j < MAXDRIVES; i++) >> - if (dev_select[i]=2Eselected) { >> - char tmpstr[80]; >> - sprintf(tmpstr, "%s%d", dev_select[i]=2Edevice_name, >> - dev_select[i]=2Eunit_number); >> - mvprintw(DISKROW, DISKCOL + 5 + 6 * j, >> - " %5=2E5s", tmpstr); >> - j++; >> - } >> + dslabel(MAXDRIVES, DISKCOL, DISKROW); >> =20 >> for (i =3D 0; i < nintr; i++) { >> if (intrloc[i] =3D=3D 0) >> @@ -401,7 +366,7 @@ labelkre(void) >> } >> =20 >> #define X(fld) {t=3Ds=2Efld[i]; s=2Efld[i]-=3Ds1=2Efld[i]; if(state=3D= =3DTIME) >s1=2Efld[i]=3Dt;} >> -#define Q(fld) {t=3Dcur=2Efld[i]; cur=2Efld[i]-=3Dlast=2Efld[i]; >if(state=3D=3DTIME) last=2Efld[i]=3Dt;} >> +#define Q(fld) {t=3Dcur_dev=2Efld[i]; cur_dev=2Efld[i]-=3Dlast_dev=2Ef= ld[i]; >if(state=3D=3DTIME) last_dev=2Efld[i]=3Dt;} >> #define Y(fld) {t =3D s=2Efld; s=2Efld -=3D s1=2Efld; if(state =3D=3D = TIME) s1=2Efld >=3D t;} >> #define Z(fld) {t =3D s=2Enchstats=2Efld; s=2Enchstats=2Efld -=3D >s1=2Enchstats=2Efld; \ >> if(state =3D=3D TIME) s1=2Enchstats=2Efld =3D t;} >> @@ -543,20 +508,17 @@ showkre(void) >> PUTRATE(v_intr, GENSTATROW + 1, GENSTATCOL + 15, 4); >> PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 4); >> PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 4); >> - for (i =3D 0, lc =3D 0; i < num_devices && lc < MAXDRIVES; i++) >> - if (dev_select[i]=2Eselected) { >> - switch(state) { >> - case TIME: >> - dinfo(i, ++lc, &cur, &last); >> - break; >> - case RUN: >> - dinfo(i, ++lc, &cur, &run); >> - break; >> - case BOOT: >> - dinfo(i, ++lc, &cur, NULL); >> - break; >> - } >> - } >> + switch(state) { >> + case TIME: >> + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &last_dev); >> + break; >> + case RUN: >> + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, &run_dev); >> + break; >> + case BOOT: >> + dsshow(MAXDRIVES, DISKCOL, DISKROW, &cur_dev, NULL); >> + break; >> + } >> putint(s=2Enumdirtybuffers, VNSTATROW, VNSTATCOL, 7); >> putint(s=2Edesiredvnodes, VNSTATROW + 1, VNSTATCOL, 7); >> putint(s=2Enumvnodes, VNSTATROW + 2, VNSTATCOL, 7); >> @@ -582,14 +544,14 @@ cmdkre(const char *cmd, const char *args) >> if (prefix(cmd, "run")) { >> retval =3D 1; >> copyinfo(&s2, &s1); >> - switch (devstat_getdevs(NULL, &run)) { >> + switch (devstat_getdevs(NULL, &run_dev)) { >> case -1: >> errx(1, "%s", devstat_errbuf); >> break; >> case 1: >> - num_devices =3D run=2Edinfo->numdevs; >> - generation =3D run=2Edinfo->generation; >> - retval =3D dscmd("refresh", NULL, MAXDRIVES, &cur); >> + num_devices =3D run_dev=2Edinfo->numdevs; >> + generation =3D run_dev=2Edinfo->generation; >> + retval =3D dscmd("refresh", NULL, MAXDRIVES, &cur_dev); >> if (retval =3D=3D 2) >> labelkre(); >> break; >> @@ -612,14 +574,14 @@ cmdkre(const char *cmd, const char *args) >> retval =3D 1; >> if (state =3D=3D RUN) { >> getinfo(&s1); >> - switch (devstat_getdevs(NULL, &run)) { >> + switch (devstat_getdevs(NULL, &run_dev)) { >> case -1: >> errx(1, "%s", devstat_errbuf); >> break; >> case 1: >> - num_devices =3D run=2Edinfo->numdevs; >> - generation =3D run=2Edinfo->generation; >> - retval =3D dscmd("refresh",NULL, MAXDRIVES, &cur); >> + num_devices =3D run_dev=2Edinfo->numdevs; >> + generation =3D run_dev=2Edinfo->generation; >> + retval =3D dscmd("refresh",NULL, MAXDRIVES, &cur_dev); >> if (retval =3D=3D 2) >> labelkre(); >> break; >> @@ -629,7 +591,7 @@ cmdkre(const char *cmd, const char *args) >> } >> return (retval); >> } >> - retval =3D dscmd(cmd, args, MAXDRIVES, &cur); >> + retval =3D dscmd(cmd, args, MAXDRIVES, &cur_dev); >> =20 >> if (retval =3D=3D 2) >> labelkre(); >> @@ -667,7 +629,7 @@ cputime(int indx) >> return (s=2Etime[indx] * 100=2E0 / lt); >> } >> =20 >> -static void >> +void >> putint(int n, int l, int lc, int w) >> { >> =20 >> @@ -713,7 +675,7 @@ do_putuint64(uint64_t n, int l, int lc, int w, >int div >> addstr(b); >> } >> =20 >> -static void >> +void >> putfloat(double f, int l, int lc, int w, int d, int nz) >> { >> int snr; >> @@ -745,7 +707,7 @@ putfloat(double f, int l, int lc, int w, int d, >int nz >> addstr(b); >> } >> =20 >> -static void >> +void >> putlongdouble(long double f, int l, int lc, int w, int d, int nz) >> { >> int snr; >> @@ -785,7 +747,7 @@ getinfo(struct Info *ls) >> int mib[2]; >> =20 >> GETSYSCTL("kern=2Ecp_time", ls->time); >> - GETSYSCTL("kern=2Ecp_time", cur=2Ecp_time); >> + GETSYSCTL("kern=2Ecp_time", cur_dev=2Ecp_time); >> GETSYSCTL("vm=2Estats=2Esys=2Ev_swtch", ls->v_swtch); >> GETSYSCTL("vm=2Estats=2Esys=2Ev_trap", ls->v_trap); >> GETSYSCTL("vm=2Estats=2Esys=2Ev_syscall", ls->v_syscall); >> @@ -838,23 +800,12 @@ getinfo(struct Info *ls) >> size !=3D sizeof(ncpu)) >> ncpu =3D 1; >> =20 >> - tmp_dinfo =3D last=2Edinfo; >> - last=2Edinfo =3D cur=2Edinfo; >> - cur=2Edinfo =3D tmp_dinfo; >> + tmp_dinfo =3D last_dev=2Edinfo; >> + last_dev=2Edinfo =3D cur_dev=2Edinfo; >> + cur_dev=2Edinfo =3D tmp_dinfo; >> =20 >> - last=2Esnap_time =3D cur=2Esnap_time; >> - switch (devstat_getdevs(NULL, &cur)) { >> - case -1: >> - errx(1, "%s", devstat_errbuf); >> - break; >> - case 1: >> - num_devices =3D cur=2Edinfo->numdevs; >> - generation =3D cur=2Edinfo->generation; >> - cmdkre("refresh", NULL); >> - break; >> - default: >> - break; >> - } >> + last_dev=2Esnap_time =3D cur_dev=2Esnap_time; >> + dsgetinfo(&cur_dev); >> } >> =20 >> static void >> @@ -880,39 +831,4 @@ copyinfo(struct Info *from, struct Info *to) >> *to =3D *from; >> =20 >> bcopy(from->intrcnt, to->intrcnt =3D intrcnt, nintr * sizeof (int)); >> -} >> - >> -static void >> -dinfo(int dn, int lc, struct statinfo *now, struct statinfo *then) >> -{ >> - long double transfers_per_second; >> - long double kb_per_transfer, mb_per_second; >> - long double elapsed_time, device_busy; >> - int di; >> - >> - di =3D dev_select[dn]=2Eposition; >> - >> - if (then !=3D NULL) { >> - /* Calculate relative to previous sample */ >> - elapsed_time =3D now->snap_time - then->snap_time; >> - } else { >> - /* Calculate relative to device creation */ >> - elapsed_time =3D now->snap_time - devstat_compute_etime( >> - &now->dinfo->devices[di]=2Ecreation_time, NULL); >> - } >> - >> - if (devstat_compute_statistics(&now->dinfo->devices[di], then ? >> - &then->dinfo->devices[di] : NULL, elapsed_time, >> - DSM_KB_PER_TRANSFER, &kb_per_transfer, >> - DSM_TRANSFERS_PER_SECOND, &transfers_per_second, >> - DSM_MB_PER_SECOND, &mb_per_second, >> - DSM_BUSY_PCT, &device_busy, >> - DSM_NONE) !=3D 0) >> - errx(1, "%s", devstat_errbuf); >> - >> - lc =3D DISKCOL + lc * 6; >> - putlongdouble(kb_per_transfer, DISKROW + 1, lc, 5, 2, 0); >> - putlongdouble(transfers_per_second, DISKROW + 2, lc, 5, 0, 0); >> - putlongdouble(mb_per_second, DISKROW + 3, lc, 5, 2, 0); >> - putlongdouble(device_busy, DISKROW + 4, lc, 5, 0, 0); >> } >>=20 >> Modified: head/usr=2Ebin/systat/zarc=2Ec >> >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/usr=2Ebin/systat/zarc=2Ec Tue Apr 2 13:59:04 2019 (r345803) >> +++ head/usr=2Ebin/systat/zarc=2Ec Tue Apr 2 14:01:03 2019 (r345804) >> @@ -1,6 +1,5 @@ >> /*- >> - * Copyright (c) 2014 >> - * The Regents of the University of California=2E All rights >reserved=2E >> + * Copyright (c) 2014 - 2017 Yoshihiro Ota >> * >> * Redistribution and use in source and binary forms, with or >without >> * modification, are permitted provided that the following >conditions >> @@ -33,11 +32,14 @@ __FBSDID("$FreeBSD$"); >> #include <sys/types=2Eh> >> #include <sys/sysctl=2Eh> >> =20 >> +/* #include <stdlib=2Eh> */ >> #include <inttypes=2Eh> >> #include <string=2Eh> >> +#include <err=2Eh> >> =20 >> #include "systat=2Eh" >> #include "extern=2Eh" >> +#include "devs=2Eh" >> =20 >> struct zfield{ >> uint64_t arcstats; >> @@ -77,21 +79,23 @@ closezarc(WINDOW *w) >> void >> labelzarc(void) >> { >> + int row =3D 1; >> wmove(wnd, 0, 0); wclrtoeol(wnd); >> mvwprintw(wnd, 0, 31+1, "%4=2E4s %7=2E7s %7=2E7s %12=2E12s %12=2E12s"= , >> "rate", "hits", "misses", "total hits", "total misses"); >> -#define L(row, str) mvwprintw(wnd, row, 5, str); \ >> +#define L(str) mvwprintw(wnd, row, 5, #str); \ >> mvwprintw(wnd, row, 31, ":"); \ >> - mvwprintw(wnd, row, 31+4, "%%") >> - L(1, "arcstats"); >> - L(2, "arcstats=2Edemand_data"); >> - L(3, "arcstats=2Edemand_metadata"); >> - L(4, "arcstats=2Eprefetch_data"); >> - L(5, "arcstats=2Eprefetch_metadata"); >> - L(6, "zfetchstats"); >> - L(7, "arcstats=2El2"); >> - L(8, "vdev_cache_stats"); >> + mvwprintw(wnd, row, 31+4, "%%"); ++row >> + L(arcstats); >> + L(arcstats=2Edemand_data); >> + L(arcstats=2Edemand_metadata); >> + L(arcstats=2Eprefetch_data); >> + L(arcstats=2Eprefetch_metadata); >> + L(zfetchstats); >> + L(arcstats=2El2); >> + L(vdev_cache_stats); >> #undef L >> + dslabel(12, 0, 18); >> } >> =20 >> static int calc(uint64_t hits, uint64_t misses) >> @@ -131,6 +135,7 @@ domode(struct zarcstats *delta, struct zarcstats >*rate >> void >> showzarc(void) >> { >> + int row =3D 1; >> struct zarcstats delta, rate; >> =20 >> memset(&delta, 0, sizeof delta); >> @@ -138,34 +143,37 @@ showzarc(void) >> =20 >> domode(&delta, &rate); >> =20 >> -#define DO(stat, row, col, fmt) \ >> +#define DO(stat, col, fmt) \ >> mvwprintw(wnd, row, col, fmt, stat) >> -#define R(row, stat) DO(rate=2Ehits=2Estat, row, 31+1, "%3"PRIu64) >> -#define H(row, stat) DO(delta=2Ehits=2Estat, row, 31+1+5, "%7"PRIu64);= \ >> - DO(curstat=2Ehits=2Estat, row, 31+1+5+8+8, "%12"PRIu64) >> -#define M(row, stat) DO(delta=2Emisses=2Estat, row, 31+1+5+8, >"%7"PRIu64); \ >> - DO(curstat=2Emisses=2Estat, row, 31+1+5+8+8+13, "%12"PRIu64) >> -#define E(row, stat) R(row, stat); H(row, stat); M(row, stat);=20 >> - E(1, arcstats); >> - E(2, arcstats_demand_data); >> - E(3, arcstats_demand_metadata); >> - E(4, arcstats_prefetch_data); >> - E(5, arcstats_prefetch_metadata); >> - E(6, zfetchstats); >> - E(7, arcstats_l2); >> - E(8, vdev_cache_stats); >> +#define R(stat) DO(rate=2Ehits=2Estat, 31+1, "%3"PRIu64) >> +#define H(stat) DO(delta=2Ehits=2Estat, 31+1+5, "%7"PRIu64); \ >> + DO(curstat=2Ehits=2Estat, 31+1+5+8+8, "%12"PRIu64) >> +#define M(stat) DO(delta=2Emisses=2Estat, 31+1+5+8, "%7"PRIu64); \ >> + DO(curstat=2Emisses=2Estat, 31+1+5+8+8+13, "%12"PRIu64) >> +#define E(stat) R(stat); H(stat); M(stat); ++row >> + E(arcstats); >> + E(arcstats_demand_data); >> + E(arcstats_demand_metadata); >> + E(arcstats_prefetch_data); >> + E(arcstats_prefetch_metadata); >> + E(zfetchstats); >> + E(arcstats_l2); >> + E(vdev_cache_stats); >> #undef DO >> #undef E >> #undef M >> #undef H >> #undef R >> + dsshow(12, 0, 18, &cur_dev, &last_dev); >> } >> =20 >> int >> initzarc(void) >> { >> + dsinit(12); >> getinfo(&initstat); >> curstat =3D oldstat =3D initstat; >> + >> return 1; >> } >> =20 >> @@ -178,6 +186,15 @@ resetzarc(void) >> static void >> getinfo(struct zarcstats *ls) >> { >> + struct devinfo *tmp_dinfo; >> + >> + tmp_dinfo =3D last_dev=2Edinfo; >> + last_dev=2Edinfo =3D cur_dev=2Edinfo; >> + cur_dev=2Edinfo =3D tmp_dinfo; >> + >> + last_dev=2Esnap_time =3D cur_dev=2Esnap_time; >> + dsgetinfo( &cur_dev ); >> + >> size_t size =3D sizeof( ls->hits=2Earcstats ); >> if ( sysctlbyname("kstat=2Ezfs=2Emisc=2Earcstats=2Ehits", >> &ls->hits=2Earcstats, &size, NULL, 0 ) !=3D 0 ) >>=20 >>=20 Gru=C3=9F ---=20 Michael
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CE944E7A-6D12-4283-93CC-8B69F4BC2BC5>