Bug 220690

Summary: sysctl(8) value kern.cp_times (current CPU utilization) is inconsistent with top(1)
Product: Base System Reporter: Yuri Victorovich <yuri>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me CC: eadler
Priority: ---    
Version: 11.0-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
cpu-consumption-kern.cp_times.sh
none
cpu-consumption-kern.cp_times.sh none

Description Yuri Victorovich freebsd_committer 2017-07-12 19:38:54 UTC
Created attachment 184310 [details]
cpu-consumption-kern.cp_times.sh

I have a process that uses 100% CPU, pinned to one CPU, according to top(1).
kern.cp_times, however, shows that CPU use frequently changes from one CPU to another. No specific CPU appears to be in use consistently, according to kern.cp_times.

Please see the attached program.

This program follows the algorithm used by xfce4 CPU use plugin sysutils/xfce4-cpugraph-plugin, which also shows incorrect CPU use as a result.

kern.cp_times CPU use data appears to not match top(1), which seems to be correct.
Comment 1 Yuri Victorovich freebsd_committer 2017-07-12 19:41:32 UTC
FreeBSD 11.1-PRERELEASE #1 r320820

The attached program is for the case of 8 CPUs.
Comment 2 Yuri Victorovich freebsd_committer 2017-07-12 19:45:23 UTC
Created attachment 184311 [details]
cpu-consumption-kern.cp_times.sh
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2017-07-12 20:22:21 UTC
Shouldn't this instead be reclassified as "base system" ?
Comment 4 Yuri Victorovich freebsd_committer 2017-07-12 20:33:36 UTC
(In reply to Mark Linimon from comment #3)

Yes, sorry.