Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Nov 2008 16:12:32 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/129052: ps(1) %cpu column reports misleading data for threaded programs
Message-ID:  <200811211612.mALGCWSa027319@ref8-amd64.freebsd.org>
Resent-Message-ID: <200811211620.mALGK1OX080463@freefall.freebsd.org>

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

>Number:         129052
>Category:       bin
>Synopsis:       ps(1) %cpu column reports misleading data for threaded programs
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 21 16:20:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Ed Maste
>Release:        FreeBSD 8.0-CURRENT amd64
>Organization:
FreeBSD
>Environment:
System: FreeBSD ref8-amd64.freebsd.org 8.0-CURRENT FreeBSD 8.0-CURRENT #0 r184542: Sun Nov 2 00:26:55 UTC 2008 peter@ref8-amd64.freebsd.org:/scratch/src/sys/amd64/compile/REF8-AMD64 amd64


>Description:

When running ps without -H (show all threads), only one thread's %CPU
is shown.  This can be very misleading: if a process has one idle
thread and other busy threads and ps(1) can report 0% cpu.

>How-To-Repeat:

Run ps with and without -H, and compare the %CPU data

[emaste@ref8-amd64 ~]$ ps -a -x -p 11 -opid,lwp,comm,tdnam,%cpu
  PID    LWP COMMAND             TDNAM               %CPU
   11 100010 idle                                    100.0

[emaste@ref8-amd64 ~]$ ps -a -x -H -p 11 -opid,lwp,comm,tdnam,%cpu
  PID    LWP COMMAND             TDNAM               %CPU
   11 100003 idle                idle: cpu7          99.9
   11 100004 idle                idle: cpu6          100.0
   11 100005 idle                idle: cpu5          74.9
   11 100006 idle                idle: cpu4          91.7
   11 100007 idle                idle: cpu3          96.1
   11 100008 idle                idle: cpu2          100.0
   11 100009 idle                idle: cpu1          100.0
   11 100010 idle                idle: cpu0          100.0

Note %CPU comes from just the last thread in this case.

Other per-thread data probably has the same problem.

>Fix:

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



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