From shoesoft@gmx.net  Fri Oct 17 12:24:18 2008
Return-Path: <shoesoft@gmx.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D75311065690
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 17 Oct 2008 12:24:18 +0000 (UTC)
	(envelope-from shoesoft@gmx.net)
Received: from mailbackup.inode.at (mailbackup.inode.at [213.229.60.24])
	by mx1.freebsd.org (Postfix) with ESMTP id 93AE28FC0A
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 17 Oct 2008 12:24:18 +0000 (UTC)
	(envelope-from shoesoft@gmx.net)
Received: from [62.99.145.10] (port=15994 helo=mx.inode.at)
	by mailbackup.inode.at with esmtp (Exim 4.67)
	(envelope-from <shoesoft@gmx.net>)
	id 1Kqm5w-00040M-DD
	for FreeBSD-gnats-submit@freebsd.org; Fri, 17 Oct 2008 11:58:08 +0200
Received: from [85.127.86.101] (port=6856 helo=taxman.pepperland)
	by smartmx-10.inode.at with esmtp (Exim 4.50)
	id 1Kqm5t-00026v-FJ
	for FreeBSD-gnats-submit@freebsd.org; Fri, 17 Oct 2008 11:58:05 +0200
Message-Id: <1224237485.22763@taxman.pepperland>
Date: Fri, 17 Oct 2008 11:58:05 +0200
From: "Stefan Ehmann" <shoesoft@gmx.net>
To: "FreeBSD gnats submit" <FreeBSD-gnats-submit@freebsd.org>
Subject: wrong CPU usage reported by top/ps with SCHED_ULE
X-Send-Pr-Version: gtk-send-pr 0.4.9 
X-GNATS-Notify:

>Number:         128177
>Category:       kern
>Synopsis:       [sched_ule] wrong CPU usage reported by top(1)/ps(1) with SCHED_ULE
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jeff
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 17 12:30:04 UTC 2008
>Closed-Date:    
>Last-Modified:  Tue Jan  3 17:10:11 UTC 2012
>Originator:     Stefan Ehmann
>Release:        FreeBSD 7.1-PRERELEASE i386
>Organization:
>Environment:


System: FreeBSD 7.1-PRERELEASE #64: Fri Oct 17 11:04:45 CEST 2008
    stefan@taxman.pepperland:/usr/obj/usr/src/sys/TAXMAN



>Description:


If a process runs in a busy loop, the CPU usage reported in top/ps is wrong. It starts at ~20% and goes down to 0% within a few seconds. The overall CPU usage is reported correctly.

Here's the top output:

last pid: 22916;  load averages:  0.71,  0.48,  0.39    up 0+00:25:47  11:32:57
87 processes:  4 running, 83 sleeping
CPU: 96.3% user,  0.0% nice,  3.4% system,  0.4% interrupt,  0.0% idle
Mem: 261M Active, 110M Inact, 134M Wired, 1656K Cache, 110M Buf, 482M Free
Swap: 1280M Total, 1280M Free
   
  PID USERNAME    THR PRI NICE   SIZE    RES STATE    TIME   WCPU COMMAND
22916 stefan        1  98    0  3500K  1684K RUN      0:02 11.18% sh <-- this should be ~100%
22719 stefan        1  44    0   103M 57444K RUN      1:10  0.00% Xorg

Only happens with SCHED_ULE. With SCHED_4BSD the reported values look sane. I didn't see this on 8-CURRENT on the same machine when I've tested it about 2 weeks ago.


>How-To-Repeat:


Run a program that uses all available CPU cycles, e.g.
$ while true; do true; done

Look at CPU usage reported by top or ps.


>Fix:





>Release-Note:
>Audit-Trail:

From: Stefan Ehmann <shoesoft@gmx.net>
To: bug-followup@freebsd.org,
 shoesoft@gmx.net
Cc:  
Subject: Re: kern/128177: [sched_ule] wrong CPU usage reported by top/ps with SCHED_ULE
Date: Sun, 26 Oct 2008 07:57:07 +0100

 --Boundary-00=_ETBBJXhBbfyiisx
 Content-Type: text/plain;
   charset="us-ascii"
 Content-Transfer-Encoding: 7bit
 
 If I assign idle priority which idprio(1) CPU usage is displayed correctly 
 with SCHED_ULE.
 
 I got the idea to use idprio from threads/122923 as I also see the problem 
 reported there. Maybe the PRs are related.
 
 --Boundary-00=_ETBBJXhBbfyiisx--

From: Stefan Ehmann <shoesoft@gmx.net>
To: bug-followup@freebsd.org,
 shoesoft@gmx.net
Cc:  
Subject: Re: kern/128177: [sched_ule] wrong CPU usage reported by top/ps with SCHED_ULE
Date: Sun, 2 Nov 2008 10:53:26 +0100

 Some more investigation revealed this:
 
 If I revert 1.214.2.7 of sched_ule.c the problem disappears.
 
 The problem only occurs if dummynet(4) is loaded.
Responsible-Changed-From-To: freebsd-bugs->jeff 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Mon Feb 9 23:48:25 UTC 2009 
Responsible-Changed-Why:  
Assign to Jeff Roberson, ULE author. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128177 

From: John Baldwin <jhb@FreeBSD.org>
To: bug-followup@FreeBSD.org, shoesoft@gmx.net
Cc:  
Subject: Re: kern/128177: [sched_ule] wrong CPU usage reported by top(1)/ps(1)
 with SCHED_ULE
Date: Tue, 03 Jan 2012 12:07:45 -0500

 The commit referenced is the MFC to 7.1 of the SVN change 180607.
 
 -- 
 John Baldwin
>Unformatted:
