Patch: Ignore sysinfo record that contains no cpu model information



Hello,

Problem description:

While testing on ppc64, the gnome-system-monitor tool always displays an
extra CPU as "Unknown CPU model" in the "System" tabbed section. For
example, the host has only two virtual processors
(Processor 0 and Processor 1), but there is always an extra CPU
displayed at the end with a description of "Processor 2: Unknown CPU
model". You could see details in the attachment "Unknown CPU model".

Recreation steps:
1. Launch System Monitor Tool (gnome-system-monitor)
2. Look at "Hardware" item of "System" tabbed section like following sentence:
   Processor 2: Unknown CPU model

Additional information:

# rpm -q gnome-system-monitor
gnome-system-monitor-2.28.0-4.el6.ppc64
# cat /proc/cpuinfo
processor       : 0
cpu             : POWER6 (architected), altivec supported
clock           : 4204.000000MHz
revision        : 3.1 (pvr 003e 0301)

processor       : 1
cpu             : POWER6 (architected), altivec supported
clock           : 4204.000000MHz
revision        : 3.1 (pvr 003e 0301)

timebase        : 512000000
platform        : pSeries
model           : IBM,8204-E8A
machine         : CHRP IBM,8204-E8A

The problem stems from the processing done in the gnome-system-monitor
src/sysinfo.cpp source and specifically in the load_processors_info()
method:

    void load_processors_info()
    {
      const glibtop_sysinfo *info = glibtop_get_sysinfo();

      for (guint i = 0; i != info->ncpu; ++i) {
        const char * const keys[] = { "model name", "cpu" };
        gchar *model = 0;

        for (guint j = 0; !model && j != G_N_ELEMENTS(keys); ++j)
          model =
static_cast<char*>(g_hash_table_lookup(info->cpuinfo[i].values,
                                                         keys[j]));

        if (!model)
          model = _("Unknown CPU model");

        this->processors.push_back(model);
      }
    }

It first invokes the glibtop_get_sysinfo() call which comes from the
external libgtop to retrieve the system info (I will explain where from
shortly) and then uses the keys "model name" and "cpu" to retrieve the
corresponding strings in a hash table that correspond to those keys.
What is retrieved is what ends up being displayed under the Hardware
section.

In the libgtop source we find a file called  sysdeps/linux/sysinfo.c
which contains the source for the glibtop_get_sysinfo() which almost
wholly contained in the function init_sysinfo(). It essentially reads
the contents of /proc/cpuinfo into a buffer then parses each line and
uses the label before the ":" as the key and the remaining as the value
and the labels/keys are loaded into string array and the string values
are added into a hash table with the label as the key.

init_sysinfo() parses the /proc/cpuinfo and considers each set of text
interrupted by "\n\n" as a new record of information. However, in
the /proc/cpuinfo output for a ppc64 system the last "record" is not
information about a specific cpu but mostly extra general information.

timebase        : 512000000
platform        : pSeries
model           : IBM,8204-E8A
machine         : CHRP IBM,8204-E8A

So when the load_processors_info() iterates into that last record, it
does not retrieve anything corresponding to "model name" or "cpu" key
and we end up displaying this last extra "Unknown CPU model" line.

The attached patch makes one simple change that removes the display of
the "Unknown CPU model" string and instead continues iteration of the
loop if the sysinfo record contains no "cpu" or "model name" key or
value in it.

This second screenshot is from the same system as the first screenshot
but using the gnome-system-monitor with the patch applied showing no
extra processor with "Unknown CPU model".

The patch applies cleanly to the latest gnome-system-monitor-2.28.1 source.

regards,
-- 
Luciano Chavez <lnx1138 linux vnet ibm com>
IBM Linux Technology Center

Attachment: Unknown_CPU_model.jpg
Description: JPEG image

diff -up gnome-system-monitor-2.28.0/src/sysinfo.cpp.orig gnome-system-monitor-2.28.0/src/sysinfo.cpp
--- gnome-system-monitor-2.28.0/src/sysinfo.cpp.orig	2010-05-12 21:37:56.608454817 -0500
+++ gnome-system-monitor-2.28.0/src/sysinfo.cpp	2010-05-12 21:38:10.338458188 -0500
@@ -113,7 +113,7 @@ namespace {
 							 keys[j]));
 
 	if (!model)
-	  model = _("Unknown CPU model");
+	  continue;
 
 	this->processors.push_back(model);
       }

Attachment: sysmon_fixed.png
Description: PNG image



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]