Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Mar 2009 21:43:25 GMT
From:      Alexander Zagrebin <alexz@visp.ru>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/133168: top without -H switch reports incorrect time for multithreaded processes
Message-ID:  <200903282143.n2SLhP4V035203@www.freebsd.org>
Resent-Message-ID: <200903282150.n2SLo1D8050901@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         133168
>Category:       bin
>Synopsis:       top without -H switch reports incorrect time for multithreaded processes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 28 21:50:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Alexander Zagrebin
>Release:        7.1-RELEASE
>Organization:
>Environment:
FreeBSD gw.xxxxxxxx.xx 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Mon Jan  5 16:27:35 MSK 2009     root@gw.xxxxxxxx.xx:/usr/obj/usr/src/sys/KERNEL  i386
>Description:
When top displays "threads as a count" (without -H switch),
it reports incorrect time for multithreaded processes.
For example:

$ top -H -d1 100 | grep named
  844 bind             44    0 26476K  8168K ucond    2:28  0.00% named
  844 bind             44    0 26476K  8168K select   0:17  0.00% named
  844 bind             44    0 26476K  8168K ucond    0:09  0.00% named
  844 bind             20    0 26476K  8168K sigwai   0:00  0.00% named

So without -H switch top have to report about 2:54 of a time, but...

$ top -d1 100 | grep named
  844 bind               4  44    0 26476K  8168K select   0:17  0.00% named

It seems that in this case top displays time of the first thread only.

>How-To-Repeat:
See full description
>Fix:
After this patch I have the correct result:

--- src/usr.bin/top/machine.c.orig      2009-03-05 20:35:56.000000000 +0300
+++ src/usr.bin/top/machine.c           2009-03-29 00:14:53.000000000 +0300
@@ -724,6 +724,7 @@
                        active_procs++;
                        prev_pp = pp;
                } else {
+                       prev_pp->ki_runtime += pp->ki_runtime;
                        prev_pp->ki_pctcpu += pp->ki_pctcpu;
                }
        }

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903282143.n2SLhP4V035203>