public inbox for powertop@lists.linux.dev
 help / color / mirror / Atom feed
From: Jaroslav Skarvada <jskarvad at redhat.com>
To: powertop@lists.01.org
Subject: [Powertop] Segfault on ppc64
Date: Tue, 04 Jun 2019 10:01:17 -0400	[thread overview]
Message-ID: <1068529415.9789856.1559656877115.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: 1497495027.9778940.1559655311590.JavaMail.zimbra@redhat.com

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

PowerTOP crashes on ppc64 machine with 1 idle state, reproducer:
# powertop -t 1 --html

Parameters of the machine are attached.

It seems the problem is caused by the report_display_cpu_cstates()
function from the src/cpu/cpu.cpp file.

On https://github.com/fenrus75/powertop/blob/e8765b5475b22b7a2b6e9e8a031c68a268a0b0b3/src/cpu/cpu.cpp#L494
it allocates table 2x1, but the table should be 2x2 (header + 1 state), so it
later crashes on
https://github.com/fenrus75/powertop/blob/e8765b5475b22b7a2b6e9e8a031c68a268a0b0b3/src/cpu/cpu.cpp#L580
where it tries to fill the table.

Unfortunately, the whole reporting code is quite unclear, so I am not sure how
to correctly fix it and not break anything else. The attached patch fixes
the problem for me, but it can have side-effects - feel free to propose
better fix

thanks & regards

Jaroslav


Machine parameters:

# cpupower idle-info
CPUidle driver: pseries_idle
CPUidle governor: menu
analyzing CPU 0:

Number of idle states: 1
Available idle states: Shared Cede
Shared Cede:
Flags/Description: Shared Cede
Latency: 0
Usage: 1188350
Duration: 14152220333

# cat /proc/cpuinfo
processor	: 0
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

processor	: 1
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

processor	: 2
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

processor	: 3
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

processor	: 4
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

processor	: 5
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

processor	: 6
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

processor	: 7
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

timebase	: 512000000
platform	: pSeries
model		: IBM pSeries (emulated by qemu)
machine		: CHRP IBM pSeries (emulated by qemu)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: powertop-2.10-ppc64-crash-fix.patch --]
[-- Type: text/x-patch, Size: 554 bytes --]

diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index 28afc4f..063f2ca 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -489,7 +489,7 @@ void report_display_cpu_cstates(void)
 		string *pkg_data = new string[pkg_tbl_size.cols * pkg_tbl_size.rows];
 
 		core_tbl_size.cols=2;
-		core_tbl_size.rows=(cstates_num *_package->children.size())
+		core_tbl_size.rows=((cstates_num + 1) * _package->children.size())
 				+ _package->children.size();
 		string *core_data = new string[core_tbl_size.cols * core_tbl_size.rows];
 		int num_cpus=0, num_cores=0;

                 reply	other threads:[~2019-06-04 14:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1068529415.9789856.1559656877115.JavaMail.zimbra@redhat.com \
    --to=powertop@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox