bin/129052: ps(1) %cpu column reports misleading data for threaded programs

Ed Maste emaste at FreeBSD.org
Fri Nov 21 08:20:02 PST 2008


>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 at 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 at ref8-amd64 ~]$ ps -a -x -p 11 -opid,lwp,comm,tdnam,%cpu
  PID    LWP COMMAND             TDNAM               %CPU
   11 100010 idle                                    100.0

[emaste at 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:


More information about the freebsd-bugs mailing list