Blame SOURCES/gnome-system-monitor-3.14.1-improve-ncpu-detection.patch

b5ee9b
From 624ec06b5cd58982a5e107b08356c001d84fb981 Mon Sep 17 00:00:00 2001
b5ee9b
From: Helio Chissini de Castro <helio@kde.org>
b5ee9b
Date: Mon, 17 Aug 2015 14:53:21 -0300
b5ee9b
Subject: [PATCH] Unreliable cpu detection through glibtop
b5ee9b
b5ee9b
glibtop not provides the number of cpus on the machine directly, relying
b5ee9b
on a list with the current load of each core.
b5ee9b
Original code assume that a 0 load core is the end of cpu list, which is
b5ee9b
invalid in cases of machines with high number of cores, that happens to
b5ee9b
some cores stay idle with 0 load.
b5ee9b
Since this can happens in any core number, if a machine has 192 cores,
b5ee9b
but the core number 5 have 0 load, then 4 cpus will be wrongly reported.
b5ee9b
Using standard sysconf api solves the issue in a simple way.
b5ee9b
---
b5ee9b
 src/application.cpp | 15 +++++----------
b5ee9b
 1 file changed, 5 insertions(+), 10 deletions(-)
b5ee9b
b5ee9b
diff --git a/src/application.cpp b/src/application.cpp
b5ee9b
index e1b77a2..5ddf3a0 100644
b5ee9b
--- a/src/application.cpp
b5ee9b
+++ b/src/application.cpp
b5ee9b
@@ -182,17 +182,12 @@ GsmApplication::load_settings()
b5ee9b
     g_signal_connect (settings, "changed::" GSM_SETTING_DISKS_UPDATE_INTERVAL,
b5ee9b
                       G_CALLBACK (cb_timeouts_changed), this);
b5ee9b
 
b5ee9b
-    /* Determine number of cpus since libgtop doesn't really tell you*/
b5ee9b
-    config.num_cpus = 0;
b5ee9b
-    glibtop_get_cpu (&cpu);
b5ee9b
+	/* Use proper number of cpus instead of unreliable check for active cpu */
b5ee9b
+	/* Some machines with high number of procs can have some core with 0 load */
b5ee9b
+    config.num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
b5ee9b
+
b5ee9b
+	glibtop_get_cpu (&cpu);
b5ee9b
     frequency = cpu.frequency;
b5ee9b
-    i=0;
b5ee9b
-    while (i < GLIBTOP_NCPU && cpu.xcpu_total[i] != 0) {
b5ee9b
-        config.num_cpus ++;
b5ee9b
-        i++;
b5ee9b
-    }
b5ee9b
-    if (config.num_cpus == 0)
b5ee9b
-        config.num_cpus = 1;
b5ee9b
 
b5ee9b
     apply_cpu_color_settings (settings, this);
b5ee9b
     g_signal_connect (settings, "changed::" GSM_SETTING_CPU_COLORS,
b5ee9b
-- 
b5ee9b
2.4.3
b5ee9b