All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] [PATCH] Fix crash on Linux ARM hosts
@ 2012-07-12 18:41 Stefan Weil
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Weil @ 2012-07-12 18:41 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1810 bytes --]

/proc/cpuinfo on ARM hosts is different and resulted
in a call of handle_one_cpu() with number == -1
which finally raised a SIGSEGV crash (noticed on
Debian Wheezy for ARM).

Fix this by testing the value of "number".

After number was used, it is now reset to -1 just to make
sure that the new test also works for a potential 2nd cpu
with unexpected information in /proc/cpuinfo.

Signed-off-by: Stefan Weil <sw(a)weilnetz.de>
---

Please note that even with this patch, powertop on ARM will
only work partially: handle_one_cpu() is never called,
so there is no cpu information.

For ARM hosts with a single core cpu (the most common case),
using a case insensitive compare for 'processor' would work.

This is my /proc/cpuinfo:

Processor	: ARMv6-compatible processor rev 7 (v6l)
BogoMIPS	: 697.95
Features	: swp half thumb fastmult vfp edsp java tls 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xb76
CPU revision	: 7

Hardware	: BCM2708
Revision	: 0002
Serial		: 00000000e16a63c5

For multicore cpus, a better 2nd patch is needed.
If anybody has a /proc/cpuinfo of that kind, please tell me
the format - otherwise I'll have to look in the Linux source.

Regards,
Stefan Weil

 src/cpu/cpu.cpp |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index 4096835..d08bdcd 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -271,8 +271,11 @@ void enumerate_cpus(void)
 			}
 		}
 		if (strncasecmp(line, "bogomips\t", 9) == 0) {
-			handle_one_cpu(number, vendor, family, model);
-			set_max_cpu(number);
+			if (number >= 0) {
+				handle_one_cpu(number, vendor, family, model);
+				set_max_cpu(number);
+				number = -1;
+			}
 		}
 	}
 
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Powertop] [PATCH] Fix crash on Linux ARM hosts
@ 2012-07-12 20:24 Stefan Weil
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Weil @ 2012-07-12 20:24 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

Am 12.07.2012 22:18, schrieb Paul Menzel:
> Am Donnerstag, den 12.07.2012, 22:05 +0200 schrieb Stefan Weil:
>
> […]
>
>> It takes a while until0it is built, because my new Raspberry PI is so
>> terribly slow.
>
> Cross-compiling should solve that. ;-) OpenEmbedded or even some Debian
> tools should do the trick.
>
>
> Thanks,
>
> Paul
>
>
> [1] http://www.openembedded.org/

Well, it's finished now and it works better than before:

PowerTOP 2.0      Overview   Idle stats   Frequency stats   Device 
stats   Tunables

Summary: 0,0 wakeups/second,  0,0 GPU ops/seconds, 0,0 VFS ops/sec and 
22,4% CPU use

                 Usage       Events/s    Category       Description
              62,5 ms/s      0,00        Process        make all
              56,8 ms/s      0,00        Process        bash
              18,5 ms/s      0,00        Process        -bash
...

Obviously the wakeup rate is wrong, but the CPU use value is good.

- sw

PS. Patch follows.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Powertop] [PATCH] Fix crash on Linux ARM hosts
@ 2012-07-12 20:18 Paul Menzel
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Menzel @ 2012-07-12 20:18 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 329 bytes --]

Am Donnerstag, den 12.07.2012, 22:05 +0200 schrieb Stefan Weil:

[…]

> It takes a while until0it is built, because my new Raspberry PI is so
> terribly slow.

Cross-compiling should solve that. ;-) OpenEmbedded or even some Debian
tools should do the trick.


Thanks,

Paul


[1] http://www.openembedded.org/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Powertop] [PATCH] Fix crash on Linux ARM hosts
@ 2012-07-12 20:17 Sergey Senozhatsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2012-07-12 20:17 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1194 bytes --]

On (07/12/12 22:05), Stefan Weil wrote:
> >We had this before. I would rather prefer default CPU number
> >to be 1, instead of -1.
> >
> >Discussion:
> >http://lists.01.org/pipermail/powertop/2012-May/000055.html
> >http://lists.01.org/pipermail/powertop/2012-May/000073.html
> >
> >
> >And the patch is:
> >http://lists.01.org/pipermail/powertop/2012-May/000052.html
> >
> >Chris, did you have a chance to take a look on this one?
> >
> >	-ss
> >
> Thanks for the pointers to the previous mails - I had searched
> the archive and bug trackers but did not notice them.
> 
> The default CPU number should be 0, not 1, because
> that seems to be a common value for other architectures
> with only one CPU.
>

Good point.
 
> My patch only sets it to -1 to avoid any use of it (it could
> also be set to any negative value).
> 
> I'm just preparing a 2nd patch on top of this one which
> adds ARM support. It should also fix any other architecture
> which does not use "processor\t:" (there are several of them
> according to the Linux source code). It takes a while until
> it is built, because my new Raspberry PI is so terribly slow.
> 
> 

Great.

	-ss

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Powertop] [PATCH] Fix crash on Linux ARM hosts
@ 2012-07-12 20:05 Stefan Weil
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Weil @ 2012-07-12 20:05 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1683 bytes --]

Am 12.07.2012 21:45, schrieb Sergey Senozhatsky:
> On (07/12/12 20:41), Stefan Weil wrote:
>> /proc/cpuinfo on ARM hosts is different and resulted
>> in a call of handle_one_cpu() with number == -1
>> which finally raised a SIGSEGV crash (noticed on
>> Debian Wheezy for ARM).
>>
>> Fix this by testing the value of "number".
>>
>> After number was used, it is now reset to -1 just to make
>> sure that the new test also works for a potential 2nd cpu
>> with unexpected information in /proc/cpuinfo.
>>
>> Signed-off-by: Stefan Weil <sw(a)weilnetz.de>
>> ---
>>
>
>
> Hello,
>
> We had this before. I would rather prefer default CPU number
> to be 1, instead of -1.
>
> Discussion:
> http://lists.01.org/pipermail/powertop/2012-May/000055.html
> http://lists.01.org/pipermail/powertop/2012-May/000073.html
>
>
> And the patch is:
> http://lists.01.org/pipermail/powertop/2012-May/000052.html
>   
>
> Chris, did you have a chance to take a look on this one?
>
>
> 	-ss
>

Thanks for the pointers to the previous mails - I had searched
the archive and bug trackers but did not notice them.

The default CPU number should be 0, not 1, because
that seems to be a common value for other architectures
with only one CPU.

My patch only sets it to -1 to avoid any use of it (it could
also be set to any negative value).

I'm just preparing a 2nd patch on top of this one which
adds ARM support. It should also fix any other architecture
which does not use "processor\t:" (there are several of them
according to the Linux source code). It takes a while until
it is built, because my new Raspberry PI is so terribly slow.

         -sw

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Powertop] [PATCH] Fix crash on Linux ARM hosts
@ 2012-07-12 19:45 Sergey Senozhatsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2012-07-12 19:45 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 2540 bytes --]

On (07/12/12 20:41), Stefan Weil wrote:
> /proc/cpuinfo on ARM hosts is different and resulted
> in a call of handle_one_cpu() with number == -1
> which finally raised a SIGSEGV crash (noticed on
> Debian Wheezy for ARM).
> 
> Fix this by testing the value of "number".
> 
> After number was used, it is now reset to -1 just to make
> sure that the new test also works for a potential 2nd cpu
> with unexpected information in /proc/cpuinfo.
> 
> Signed-off-by: Stefan Weil <sw(a)weilnetz.de>
> ---
>


Hello,

We had this before. I would rather prefer default CPU number
to be 1, instead of -1.

Discussion:
http://lists.01.org/pipermail/powertop/2012-May/000055.html
http://lists.01.org/pipermail/powertop/2012-May/000073.html


And the patch is:
http://lists.01.org/pipermail/powertop/2012-May/000052.html
 

Chris, did you have a chance to take a look on this one?


	-ss


> Please note that even with this patch, powertop on ARM will
> only work partially: handle_one_cpu() is never called,
> so there is no cpu information.
> 
> For ARM hosts with a single core cpu (the most common case),
> using a case insensitive compare for 'processor' would work.
> 
> This is my /proc/cpuinfo:
> 
> Processor	: ARMv6-compatible processor rev 7 (v6l)
> BogoMIPS	: 697.95
> Features	: swp half thumb fastmult vfp edsp java tls 
> CPU implementer	: 0x41
> CPU architecture: 7
> CPU variant	: 0x0
> CPU part	: 0xb76
> CPU revision	: 7
> 
> Hardware	: BCM2708
> Revision	: 0002
> Serial		: 00000000e16a63c5
> 
> For multicore cpus, a better 2nd patch is needed.
> If anybody has a /proc/cpuinfo of that kind, please tell me
> the format - otherwise I'll have to look in the Linux source.
> 
> Regards,
> Stefan Weil
> 
>  src/cpu/cpu.cpp |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
> index 4096835..d08bdcd 100644
> --- a/src/cpu/cpu.cpp
> +++ b/src/cpu/cpu.cpp
> @@ -271,8 +271,11 @@ void enumerate_cpus(void)
>  			}
>  		}
>  		if (strncasecmp(line, "bogomips\t", 9) == 0) {
> -			handle_one_cpu(number, vendor, family, model);
> -			set_max_cpu(number);
> +			if (number >= 0) {
> +				handle_one_cpu(number, vendor, family, model);
> +				set_max_cpu(number);
> +				number = -1;
> +			}
>  		}
>  	}
>  
> -- 
> 1.7.10
> 
> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-07-12 20:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-12 18:41 [Powertop] [PATCH] Fix crash on Linux ARM hosts Stefan Weil
2012-07-12 19:45 Sergey Senozhatsky
2012-07-12 20:05 Stefan Weil
2012-07-12 20:17 Sergey Senozhatsky
2012-07-12 20:18 Paul Menzel
2012-07-12 20:24 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.