Bug 280600 - sysutils/htop CPU usage meters reporting wildly inaccurate CPU usage
Summary: sysutils/htop CPU usage meters reporting wildly inaccurate CPU usage
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Fernando Apesteguía
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-03 20:21 UTC by lily
Modified: 2024-08-28 06:40 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (gaod)


Attachments
screenshot of htop that shows the 8 CPU usage meters all at about 1 to 0 percent while stress is running a stress test on each of the 8 CPU cores and has them all at about 100 percent CPU usage (112.39 KB, image/png)
2024-08-03 20:21 UTC, lily
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description lily 2024-08-03 20:21:01 UTC
Created attachment 252486 [details]
screenshot of htop that shows the 8 CPU usage meters all at about 1 to 0 percent while stress is running a stress test on each of the 8 CPU cores and has them all at about 100 percent CPU usage

The CPU usage meters in htop are showing very low CPU usage no matter what I am doing and regardless of the actual reported CPU usage by processes or by other utilities such as top.
Comment 1 bsd 2024-08-07 20:54:49 UTC
It seems that error is introduced with commit c803ec6dae5556fa35d6bd8124aa536633887f77

Small diff will fix it:
--- a/freebsd/Platform.c
+++ b/freebsd/Platform.c
@@ -210,7 +210,7 @@ double Platform_setCPUValues(Meter* this, unsigned int cpu) {
       this->curItems = 4;
       percent = v[CPU_METER_NICE] + v[CPU_METER_NORMAL] + v[CPU_METER_KERNEL] + v[CPU_METER_IRQ];
    } else {
-      v[CPU_METER_NORMAL] = cpuData->systemAllPercent;
+      v[CPU_METER_KERNEL] = cpuData->systemAllPercent;
       this->curItems = 3;
       percent = v[CPU_METER_NICE] + v[CPU_METER_NORMAL] + v[CPU_METER_KERNEL];
    }

I'll report it to the upstream.
Comment 2 Fernando Apesteguía freebsd_committer freebsd_triage 2024-08-28 06:40:22 UTC
Fixed, thanks!
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-08-28 06:40:50 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ef1b781fb1d88ba11cadc4f35bb398bea2378aef

commit ef1b781fb1d88ba11cadc4f35bb398bea2378aef
Author:     Fernando Apesteguía <fernape@FreeBSD.org>
AuthorDate: 2024-08-23 10:57:48 +0000
Commit:     Fernando Apesteguía <fernape@FreeBSD.org>
CommitDate: 2024-08-28 06:35:26 +0000

    sysutils/htop: Fix CPU usage in FreeBSD

    Cherry pick fix from upstream.

    PR:                     280600 281014
    Approved by:            gaod@hychen.org (maintainer, timeout > 2 weeks)
    Differential Revision:  https://reviews.freebsd.org/D46401

 sysutils/htop/Makefile | 5 ++++-
 sysutils/htop/distinfo | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)