Bug 350429 - Displayed CPU "user" load drops to zero after long uptimes (~700 days) on 32 bit systems
Summary: Displayed CPU "user" load drops to zero after long uptimes (~700 days) on 32 ...
Status: RESOLVED WORKSFORME
Alias: None
Product: ksysguard
Classification: Unmaintained
Component: ksysguardd (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KSysGuard Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-20 21:44 UTC by Harald Brinkmann
Modified: 2022-11-15 05:16 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Brinkmann 2015-07-20 21:44:42 UTC
After those 700 days on the system monitors CPU "user" load is always zero. The CPU is mostly shown busy (near 100%) in "system". Before that everything worked fine. I am on openSUSE 12.1 32 bit. My ksysguardd version is 4.7 as supplied by the openSUSE repositories. As far as I can tell all newer version still have this bug

Reproducible: Always

Steps to Reproduce:
1. Boot your system (32 bits)
2. Wait ~700 days ;-)
3. Launch any KDE utility showing CPU load

Actual Results:  
CPU "user" load is zero, CPU "system" load very high

Expected Results:  
Show plausible amount of CPU "user" and "system" loads

This is the head of my current /proc/stat:
cpu  4425217554 1286866 581986284 1173412658 3046616 22233 6309211 0 0 0
cpu0 4425217554 1286866 581986284 1173412658 3046616 22233 6309211 0 0 0

Note that the first number is more than 2^32!

These are the changes I made to ksysguardd/Linux/stat.c that seem to fix this:
***************
*** 20,25 ****
--- 20,27 ----
   * stat.c is used to read from /proc/[pid]/stat
  */

+ #include <inttypes.h>
+
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <sys/time.h>
***************
*** 29,34 ****
--- 31,37 ----
  #include <stdlib.h>
  #include <string.h>
  #include <ctype.h>
+ #include <stdint.h>

  #include "Command.h"
  #include "ksysguardd.h"
***************
*** 47,57 ****

        /* To calculate the loads we need to remember the tick values for each
        * load type. */
!       unsigned long userTicks;
!       unsigned long niceTicks;
!       unsigned long sysTicks;
!       unsigned long idleTicks;
!       unsigned long waitTicks;
  } CPULoadInfo;

  typedef struct {
--- 50,65 ----

        /* To calculate the loads we need to remember the tick values for each
        * load type. */
!   //  unsigned long userTicks;
!   //  unsigned long niceTicks;
!   //  unsigned long sysTicks;
!   //  unsigned long idleTicks;
!   //  unsigned long waitTicks;
!         uint64_t userTicks;
!       uint64_t niceTicks;
!       uint64_t sysTicks;
!       uint64_t idleTicks;
!       uint64_t waitTicks;
  } CPULoadInfo;

  typedef struct {
***************
*** 146,159 ****
   * Parses the total cpu status line from /proc/stat
   */
  static void updateCPULoad( const char* line, CPULoadInfo* load ) {
!       unsigned long currUserTicks, currSysTicks, currNiceTicks;
!       unsigned long currIdleTicks, currWaitTicks, totalTicks;

!       if(sscanf( line, "%*s %lu %lu %lu %lu %lu", &currUserTicks, &currNiceTicks,
                &currSysTicks, &currIdleTicks, &currWaitTicks ) != 5) {
          return;
      }
!
        totalTicks = ( currUserTicks - load->userTicks ) +
                ( currSysTicks - load->sysTicks ) +
                ( currNiceTicks - load->niceTicks ) +
--- 154,167 ----
   * Parses the total cpu status line from /proc/stat
   */
  static void updateCPULoad( const char* line, CPULoadInfo* load ) {
!       uint64_t currUserTicks, currSysTicks, currNiceTicks;
!       uint64_t currIdleTicks, currWaitTicks, totalTicks;

!         if(sscanf( line, "%*s %" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64, &currUserTicks, &currNiceTicks,
                &currSysTicks, &currIdleTicks, &currWaitTicks ) != 5) {
          return;
      }
!
        totalTicks = ( currUserTicks - load->userTicks ) +
                ( currSysTicks - load->sysTicks ) +
                ( currNiceTicks - load->niceTicks ) +
***************
Comment 1 Justin Zobel 2022-10-16 07:52:12 UTC
Thank you for reporting this bug in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version?

If you can reproduce the issue, please change the status to "CONFIRMED" when replying. Thank you!
Comment 2 Bug Janitor Service 2022-10-31 05:04:01 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Bug Janitor Service 2022-11-15 05:16:01 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!