From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 18 19:49:34 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AADD15E7; Thu, 18 Dec 2014 19:49:34 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8268A16AD; Thu, 18 Dec 2014 19:49:34 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 73715B97A; Thu, 18 Dec 2014 14:49:33 -0500 (EST) From: John Baldwin To: Fernando =?utf-8?q?Apestegu=C3=ADa?= Subject: Re: top -d1 behavior Date: Thu, 18 Dec 2014 14:49:16 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; KDE/4.5.5; amd64; ; ) References: <201412161203.44257.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201412181449.16974.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 18 Dec 2014 14:49:33 -0500 (EST) Cc: FreeBSD Hackers , Allan Jude X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Dec 2014 19:49:34 -0000 On Wednesday, December 17, 2014 5:27:40 pm Fernando Apestegu=C3=ADa wrote: > On Tue, Dec 16, 2014 at 6:03 PM, John Baldwin wrote: > > On Sunday, November 23, 2014 4:57:33 pm Fernando Apestegu=C3=ADa wrote: > >> > Neither seem like what the user would expect. > >> > >> Agreed. But this is mostly unexpected (and can lead scripts to fail): > > > > Actually, I think having it output the states since boot would be more > > consistent with other tools like iostat/vmstat/etc. They report states > > on the first iteration that are states since boot. For example: > > > > % iostat 1 > > tty ada0 ada1 cd0 = cpu > > tin tout KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us ni sy = in id > > 8 225 20.41 12 0.24 20.56 12 0.24 2.79 0 0.00 3 0 2 = 0 95 > > 0 6230 60.00 6 0.35 64.80 10 0.62 0.00 0 0.00 9 0 91 = 0 0 > > 0 6195 64.00 5 0.31 51.43 7 0.35 0.00 0 0.00 11 0 89 = 0 1 > > > > Can you test this test patch to see if it gives you what you expect from > > top -d1? >=20 > Yes it does. >=20 > I thought however that the discussion was over :) so I filed a PR[1] > to at least warn in the man page about the special behavior for this > case. >=20 > I would rather fix top and leave the man page as it is. I think fixing top makes the most sense. I saw this thread a while ago but just hadn't replied until I sent the previous message. Here's a real versi= on of the patch if you would like to test it. Index: contrib/top/display.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- contrib/top/display.c (revision 275828) +++ contrib/top/display.c (working copy) @@ -557,46 +557,6 @@ } } =20 =2Dz_cpustates() =2D =2D{ =2D register int i =3D 0; =2D register char **names; =2D register char *thisname; =2D register int *lp; =2D int cpu, value; =2D =2Dfor (cpu =3D 0; cpu < num_cpus; cpu++) { =2D names =3D cpustate_names; =2D =2D /* show tag and bump lastline */ =2D if (num_cpus =3D=3D 1) =2D printf("\nCPU: "); =2D else { =2D value =3D printf("\nCPU %d: ", cpu); =2D while (value++ <=3D cpustates_column) =2D printf(" "); =2D } =2D lastline++; =2D =2D while ((thisname =3D *names++) !=3D NULL) =2D { =2D if (*thisname !=3D '\0') =2D { =2D printf("%s %% %s", (i++ % num_cpustates) =3D=3D 0 ? "" : ", ", t= hisname); =2D } =2D } =2D} =2D =2D /* fill the "last" array with all -1s, to insure correct updating */ =2D lp =3D lcpustates; =2D i =3D num_cpustates * num_cpus; =2D while (--i >=3D 0) =2D { =2D *lp++ =3D -1; =2D } =2D} =2D /* * *_memory(stats) - print "Memory: " followed by the memory summary stri= ng * Index: contrib/top/top.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- contrib/top/top.c (revision 275828) +++ contrib/top/top.c (working copy) @@ -176,7 +176,6 @@ int preset_argc =3D 0; char **av; int ac; =2D char dostates =3D No; char do_unames =3D Yes; char interactive =3D Maybe; char warnings =3D 0; @@ -643,23 +642,7 @@ system_info.procstates); =20 /* display the cpu state percentage breakdown */ =2D if (dostates) /* but not the first time */ =2D { =2D (*d_cpustates)(system_info.cpustates); =2D } =2D else =2D { =2D /* we'll do it next time */ =2D if (smart_terminal) =2D { =2D z_cpustates(); =2D } =2D else =2D { =2D putchar('\n'); =2D } =2D dostates =3D Yes; =2D } + (*d_cpustates)(system_info.cpustates); =20 /* display memory stats */ (*d_memory)(system_info.memory); =2D-=20 John Baldwin