From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 19 17:22:44 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A42258B6; Fri, 19 Dec 2014 17:22:44 +0000 (UTC) Received: from mail-wi0-x22a.google.com (mail-wi0-x22a.google.com [IPv6:2a00:1450:400c:c05::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3F7B4222A; Fri, 19 Dec 2014 17:22:44 +0000 (UTC) Received: by mail-wi0-f170.google.com with SMTP id bs8so5371310wib.3; Fri, 19 Dec 2014 09:22:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=GY7qMuy4j8NSO+ywNbnfC5UKMTPJ32Zntx2qf1EQQbE=; b=reEe3Glw137nKoyqiZf27Uf/Ag1DVN1LoK+Tw10TV4wv4kfIvpIR+e7IQnm52lTZIN cS8wdFpAAFHt9scwU7uI+e3DEJfGmB9knTg5C3gL8lDiZVcLMeSeGoAhcjGX7BPR1Coh BwkUHzJ3WMgmIOLJBWMQXcWwl0SVH/D7Gvkr10NlN3jRse4atrPVzAXeJUD6VIKKHDId oWw61nlgAtUhXR07wIef88C6mvfbF6SoZsRgKU5ODgCbpVTptXllBh4yukG16XtwMtqc WmT5df3aLs8h4zXN1wbfCvyAX9mO1G/W5pkBu+QRTXA6rnrG9rWay7upkBW2l6nhg1GF lQ8Q== MIME-Version: 1.0 X-Received: by 10.181.13.106 with SMTP id ex10mr7788002wid.36.1419009762340; Fri, 19 Dec 2014 09:22:42 -0800 (PST) Received: by 10.180.198.52 with HTTP; Fri, 19 Dec 2014 09:22:42 -0800 (PST) In-Reply-To: <201412181449.16974.jhb@freebsd.org> References: <201412161203.44257.jhb@freebsd.org> <201412181449.16974.jhb@freebsd.org> Date: Fri, 19 Dec 2014 18:22:42 +0100 Message-ID: Subject: Re: top -d1 behavior From: =?UTF-8?Q?Fernando_Apestegu=C3=ADa?= To: John Baldwin Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: Fri, 19 Dec 2014 17:22:44 -0000 On Thu, Dec 18, 2014 at 8:49 PM, John Baldwin wrote: > 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 state= s >> > 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 fr= om >> > top -d1? >> >> Yes it does. >> >> 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. >> >> 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 b= ut > just hadn't replied until I sent the previous message. Here's a real ver= sion > of the patch if you would like to test it. I don't know what I was doing wrong, but I couldn't apply your patch cleanly, sorry (patch -p0 < /path/to/patch). Anyway, I translated the changes to the code and it worked for me. Sample output: last pid: 8084; load averages: 0.36, 0.26, 0.23 up 1+00:47:24 16:38:10 47 processes: 1 running, 46 sleeping CPU: 32.0% user, 0.0% nice, 8.1% system, 0.1% interrupt, 59.8% idle Mem: 361M Active, 1024M Inact, 630M Wired, 528K Cache, 361M Buf, 1931M Free Swap: 128M Total, 40M Used, 88M Free, 31% Inuse ... [snip] If you are to commit this, could you please close PR 195717? > > 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 > --- contrib/top/display.c (revision 275828) > +++ contrib/top/display.c (working copy) > @@ -557,46 +557,6 @@ > } > } > > -z_cpustates() > - > -{ > - register int i =3D 0; > - register char **names; > - register char *thisname; > - register int *lp; > - int cpu, value; > - > -for (cpu =3D 0; cpu < num_cpus; cpu++) { > - names =3D cpustate_names; > - > - /* show tag and bump lastline */ > - if (num_cpus =3D=3D 1) > - printf("\nCPU: "); > - else { > - value =3D printf("\nCPU %d: ", cpu); > - while (value++ <=3D cpustates_column) > - printf(" "); > - } > - lastline++; > - > - while ((thisname =3D *names++) !=3D NULL) > - { > - if (*thisname !=3D '\0') > - { > - printf("%s %% %s", (i++ % num_cpustates) =3D=3D 0 ? "" : "= , ", thisname); > - } > - } > -} > - > - /* fill the "last" array with all -1s, to insure correct updating */ > - lp =3D lcpustates; > - i =3D num_cpustates * num_cpus; > - while (--i >=3D 0) > - { > - *lp++ =3D -1; > - } > -} > - > /* > * *_memory(stats) - print "Memory: " followed by the memory summary st= ring > * > 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 > --- 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; > - char dostates =3D No; > char do_unames =3D Yes; > char interactive =3D Maybe; > char warnings =3D 0; > @@ -643,23 +642,7 @@ > system_info.procstates); > > /* display the cpu state percentage breakdown */ > - if (dostates) /* but not the first time */ > - { > - (*d_cpustates)(system_info.cpustates); > - } > - else > - { > - /* we'll do it next time */ > - if (smart_terminal) > - { > - z_cpustates(); > - } > - else > - { > - putchar('\n'); > - } > - dostates =3D Yes; > - } > + (*d_cpustates)(system_info.cpustates); > > /* display memory stats */ > (*d_memory)(system_info.memory); > > -- > John Baldwin