Accepting request 544197 from GNOME:Factory

- Add gsm-fix-inaccurate-cpu-values.patch: fix inaccurate %CPU
  values in the Processes table (bgo#788922). (forwarded request 543981 from mgorse)

OBS-URL: https://build.opensuse.org/request/show/544197
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/gnome-system-monitor?expand=0&rev=98
This commit is contained in:
Dominique Leuenberger 2017-11-30 15:30:27 +00:00 committed by Git OBS Bridge
commit 2b830680a2
3 changed files with 52 additions and 0 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Nov 20 20:07:43 UTC 2017 - mgorse@suse.com
- Add gsm-fix-inaccurate-cpu-values.patch: fix inaccurate %CPU
values in the Processes table (bgo#788922).
-------------------------------------------------------------------
Tue Oct 3 01:14:02 UTC 2017 - jengelh@inai.de

View File

@ -26,6 +26,8 @@ Url: http://www.gnome.org
Source0: http://download.gnome.org/sources/gnome-system-monitor/3.26/%{name}-%{version}.tar.xz
# PATCH-FEATURE-UPSTREAM gsm-bsc1020294-add-resources-scrollbar.patch bsc#1020294 bgo#778697 mgorse@suse.com -- add a scrollbar to the resources tab.
Patch0: gsm-bsc1020294-add-resources-scrollbar.patch
# PATCH-FIX-UPSTREAM gsm-fix-inaccurate-cpu-values.patch bgo#788922 mgorse@suse.com -- fix inaccurate %CPU values in the Process table.
Patch1: gsm-fix-inaccurate-cpu-values.patch
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: intltool
@ -61,6 +63,7 @@ processor time, memory, and disk space are being used.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%if !0%{?is_opensuse}
translation-update-upstream
%endif

View File

@ -0,0 +1,43 @@
From 9224515cd6b19ba2dc59afe14684749b4dbf0349 Mon Sep 17 00:00:00 2001
From: Daniel van Vugt <daniel.van.vugt@canonical.com>
Date: Fri, 27 Oct 2017 19:11:33 +0800
Subject: [PATCH] Fix inaccurate %CPU values in the Processes table
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Multi-core machines were displaying inaccurate %CPU values due to a
loss of precision from performing integer division before multiplication.
This changes the order of operations so that no precision is lost, and
now all machines will display process %CPU values to within 1% accuracy.
https://bugzilla.gnome.org/show_bug.cgi?id=788922
Signed-off-by: Benoît Dejean <bdejean@gmail.com>
---
src/proctable.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/proctable.cpp b/src/proctable.cpp
index e41d6d08..c37a48b2 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -917,11 +917,13 @@ update_info (GsmApplication *app, ProcInfo *info)
guint64 difference = proctime.rtime - info->cpu_time;
if (difference > 0)
info->status = GLIBTOP_PROCESS_RUNNING;
- info->pcpu = difference * 100 / app->cpu_total_time;
- info->pcpu = MIN(info->pcpu, 100);
+ guint cpu_scale = 100;
if (not app->config.solaris_mode)
- info->pcpu *= app->config.num_cpus;
+ cpu_scale *= app->config.num_cpus;
+
+ info->pcpu = difference * cpu_scale / app->cpu_total_time;
+ info->pcpu = MIN(info->pcpu, cpu_scale);
app->processes.cpu_times[info->pid] = info->cpu_time = proctime.rtime;
info->nice = procuid.nice;
--
2.15.0