Bug 128177 - [sched_ule] wrong CPU usage reported by top(1)/ps(1) with SCHED_ULE
Summary: [sched_ule] wrong CPU usage reported by top(1)/ps(1) with SCHED_ULE
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 7.1-PRERELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-17 13:30 UTC by Stefan Ehmann
Modified: 2018-11-26 19:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Ehmann 2008-10-17 13:30:04 UTC

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.
Comment 1 Stefan Ehmann 2008-10-26 06:57:07 UTC
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.
Comment 2 Stefan Ehmann 2008-11-02 09:53:26 UTC
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.
Comment 3 Robert Watson freebsd_committer freebsd_triage 2009-02-09 23:48:25 UTC
Responsible Changed
From-To: freebsd-bugs->jeff

Assign to Jeff Roberson, ULE author.
Comment 4 John Baldwin freebsd_committer freebsd_triage 2012-01-03 17:07:45 UTC
The commit referenced is the MFC to 7.1 of the SVN change 180607.

-- 
John Baldwin
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:00 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 6 Stefan Ehmann 2018-11-26 19:14:42 UTC
Just found this very old PR reported by me.

The issue is no longer reproducible on my current machine using supported versions of FreeBSD. So I'm closing this bug.