Re: [Powertop] segfault on Sheevaplug (ARM Kirkwood)

Rui DaCosta <ruidc at yahoo.com> Sun, 20 May 2012 12:32:56 -0700
Newsgroups dev.linux.lists.powertop
Message-ID <[email protected]>
it was pointed out to me that  CONFIG_PERF_COUNTERS has been superseded by PERF_EVENTS since 2.6.32  - see bottom section of http://cateee.net/lkddb/web-lkddb/PERF_COUNTERS.html

so is  CONFIG_PERF_COUNTERS really required?




________________________________
 From: Rui DaCosta <ruidc(a)yahoo.com>
To: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com> 
Cc: Arjan van de Ven <arjan(a)linux.intel.com>; Chris Ferron <chris.e.ferron(a)linux.intel.com>; "powertop(a)lists.01.org" <powertop(a)lists.01.org> 
Sent: Sunday, 20 May 2012, 13:01
Subject: Re: [Powertop] segfault on Sheevaplug (ARM Kirkwood)
 

Thanks,

this has gotten past the issue. I now get:


PowerTOP v2.0 needs the kernel to support the 'perf' subsystem
as well as support for trace points in the kernel:

CONFIG_PERF_EVENTS=y 
CONFIG_PERF_COUNTERS=y
CONFIG_TRACEPOINTS=y
CONFIG_TRACING=y

all these except CONFIG_PERF_COUNTERS are already set, so i'll need to see if i can get a kernel built with that option on.

Will this patch make it into trunk?

Many thanks.


________________________________
 From: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>
To: Rui DaCosta <ruidc(a)yahoo.com> 
Cc: Arjan van de Ven <arjan(a)linux.intel.com>; Chris Ferron <chris.e.ferron(a)linux.intel.com>; powertop(a)lists.01.org 
Sent: Sunday, 20 May 2012, 11:34
Subject: Re: [Powertop] segfault on Sheevaplug (ARM Kirkwood)
 
On (05/20/12 02:19), Rui DaCosta wrote:
> Sure and thanks,
> (v1.13 worked fine btw)
> Processor    : Feroceon 88FR131 rev 1 (v5l)
> BogoMIPS    : 1191.11
> Features    : swp half thumb
 fastmult edsp 
> CPU implementer    : 0x56
> CPU architecture: 5TE
> CPU variant    : 0x2
> CPU part    : 0x131
> CPU revision    : 1
> 
> Hardware    : Marvell SheevaPlug Reference Board
> Revision    : 0000
> Serial        : 0000000000000000
> 
> 

Thanks,

Well, that's the problem. Current cpu info parser doesn't understand your
cpuinfo format. It awaits for sane values on special places. For example, word 
"processor" should be followed by a number, not model name.

    processor    : 2
    vendor_id    : GenuineIntel
    cpu family    : 6
    model        : 37
   
 bogomips    : 4522.66

while cpuinfo on your system is totally different.

the following is untested patch (I'm a bit skeptical) plus I don't have 
ARM device for testing.

---

src/cpu/cpu.cpp |   26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index 09d4a2d..143e18c 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -225,7 +225,7 @@ void enumerate_cpus(void)
    ifstream file;
    char line[1024];

-    int number = -1;
+    int number = 1;
    char vendor[128];
    int family = 0;
    int model = 0;
@@ -236,7 +236,6 @@ void enumerate_cpus(void)
        return;

    while (file) {
-
   
     file.getline(line, sizeof(line));
        if (strncmp(line, "vendor_id\t",10) == 0) {
            char *c;
@@ -247,42 +246,45 @@ void enumerate_cpus(void)
                    c++;
                strncpy(vendor,c, 127);
            }
-        }
-        if (strncmp(line, "processor\t",10) == 0) {
+        } else if (strncmp(line, "processor\t",10) == 0) {
            char *c;
            c = strchr(line, ':');
       
     if (c) {
                c++;
                number = strtoull(c, NULL, 10);
            }
-        }
-        if (strncmp(line, "cpu family\t",11) == 0) {
+        } else if (strncmp(line, "Processor\t",10) == 0) {
+            char *c;
+            c = strchr(line, ':');
+            if (c) {
+                c++;
+                if (*c == ' ')
+       
             c++;
+                strncpy(vendor, c, 127);
+            }
+        }  else if (strncmp(line, "cpu family\t",11) == 0) {
            char *c;
            c = strchr(line, ':');
            if (c) {
                c++;
                family = strtoull(c, NULL, 10);
            }
-        }
-        if (strncmp(line, "model\t",6) == 0) {
+   
     } else if (strncmp(line, "model\t",6) == 0) {
            char *c;
            c = strchr(line, ':');
            if (c) {
                c++;
                model = strtoull(c, NULL, 10);
            }
-        }
-        if (strncasecmp(line, "bogomips\t", 9) == 0) {
+        } else if (strncasecmp(line, "bogomips\t", 9) == 0) {
            handle_one_cpu(number, vendor, family, model);
           
 set_max_cpu(number);
        }
    }

-
    file.close();

    perf_events = new perf_power_bundle();
-
    if (!perf_events->add_event("power:cpu_idle")){
        perf_events->add_event("power:power_start");
        perf_events->add_event("power:power_end");
attachment.html (text/html, 9.4 KB)
<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>it was pointed out to me that&nbsp;</span>
<span>CONFIG_PERF_COUNTERS has been superseded by PERF_EVENTS since 2.6.32 &nbsp;- see bottom section of </span><span>http://cateee.net/lkddb/web-lkddb/PERF_COUNTERS.html</span></div><div><span><br></span></div><div><span>so is&nbsp;</span>
<span>CONFIG_PERF_COUNTERS really required?</span><span><br></span><span><br></span></div><div><br></div>  <div style="font-size: 12pt; font-family: &quot;times new roman&quot;, &quot;new york&quot;, &quot;times&quot;, serif"> <div style="font-size: 12pt; font-family: &quot;times new roman&quot;, &quot;new york&quot;, &quot;times&quot;, serif"> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Rui DaCosta &lt;[email protected]&gt;<br> <b><span style="font-weight: bold;">To:</span></b> Sergey Senozhatsky &lt;[email protected]&gt; <br><b><span style="font-weight: bold;">Cc:</span></b> Arjan van de Ven &lt;[email protected]&gt;; Chris Ferron &lt;[email protected]&gt;; "[email protected]" &lt;[email protected]&gt; <br> <b><span style="font-weight: bold;">Sent:</span></b> Sunday, 20 May 2012, 13:01<br> <b><span style="font-weight: bold;">Subject:</span></b> Re:
 [Powertop] segfault on Sheevaplug (ARM Kirkwood)<br> </font> </div> <br><div id="yiv720964874"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-size: 12pt; font-family: &quot;times new roman&quot;, &quot;new york&quot;, &quot;times&quot;, serif"><div><span>Thanks,<br></span></div><div><span>this has gotten past the issue. I now get:<br></span></div><div><span><br></span></div><div><span>PowerTOP v2.0 needs the kernel to support the 'perf' subsystem<br>as well as support for trace points in the kernel:<br><br>CONFIG_PERF_EVENTS=y <br>CONFIG_PERF_COUNTERS=y<br>CONFIG_TRACEPOINTS=y<br>CONFIG_TRACING=y<br><br>all these except CONFIG_PERF_COUNTERS are already set, so i'll need to see if i can get a kernel built with that option on.</span></div><div><span><br></span></div><div><span>Will this patch make it into trunk?</span></div><div><span><br>Many thanks.</span></div><div><br></div>  <div style="font-size:12pt;"> <div
 style="font-size:12pt;
"> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Sergey Senozhatsky &lt;[email protected]&gt;<br> <b><span style="font-weight:bold;">To:</span></b> Rui DaCosta &lt;[email protected]&gt; <br><b><span style="font-weight:bold;">Cc:</span></b> Arjan van de Ven &lt;[email protected]&gt;; Chris Ferron &lt;[email protected]&gt;; [email protected] <br> <b><span style="font-weight:bold;">Sent:</span></b> Sunday, 20 May 2012, 11:34<br> <b><span style="font-weight:bold;">Subject:</span></b> Re: [Powertop] segfault on Sheevaplug (ARM Kirkwood)<br> </font> </div> <br>On (05/20/12 02:19), Rui DaCosta wrote:<br>&gt; Sure and thanks,<br>&gt; (v1.13 worked fine btw)<br>&gt; Processor&nbsp;&nbsp;&nbsp; : Feroceon 88FR131 rev 1 (v5l)<br>&gt; BogoMIPS&nbsp;&nbsp;&nbsp; : 1191.11<br>&gt; Features&nbsp;&nbsp;&nbsp; : swp half thumb
 fastmult edsp <br>&gt; CPU implementer&nbsp;&nbsp;&nbsp; : 0x56<br>&gt; CPU architecture: 5TE<br>&gt; CPU variant&nbsp;&nbsp;&nbsp; : 0x2<br>&gt; CPU part&nbsp;&nbsp;&nbsp; : 0x131<br>&gt; CPU revision&nbsp;&nbsp;&nbsp; : 1<br>&gt; <br>&gt; Hardware&nbsp;&nbsp;&nbsp; : Marvell SheevaPlug Reference Board<br>&gt; Revision&nbsp;&nbsp;&nbsp; : 0000<br>&gt; Serial&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; : 0000000000000000<br>&gt; <br>&gt; <br><br>Thanks,<br><br>Well, that's the problem. Current cpu info parser doesn't understand your<br>cpuinfo format. It awaits for sane values on special places. For example, word <br>"processor" should be followed by a number, not model name.<br><br>&nbsp;&nbsp;&nbsp; processor&nbsp;&nbsp;&nbsp; : 2<br>&nbsp;&nbsp;&nbsp; vendor_id&nbsp;&nbsp;&nbsp; : GenuineIntel<br>&nbsp;&nbsp;&nbsp; cpu family&nbsp;&nbsp;&nbsp; : 6<br>&nbsp;&nbsp;&nbsp; model&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; : 37<br>&nbsp;&nbsp;&nbsp;
 bogomips&nbsp;&nbsp;&nbsp; : 4522.66<br><br>while cpuinfo on your system is totally different.<br><br>the following is untested patch (I'm a bit skeptical) plus I don't have <br>ARM device for testing.<br><br>---<br><br> src/cpu/cpu.cpp |&nbsp;  26 ++++++++++++++------------<br> 1 file changed, 14 insertions(+), 12 deletions(-)<br><br>diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp<br>index 09d4a2d..143e18c 100644<br>--- a/src/cpu/cpu.cpp<br>+++ b/src/cpu/cpu.cpp<br>@@ -225,7 +225,7 @@ void enumerate_cpus(void)<br> &nbsp;&nbsp;&nbsp; ifstream file;<br> &nbsp;&nbsp;&nbsp; char line[1024];<br> <br>-&nbsp;&nbsp;&nbsp; int number = -1;<br>+&nbsp;&nbsp;&nbsp; int number = 1;<br> &nbsp;&nbsp;&nbsp; char vendor[128];<br> &nbsp;&nbsp;&nbsp; int family = 0;<br> &nbsp;&nbsp;&nbsp; int model = 0;<br>@@ -236,7 +236,6 @@ void enumerate_cpus(void)<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return;<br> <br> &nbsp;&nbsp;&nbsp; while (file) {<br>-<br> &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; file.getline(line, sizeof(line));<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (strncmp(line, "vendor_id\t",10) == 0) {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; char *c;<br>@@ -247,42 +246,45 @@ void enumerate_cpus(void)<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c++;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; strncpy(vendor,c, 127);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (strncmp(line, "processor\t",10) == 0) {<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else if (strncmp(line, "processor\t",10) == 0) {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; char *c;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c = strchr(line, ':');<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; if (c) {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c++;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; number = strtoull(c, NULL, 10);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (strncmp(line, "cpu family\t",11) == 0) {<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else if (strncmp(line, "Processor\t",10) == 0) {<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; char *c;<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c = strchr(line, ':');<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (c) {<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c++;<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (*c == ' ')<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c++;<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; strncpy(vendor, c, 127);<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }&nbsp; else if (strncmp(line, "cpu family\t",11) == 0) {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; char *c;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c = strchr(line, ':');<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (c) {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c++;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; family = strtoull(c, NULL, 10);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (strncmp(line, "model\t",6) == 0) {<br>+&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; } else if (strncmp(line, "model\t",6) == 0) {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; char *c;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c = strchr(line, ':');<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (c) {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; c++;<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; model = strtoull(c, NULL, 10);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (strncasecmp(line, "bogomips\t", 9) == 0) {<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } else if (strncasecmp(line, "bogomips\t", 9) == 0) {<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; handle_one_cpu(number, vendor, family, model);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 set_max_cpu(number);<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; }<br> <br>-<br> &nbsp;&nbsp;&nbsp; file.close();<br> <br> &nbsp;&nbsp;&nbsp; perf_events = new perf_power_bundle();<br>-<br> &nbsp;&nbsp;&nbsp; if (!perf_events-&gt;add_event("power:cpu_idle")){<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; perf_events-&gt;add_event("power:power_start");<br> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; perf_events-&gt;add_event("power:power_end");<br><br><br><br> </div> </div>  </div></div></div><br><br> </div> </div>  </div></body></html>