* Re: [Powertop] [PATCH] Fix handling of /proc/cpuinfo for non x86 architectures
@ 2012-07-17 22:08 Chris Ferron
0 siblings, 0 replies; 2+ messages in thread
From: Chris Ferron @ 2012-07-17 22:08 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 1795 bytes --]
On 07/12/2012 01:37 PM, Stefan Weil wrote:
> Not all architectures include lines with "vendor_id\t" or
> "processor\t". ARM Linux without SMP support includes
> neither of these two entries. With SMP support, there are
> "processor\t" entries for each CPU.
>
> Set vendor to an empty string initially, so there is a default value.
>
> Assume CPU id 0 when no number was set while encountering the first
> "bogomips\t" line. If there are more such lines without a correct
> number, only the first CPU is handled. This should not be needed
> for ARM, but makes the code more robust because it avoids calling
> handle_one_cpu twice with number == 0.
>
> Signed-off-by: Stefan Weil <sw(a)weilnetz.de>
> ---
>
> This patch is based on my previous patch (which fixed the crash on ARM).
> The final result was tested on a Raspberry PI ARM.
>
> - sw
>
> src/cpu/cpu.cpp | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
> index d08bdcd..13015bd 100644
> --- a/src/cpu/cpu.cpp
> +++ b/src/cpu/cpu.cpp
> @@ -233,6 +233,9 @@ void enumerate_cpus(void)
> if (!file)
> return;
>
> + /* Not all /proc/cpuinfo include "vendor_id\t". */
> + vendor[0] = '\0';
> +
> while (file) {
>
> file.getline(line, sizeof(line));
> @@ -271,10 +274,14 @@ void enumerate_cpus(void)
> }
> }
> if (strncasecmp(line, "bogomips\t", 9) == 0) {
> + if (number == -1) {
> + /* Not all /proc/cpuinfo include "processor\t". */
> + number = 0;
> + }
> if (number >= 0) {
> handle_one_cpu(number, vendor, family, model);
> set_max_cpu(number);
> - number = -1;
> + number = -2;
> }
> }
> }
Your patch has been merged.
Thank you,
^ permalink raw reply [flat|nested] 2+ messages in thread* [Powertop] [PATCH] Fix handling of /proc/cpuinfo for non x86 architectures
@ 2012-07-12 20:37 Stefan Weil
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Weil @ 2012-07-12 20:37 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]
Not all architectures include lines with "vendor_id\t" or
"processor\t". ARM Linux without SMP support includes
neither of these two entries. With SMP support, there are
"processor\t" entries for each CPU.
Set vendor to an empty string initially, so there is a default value.
Assume CPU id 0 when no number was set while encountering the first
"bogomips\t" line. If there are more such lines without a correct
number, only the first CPU is handled. This should not be needed
for ARM, but makes the code more robust because it avoids calling
handle_one_cpu twice with number == 0.
Signed-off-by: Stefan Weil <sw(a)weilnetz.de>
---
This patch is based on my previous patch (which fixed the crash on ARM).
The final result was tested on a Raspberry PI ARM.
- sw
src/cpu/cpu.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index d08bdcd..13015bd 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -233,6 +233,9 @@ void enumerate_cpus(void)
if (!file)
return;
+ /* Not all /proc/cpuinfo include "vendor_id\t". */
+ vendor[0] = '\0';
+
while (file) {
file.getline(line, sizeof(line));
@@ -271,10 +274,14 @@ void enumerate_cpus(void)
}
}
if (strncasecmp(line, "bogomips\t", 9) == 0) {
+ if (number == -1) {
+ /* Not all /proc/cpuinfo include "processor\t". */
+ number = 0;
+ }
if (number >= 0) {
handle_one_cpu(number, vendor, family, model);
set_max_cpu(number);
- number = -1;
+ number = -2;
}
}
}
--
1.7.10
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-17 22:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-17 22:08 [Powertop] [PATCH] Fix handling of /proc/cpuinfo for non x86 architectures Chris Ferron
-- strict thread matches above, loose matches on Subject: below --
2012-07-12 20:37 Stefan Weil
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.