GNOME Bugzilla – Bug 619733
gnome-system-monitor displays extra "Unknown CPU mode" on ppc64
Last modified: 2011-11-11 10:03:55 UTC
Created attachment 162027 [details] [review] Patch: Ignore sysinfo record that contains no cpu model information While testing RHEL6, 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.
Created attachment 162028 [details] Screenshot of "Unknown CPU model" in System tab
Created attachment 162029 [details] Screenshot using patched gnome-system-monitor
Hello, Is it possible to get a comment regarding the patch please?
Thanks for the patch. Sorry it took so long to tend to it.
Created attachment 182314 [details] [review] Fix falsly reporting 'Unknown CPU model'.
Thanks Chris! I noticed that patch checked in had three additional line changes but that might have just been minor white space differences?
(In reply to comment #6) > Thanks Chris! > > I noticed that patch checked in had three additional line changes but that > might have just been minor white space differences? Yes, the patch wouldn't apply cleanly due to recent major changes so I made the change myself but marked you as the author since you tracked it down and were nice enough to submit a patch for. I'm always happy to get rid of trailing whitespace, which my editor automatically does on save, so I left those changes too. Thanks again.
Understood. Thanks!