From avleen@mail.silverwraith.com  Fri May  3 02:33:00 2002
Return-Path: <avleen@mail.silverwraith.com>
Received: from mail.silverwraith.com (apple.silverwraith.com [212.25.240.44])
	by hub.freebsd.org (Postfix) with SMTP id 850F037B417
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  3 May 2002 02:32:59 -0700 (PDT)
Received: (qmail 53893 invoked by uid 1000); 3 May 2002 09:33:13 -0000
Message-Id: <20020503093313.53892.qmail@mail.silverwraith.com>
Date: 3 May 2002 09:33:13 -0000
From: Avleen Vig <lists-sendpr@silverwraith.com>
Reply-To: Avleen Vig <lists-sendpr@silverwraith.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Avleen Vig <lists-sendpr@silverwraith.com>
Subject: /usr/bin/top uses 100% cpu in 'system'
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         37702
>Category:       bin
>Synopsis:       /usr/bin/top uses 100% cpu in 'system'
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    dwmalone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 03 02:40:01 PDT 2002
>Closed-Date:    Sun Aug 11 11:07:04 PDT 2002
>Last-Modified:  Sun Aug 11 11:07:04 PDT 2002
>Originator:     Avleen Vig
>Release:        FreeBSD 4.4-RELEASE i386
>Organization:
Personal
>Environment:
System: FreeBSD apple.silverwraith.com 4.4-RELEASE
FreeBSD 4.4-RELEASE #0: Wed May 1 13:15:54 BST 2002
root@apple.silverwraith.com:/usr/src/sys/compile/APPLE.DEGUB i386

P166 MMX (intel), 128Mb RAM
Low load: 'load averages: 0.01, 0.13, 0.14'


	
>Description:
Running 'top -s' gives the following error:
top: option requires an argument -- s
Top version 3.4

But running 'top -s -o size' starts top and causes it to update
as fast as it can. This increases load (rate if increase depends
on box specs and other running procs), while top takes up as much
CPU time as it can.

After 5 mins on a very load load box:
load averages:  1.53,  0.85,  0.45

On a box where the initial load is:
load averages:  3.16,  1.95,  1.00
After 5 minute of broken top, we get:
load averages:  5.24,  3.91,  1.98

http_load also shows that requests don't always seem to complete
(ok, it's not the best test)
--- 60.0106 secs, 249 fetches started, 199 completed, 50 current

>How-To-Repeat:
Run: 'top -s -o size'. I don't recommend doing this on a heavily
loaded box straight away. Try it on your desktop. You can still
quit top easily with the 'q' key.

>Fix:
Unknown
>Release-Note:
>Audit-Trail:

From: Edwin Groothuis <edwin@mavetju.org>
To: Avleen Vig <lists-sendpr@silverwraith.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/37702: /usr/bin/top uses 100% cpu in 'system'
Date: Fri, 3 May 2002 22:47:44 +1000

 On Fri, May 03, 2002 at 09:33:13AM -0000, Avleen Vig wrote:
 > >How-To-Repeat:
 > Run: 'top -s -o size'. I don't recommend doing this on a heavily
 > loaded box straight away. Try it on your desktop. You can still
 > quit top easily with the 'q' key.
 > 
 > >Fix:
 > Unknown
 
 Problem is that the handling of arguments is a little bit broken.
 For 4.5, the patch would be:
 
 --- /usr/src/contrib/top/top.c.old   Fri May  3 22:38:48 2002
 +++ /usr/src/contrib/top/top.c       Fri May  3 22:39:14 2002
 @@ -317,10 +317,10 @@
                 break;
  
               case 's':
 -               if ((delay = atoi(optarg)) < 0)
 +               if ((delay = atoi(optarg)) <= 0)
                 {
                     fprintf(stderr,
 -                       "%s: warning: seconds delay should be non-negative -- using default\n",
 +                       "%s: warning: seconds delay should be postive -- using default\n",
                         myname);
                     delay = Default_DELAY;
                     warnings++;
 
 With this information a similair patch for -current would be easy to make.
 
 The handling of the fact that the integer value of "size" is
 translated into 0 and is displaying zero lines of process-output
 is not tackled by this, since people might want to display zero
 processes and have only the summary.
 
 Edwin
 
 -- 
 Edwin Groothuis      |           Personal website: http://www.MavEtJu.org
 edwin@mavetju.org    |        Interested in MUDs? Visit Fatal Dimensions:
 bash$ :(){ :|:&};:   |                    http://www.FatalDimensions.org/

From: Bruce Evans <bde@zeta.org.au>
To: David Malone <dwmalone@maths.tcd.ie>
Cc: Edwin Groothuis <edwin@mavetju.org>,
	<freebsd-gnats-submit@FreeBSD.ORG>
Subject: Re: bin/37702: /usr/bin/top uses 100% cpu in 'system'
Date: Sun, 5 May 2002 10:39:24 +1000 (EST)

 On Sat, 4 May 2002, David Malone wrote:
 
 > On Fri, May 03, 2002 at 05:50:07AM -0700, Edwin Groothuis wrote:
 > >                case 's':
 > >  -               if ((delay = atoi(optarg)) < 0)
 > >  +               if ((delay = atoi(optarg)) <= 0)
 > >                  {
 >
 > I think this has been fixed in -current in another way:
 >
 > 	if ((delay = atoi(optarg)) < 0 || (delay == 0 && getuid() != 0))
 >
 > this means you're only alowd to get continious updates if you're
 > root. (This change came from the last beta version of top which
 > was released by the original authors.)
 
 -current still has the bad options parsing, and a delay of 0 causes
 strange synchronization at least on syscons consoles: the
 user/nice/system/interrupt/idle percentages are usually all displayed
 as "0.0".
 
 Bruce
 
Responsible-Changed-From-To: freebsd-bugs->dwmalone 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Mon May 6 01:48:17 PDT 2002 
Responsible-Changed-Why:  
Top PR for me. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37702 
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Sun Aug 11 11:04:26 PDT 2002 
State-Changed-Why:  
This problem is fixed for regular users with the version of top I 
just MFCed. It still allows root to run "top -s 0", which produces 
weird output, but that might be useful for some. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37702 
>Unformatted:
