From c7efee884c05e15272c38f0531ae276ad06aa31e323f0116d3aa8d254e02b356 Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Tue, 21 Nov 2017 15:31:43 +0000 Subject: [PATCH] Accepting request 543981 from home:mgorse:branches:GNOME:Factory - Add gsm-fix-inaccurate-cpu-values.patch: fix inaccurate %CPU values in the Processes table (bgo#788922). OBS-URL: https://build.opensuse.org/request/show/543981 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gnome-system-monitor?expand=0&rev=167 --- gnome-system-monitor.changes | 6 ++++ gnome-system-monitor.spec | 3 ++ gsm-fix-inaccurate-cpu-values.patch | 43 +++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 gsm-fix-inaccurate-cpu-values.patch diff --git a/gnome-system-monitor.changes b/gnome-system-monitor.changes index 82e5a2f..8399481 100644 --- a/gnome-system-monitor.changes +++ b/gnome-system-monitor.changes @@ -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 diff --git a/gnome-system-monitor.spec b/gnome-system-monitor.spec index e739949..52482de 100644 --- a/gnome-system-monitor.spec +++ b/gnome-system-monitor.spec @@ -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 diff --git a/gsm-fix-inaccurate-cpu-values.patch b/gsm-fix-inaccurate-cpu-values.patch new file mode 100644 index 0000000..85b0852 --- /dev/null +++ b/gsm-fix-inaccurate-cpu-values.patch @@ -0,0 +1,43 @@ +From 9224515cd6b19ba2dc59afe14684749b4dbf0349 Mon Sep 17 00:00:00 2001 +From: Daniel van Vugt +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 +--- + 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 +