[PATCH] cpu: Fix abstract_cpu::calculate_freq
by Namhyung Kim
The 'freq' should have the maximun frequency value of all children.
But the current code does not update the freq properly. Fix it.
Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
src/cpu/abstract_cpu.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cpu/abstract_cpu.cpp b/src/cpu/abstract_cpu.cpp
index 386d981..de55cf2 100644
--- a/src/cpu/abstract_cpu.cpp
+++ b/src/cpu/abstract_cpu.cpp
@@ -341,7 +341,7 @@ void abstract_cpu::calculate_freq(uint64_t time)
is_idle = false;
}
if (f > freq)
- f = freq;
+ freq = f;
}
current_frequency = freq;
--
1.7.9.2
9 years, 8 months
[PATCH v2 1/2] Updates to support Android platform
by Rajagopal Venkat
This patch adds following minor changes to prepare powertop
to support Android platform.
- Add missing HAVE_CONFIG_H conditional check.
- remove un-used ethtool_cmd_speed_set and ethtool_cmd_speed
functions.
- Minimize dependency on exception handling in catch blocks.
These changes will not affect powertop functionality.
Signed-off-by: Rajagopal Venkat <rajagopal.venkat(a)linaro.org>
---
src/devices/ahci.cpp | 4 ++--
src/devices/alsa.cpp | 4 ++--
src/devices/network.cpp | 16 ----------------
src/main.cpp | 2 ++
4 files changed, 6 insertions(+), 20 deletions(-)
diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp
index 1fe39c7..67ce06e 100644
--- a/src/devices/ahci.cpp
+++ b/src/devices/ahci.cpp
@@ -170,7 +170,7 @@ void ahci::start_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to start measurement for ahci device\n");
}
}
@@ -203,7 +203,7 @@ void ahci::end_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to end measurement for ahci device\n");
}
if (end_active < start_active)
end_active = start_active;
diff --git a/src/devices/alsa.cpp b/src/devices/alsa.cpp
index 4f5d3f9..a67780c 100644
--- a/src/devices/alsa.cpp
+++ b/src/devices/alsa.cpp
@@ -104,7 +104,7 @@ void alsa::start_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to start measurement for alsa device\n");
}
}
@@ -130,7 +130,7 @@ void alsa::end_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to end measurement for alsa device\n");
}
p = (end_active - start_active) / (0.001 + end_active + end_inactive - start_active - start_inactive) * 100.0;
diff --git a/src/devices/network.cpp b/src/devices/network.cpp
index b8a5c9c..ed9d7aa 100644
--- a/src/devices/network.cpp
+++ b/src/devices/network.cpp
@@ -55,22 +55,6 @@ extern "C" {
static map<string, class network *> nics;
-#ifdef DISABLE_TRYCATCH
-
-static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
- __u32 speed)
-{
-
- ep->speed = (__u16)speed;
- ep->speed_hi = (__u16)(speed >> 16);
-}
-
-static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
-{
- return (ep->speed_hi << 16) | ep->speed;
-}
-
-#endif
static void do_proc_net_dev(void)
{
diff --git a/src/main.cpp b/src/main.cpp
index 1815075..dc49dba 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -42,7 +42,9 @@
#include "perf/perf.h"
#include "perf/perf_bundle.h"
#include "lib.h"
+#ifdef HAVE_CONFIG_H
#include "../config.h"
+#endif
#include "devices/device.h"
--
1.7.11.3
9 years, 9 months
[PATCH v2] Fix string null termination and SIGABRT from glibc
by Mikko Rapeli
According to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=682388
the string is not null terminated when too much data is read.
This patch fixes the crashes on my system.
---
src/process/process.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/process/process.cpp b/src/process/process.cpp
index 71f81b6..34dc68d 100644
--- a/src/process/process.cpp
+++ b/src/process/process.cpp
@@ -86,7 +86,7 @@ static void cmdline_to_string(char *str)
process::process(const char *_comm, int _pid, int _tid) : power_consumer()
{
- char line[4096];
+ char line[4097];
ifstream file;
strcpy(comm, _comm);
@@ -103,6 +103,7 @@ process::process(const char *_comm, int _pid, int _tid) : power_consumer()
file.open(line);
while (file) {
file.getline(line, 4096);
+ line[4096] = '\0';
if (strstr(line, "Tgid")) {
char *c;
c = strchr(line, ':');
--
1.7.10.4
9 years, 9 months
[PATCH] Fix string null termination and SIGABRT from glibc
by Mikko Rapeli
According to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=682388
the string is not null terminated when too much data is read.
This patch fixes the crashes for me. My traces:
PowerTOP 2.1 Overview Idle stats Frequency stats Device stats Tunab
Package | CPU 0
POLL 0.0% | POLL 0.0% 0.0 ms
C1 0.0% | C1 0.0% 0.0 ms
C2 3.8% | C2 5.4% 0.2 ms
C3 12.4% | C3 20.9% 1.7 ms
| CPU 1
| POLL 0.0% 0.0 ms
| C1 0.0% 0.2 ms
| C2 2.2% 0.2 ms
| C3 3.8% 0.9 ms
*** stack smashing detected ***: /usr/local/sbin/powertop terminated
======= Backtrace: =========
/lib/i386-linux-gnu/i686/cmov/libc.so.6(__fortify_fail+0x50)[0xb7d7be70]
/lib/i386-linux-gnu/i686/cmov/libc.so.6(+0xe4e1a)[0xb7d7be1a]
/usr/local/sbin/powertop[0x8067a01]
<ESC> Exit | /usr/local/sbin/powertop[0x8067ce7]
/usr/local/sbin/powertop[0x806b727]
/usr/local/sbin/powertop[0x8070d62]
/usr/local/sbin/powertop[0x806c2e6]
/usr/local/sbin/powertop[0x8089ecf]
/usr/local/sbin/powertop[0x804df42]
/lib/i386-linux-gnu/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0xb7cade46]
/usr/local/sbin/powertop[0x804e0f1]
======= Memory map: ========
08048000-080af000 r-xp 00000000 08:02 2336756 /usr/local/sbin/powertop
080af000-080b0000 rw-p 00067000 08:02 2336756 /usr/local/sbin/powertop
080b0000-1022a000 rw-p 00000000 00:00 0 [heap]
b68c6000-b69c7000 rw-p 00000000 00:00 0
b6aaa000-b6acb000 rw-p 00000000 00:00 0
b6acb000-b6b4c000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b6b4c000-b6bcd000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b6bcd000-b6c4e000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b6c4e000-b6ccf000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b6ccf000-b6d50000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b6d50000-b6dd1000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b6dd1000-b6e52000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b6e52000-b6ed3000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b6ed3000-b6f54000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b6f54000-b6fd5000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b6fd5000-b7056000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b7056000-b70d7000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b70d7000-b7158000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b7158000-b71d9000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b71d9000-b725a000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b725a000-b72db000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b72db000-b735c000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b735c000-b73dd000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b73dd000-b745e000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b745e000-b74df000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b74df000-b7560000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b7560000-b75e1000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b75e1000-b7662000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b7662000-b76e3000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b76e3000-b7764000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b7764000-b77e5000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b77e5000-b7866000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b7866000-b78e7000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b78e7000-b7968000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b7968000-b79e9000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b79e9000-b7a6a000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b7a6a000-b7aeb000 rw-s 00000000 00:09 5025 anon_inode:[perf_event]
b7aeb000-b7c62000 r--p 00000000 08:02 2621607 /usr/lib/locale/locale-archive
b7c62000-b7c65000 rw-p 00000000 00:00 0
b7c65000-b7c67000 r-xp 00000000 08:02 632012 /lib/i386-linux-gnu/i686/cmov/libdl-2.13.so
b7c67000-b7c68000 r--p 00001000 08:02 632012 /lib/i386-linux-gnu/i686/cmov/libdl-2.13.so
b7c68000-b7c69000 rw-p 00002000 08:02 632012 /lib/i386-linux-gnu/i686/cmov/libdl-2.13.so
b7c69000-b7c6a000 rw-p 00000000 00:00 0
b7c6a000-b7c7a000 r-xp 00000000 08:02 632036 /lib/i386-linux-gnu/i686/cmov/libresolv-2.13.so
b7c7a000-b7c7b000 r--p 00010000 08:02 632036 /lib/i386-linux-gnu/i686/cmov/libresolv-2.13.so
b7c7b000-b7c7c000 rw-p 00011000 08:02 632036 /lib/i386-linux-gnu/i686/cmov/libresolv-2.13.so
b7c7c000-b7c7e000 rw-p 00000000 00:00 0
b7c7e000-b7c95000 r-xp 00000000 08:02 632038 /lib/i386-linux-gnu/libz.so.1.2.7
b7c95000-b7c96000 r--p 00016000 08:02 632038 /lib/i386-linux-gnu/libz.so.1.2.7
b7c96000-b7c97000 rw-p 00017000 08:02 632038 /lib/i386-linux-gnu/libz.so.1.2.7
b7c97000-b7ded000 r-xp 00000000 08:02 632108 /lib/i386-linux-gnu/i686/cmov/libc-2.13.so
b7ded000-b7dee000 ---p 00156000 08:02 632108 /lib/i386-linux-gnu/i686/cmov/libc-2.13.so
b7dee000-b7df0000 r--p 00156000 08:02 632108 /lib/i386-linux-gnu/i686/cmov/libc-2.13.so
b7df0000-b7df1000 rw-p 00158000 08:02 632108 /lib/i386-linux-gnu/i686/cmov/libc-2.13.so
b7df1000-b7df4000 rw-p 00000000 00:00 0
b7df4000-b7e10000 r-xp 00000000 08:02 630810 /lib/i386-linux-gnu/libgcc_s.so.1
b7e10000-b7e11000 rw-p 0001b000 08:02 630810 /lib/i386-linux-gnu/libgcc_s.so.1
b7e11000-b7e35000 r-xp 00000000 08:02 632046 /lib/i386-linux-gnu/i686/cmov/libm-2.13.so
b7e35000-b7e36000 r--p 00023000 08:02 632046 /lib/i386-linux-gnu/i686/cmov/libm-2.13.so
b7e36000-b7e37000 rw-p 00024000 08:02 632046 /lib/i386-linux-gnu/i686/cmov/libm-2.13.so
b7e37000-b7e38000 rw-p 00000000 00:00 0
b7e38000-b7f18000 r-xp 00000000 08:02 2514966 /usr/lib/i386-linux-gnu/libstdc++.so.6.0.17
b7f18000-b7f1c000 r--p 000e0000 08:02 2514966 /usr/lib/i386-linux-gnu/libstdc++.so.6.0.17
b7f1c000-b7f1d000 rw-p 000e4000 08:02 2514966 /usr/lib/i386-linux-gnu/libstdc++.so.6.0.17
b7f1d000-b7f24000 rw-p 00000000 00:00 0
b7f24000-b7f41000 r-xp 00000000 08:02 630823 /lib/i386-linux-gnu/libtinfo.so.5.9
b7f41000-b7f43000 r--p 0001c000 08:02 630823 /lib/i386-linux-gnu/libtinfo.so.5.9
b7f43000-b7f44000 rw-p 0001e000 08:02 630823 /lib/i386-linux-gnu/libtinfo.so.5.9
b7f44000-b7f75000 r-xp 00000000 08:02 630988 /lib/i386-linux-gnu/libncursesw.so.5.9
b7f75000-b7f76000 r--p 00030000 08:02 630988 /lib/i386-linux-gnu/libncursesw.so.5.9
b7f76000-b7f77000 rw-p 00031000 08:02 630988 /lib/i386-linux-gnu/libncursesw.so.5.9
b7f77000-b7f8c000 r-xp 00000000 08:02 631069 /lib/i386-linux-gnu/i686/cmov/libpthread-2.13.so
b7f8c000-b7f8d000 r--p 00014000 08:02 631069 /lib/i386-linux-gnu/i686/cmov/libpthread-2.13.so
b7f8d000-b7f8e000 rw-p 00015000 08:02 631069 /lib/i386-linux-gnu/i686/cmov/libpthread-2.13.so
b7f8e000-b7f90000 rw-p 00000000 00:00 0
b7f90000-b7fa7000 r-xp 00000000 08:02 630877 /lib/i386-linux-gnu/libnl-3.so.200.5.2
b7fa7000-b7fa8000 r--p 00017000 08:02 630877 /lib/i386-linux-gnu/libnl-3.so.200.5.2
b7fa8000-b7fa9000 rw-p 00018000 08:02 630877 /lib/i386-linux-gnu/libnl-3.so.200.5.2
b7fa9000-b7faa000 rw-p 00000000 00:00 0
b7faa000-b7fae000 r-xp 00000000 08:02 630867 /lib/i386-linux-gnu/libnl-genl-3.so.200.5.2
b7fae000-b7faf000 r--p 00003000 08:02 630867 /lib/i386-linux-gnu/libnl-genl-3.so.200.5.2
b7faf000-b7fb0000 rw-p 00004000 08:02 630867 /lib/i386-linux-gnu/libnl-genl-3.so.200.5.2
b7fb0000-b7fbb000 r-xp 00000000 08:02 630812 /lib/i386-linux-gnu/libpci.so.3.1.9
b7fbb000-b7fbc000 r--p 0000a000 08:02 630812 /lib/i386-linux-gnu/libpci.so.3.1.9
b7fbc000-b7fbd000 rw-p 0000b000 08:02 630812 /lib/i386-linux-gnu/libpci.so.3.1.9
b7fd6000-b7fdd000 r--s 00000000 08:02 2518433 /usr/lib/i386-linux-gnu/gconv/gconv-modules.cache
b7fdd000-b7fdf000 r--p 00000000 08:02 2892068 /usr/local/share/locale/en_US/LC_MESSAGES/powertop.mo
b7fdf000-b7fe1000 rw-p 00000000 00:00 0
b7fe1000-b7fe2000 r-xp 00000000 00:00 0 [vdso]
b7fe2000-b7ffe000 r-xp 00000000 08:02 630935 /lib/i386-linux
Program received signal SIGABRT, Aborted.
0xb7fe1424 in __kernel_vsyscall ()
(gdb) bt full
No symbol table info available.
at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
resultvar = <optimized out>
pid = -1210122252
selftid = 22773
act = {__sigaction_handler = {
sa_handler = 0xb7fff4e4 <_rtld_global+1220>,
sa_sigaction = 0xb7fff4e4 <_rtld_global+1220>}, sa_mask = {
__val = {1835008, 134937032, 134519608, 3221208440, 4319,
3221208408, 134515384, 134515200, 3221208252, 4, 3221208336,
3084252763, 134937032, 3083678964, 3084845044, 11, 3221209724,
3221208456, 3084371588, 55, 3221208336, 4, 0, 3221208432, 0, 2,
3084702268, 3084702264, 3084697743, 3084697808, 230,
3221208336}}, sa_flags = -1073758888, sa_restorer = 0xb7dce616}
sigs = {__val = {32, 0 <repeats 31 times>}}
fmt=0xb7dce588 "*** %s ***: %s terminated\n")
at ../sysdeps/unix/sysv/linux/libc_fatal.c:189
ap = <optimized out>
fd = -1073758600
---Type <return> to continue, or q <return> to quit---
on_2 = <optimized out>
list = <optimized out>
nlist = <optimized out>
cp = <optimized out>
written = false
at fortify_fail.c:32
No locals.
No locals.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
ubp_av=0xbffff7f4, init=0x80954e0, fini=0x80954d0, rtld_fini=0xb7ff0590,
stack_end=0xbffff7ec) at libc-start.c:228
result = <optimized out>
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-1210122252, 0, 0,
-1073743928, 766793170, 1206313922}, mask_was_saved = 0}},
priv = {pad = {0x0, 0x0, 0x1, 0x804e0d0}, data = {prev = 0x0,
cleanup = 0x0, canceltype = 1}}}
not_first_call = <optimized out>
No symbol table info available.
---
src/process/process.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/process/process.cpp b/src/process/process.cpp
index 71f81b6..34dc68d 100644
--- a/src/process/process.cpp
+++ b/src/process/process.cpp
@@ -86,7 +86,7 @@ static void cmdline_to_string(char *str)
process::process(const char *_comm, int _pid, int _tid) : power_consumer()
{
- char line[4096];
+ char line[4097];
ifstream file;
strcpy(comm, _comm);
@@ -103,6 +103,7 @@ process::process(const char *_comm, int _pid, int _tid) : power_consumer()
file.open(line);
while (file) {
file.getline(line, 4096);
+ line[4096] = '\0';
if (strstr(line, "Tgid")) {
char *c;
c = strchr(line, ':');
--
1.7.10.4
9 years, 9 months
Software resource usage by cpu's
by Saumil Merchant
Hi,
I am new to PowerTop and think it is a wonderful tool and am exploring its
possible use in my work. I had a question. Can PowerTop report software
resource usage info for individual CPU's? For example, have a CPU column
in the software info report which specifies the cpu on which the process
was scheduled.
Thanks,
Saumil
9 years, 9 months
[PATCH 0/4] Fix a few minor typos.
by Colin King
From: Colin Ian King <colin.king(a)canonical.com>
Just a few minor spelling mistakes/typos that need fixing.
Colin Ian King (4):
main: Fix type in print_usage
cpu: abstract_cpu: Fix typo in comment
process: do_process: Fix typo in handle_trace_point
tuning/nl80211.h: Fix a few minor typos in comments.
src/cpu/abstract_cpu.cpp | 2 +-
src/main.cpp | 2 +-
src/process/do_process.cpp | 2 +-
src/tuning/nl80211.h | 6 +++---
4 files changed, 6 insertions(+), 6 deletions(-)
--
1.7.10.4
9 years, 9 months
[PATCH 1/2] Updates to support Android platform
by Rajagopal Venkat
This patch adds following minor changes to prepare powertop
to support Android platform.
- add missing HAVE_CONFIG_H conditional check.
- remove un-used ethtool_cmd_speed_set and ethtool_cmd_speed
functions.
- minimize dependency on exception handling in catch blocks.
These changes will not affect powertop functionality.
Signed-off-by: Rajagopal Venkat <rajagopal.venkat(a)linaro.org>
---
src/devices/ahci.cpp | 4 ++--
src/devices/alsa.cpp | 4 ++--
src/devices/network.cpp | 16 ----------------
src/lib.cpp | 2 +-
src/main.cpp | 2 ++
src/process/do_process.cpp | 4 ++--
6 files changed, 9 insertions(+), 23 deletions(-)
diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp
index 1fe39c7..67ce06e 100644
--- a/src/devices/ahci.cpp
+++ b/src/devices/ahci.cpp
@@ -170,7 +170,7 @@ void ahci::start_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to start measurement for ahci device\n");
}
}
@@ -203,7 +203,7 @@ void ahci::end_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to end measurement for ahci device\n");
}
if (end_active < start_active)
end_active = start_active;
diff --git a/src/devices/alsa.cpp b/src/devices/alsa.cpp
index 4f5d3f9..a67780c 100644
--- a/src/devices/alsa.cpp
+++ b/src/devices/alsa.cpp
@@ -104,7 +104,7 @@ void alsa::start_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to start measurement for alsa device\n");
}
}
@@ -130,7 +130,7 @@ void alsa::end_measurement(void)
file.close();
}
catch (std::ios_base::failure &c) {
- fprintf(stderr, "%s\n", c.what());
+ fprintf(stderr, "Failed to end measurement for alsa device\n");
}
p = (end_active - start_active) / (0.001 + end_active + end_inactive - start_active - start_inactive) * 100.0;
diff --git a/src/devices/network.cpp b/src/devices/network.cpp
index b8a5c9c..ed9d7aa 100644
--- a/src/devices/network.cpp
+++ b/src/devices/network.cpp
@@ -55,22 +55,6 @@ extern "C" {
static map<string, class network *> nics;
-#ifdef DISABLE_TRYCATCH
-
-static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
- __u32 speed)
-{
-
- ep->speed = (__u16)speed;
- ep->speed_hi = (__u16)(speed >> 16);
-}
-
-static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
-{
- return (ep->speed_hi << 16) | ep->speed;
-}
-
-#endif
static void do_proc_net_dev(void)
{
diff --git a/src/lib.cpp b/src/lib.cpp
index 9838c0b..776a67b 100644
--- a/src/lib.cpp
+++ b/src/lib.cpp
@@ -259,7 +259,7 @@ void format_watts(double W, char *buffer, unsigned int len)
if (W < 0.0001)
sprintf(buffer, _(" 0 mW"));
- while (mbstowcs(NULL,buffer,0) < len)
+ while (mbstowcs(NULL,buffer,len) < len)
strcat(buffer, " ");
}
diff --git a/src/main.cpp b/src/main.cpp
index 1815075..dc49dba 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -42,7 +42,9 @@
#include "perf/perf.h"
#include "perf/perf_bundle.h"
#include "lib.h"
+#ifdef HAVE_CONFIG_H
#include "../config.h"
+#endif
#include "devices/device.h"
diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
index eaef7f1..c9d6b0b 100644
--- a/src/process/do_process.cpp
+++ b/src/process/do_process.cpp
@@ -869,7 +869,7 @@ void process_update_display(void)
if (!show_power)
strcpy(power, " ");
sprintf(name, "%s", all_power[i]->type());
- while (mbstowcs(NULL,name,0) < 14) strcat(name, " ");
+ while (mbstowcs(NULL,name,20) < 14) strcat(name, " ");
if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0)
@@ -882,7 +882,7 @@ void process_update_display(void)
else
sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units());
}
- while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " ");
+ while (mbstowcs(NULL,usage,20) < 14) strcat(usage, " ");
sprintf(events, "%5.1f", all_power[i]->events());
if (!all_power[i]->show_events())
events[0] = 0;
--
1.7.9.5
9 years, 9 months
[PATCH] cpu: Fix typo on freq_class
by Namhyung Kim
s/cpu_even_req/cpu_even_freq/
Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
src/cpu/cpu.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index cc37748..96e3888 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -385,7 +385,7 @@ static const char *freq_class(int line)
if (line & 1) {
return "cpu_odd_freq";
}
- return "cpu_even_req";
+ return "cpu_even_freq";
}
static int has_state_level(class abstract_cpu *acpu, int state, int line)
--
1.7.9.2
9 years, 9 months
[PATCH] report: Try /etc/lsb-release for OS information
by Namhyung Kim
Ubuntu doesn't provide /etc/{system,redhat,os}-release but
/etc/lsb-release file. Since it's present on any LSB (Linux Standard
Base) compliant distributions, it'd better to try to read it.
To this end, change read_os_release to receive an additional argument
to find the right line - in this case it's "DISTRIB_DESCRIPTION".
Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
src/report.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/report.cpp b/src/report.cpp
index 6776b30..085e81b 100644
--- a/src/report.cpp
+++ b/src/report.cpp
@@ -83,12 +83,11 @@ string cpu_model(void)
return "";
}
-static string read_os_release(const string &filename)
+static string read_os_release(const string &filename, const char *pname)
{
ifstream file;
char content[4096];
char *c;
- const char *pname = "PRETTY_NAME=";
string os("");
file.open(filename.c_str(), ios::in);
@@ -160,7 +159,9 @@ static void system_info(void)
if (str.length() < 1)
str = read_sysfs_string("/etc/redhat-release");
if (str.length() < 1)
- str = read_os_release("/etc/os-release");
+ str = read_os_release("/etc/os-release", "PRETTY_NAME=");
+ if (str.length() < 1)
+ str = read_os_release("/etc/lsb-release", "DISTRIB_DESCRIPTION=");
if (reporttype) {
fprintf(reportout.http_report, "<tr class=\"system_even\"><td>OS Information</td><td>%s</td></tr>\n",
--
1.7.9.2
9 years, 9 months
Powertop doesn't detects sleeping ARM cores
by Igor Zhbanov
Hello!
When you start the PowerTOP on a "cold" ARM phone with several cores and low CPU average
some cores could be powered down. It is very frequent situation on ARM platform to dynamically
turn cores on/off to save power.
And when the PowerTOP scans /proc/cpuinfo file in enumerate_cpus() function, it will see
only one working core, so PowerTOP calls handle_one_cpu(...) only once and sets number of CPUs to 1.
So the PowerTOP will not register trace events for other cores.
Later when the system load (during the lifetime of PowerTOP) increases, the Linux kernel powers-up
additional cores. But the PowerTOP will not catch events for them.
I thought about scanning the /sys/devices/system/cpu/ directory for finding out how many CPUs
the system has. But the problem is that the directories for CPUs in offline mode doesn't provide
needed subdirectories cpuidle/ and topology/ (also it misses some files in cpufreq/ directory).
The only way to enable these directories is to (temporarily?) turn the core on.
This could be done e.g. by writing 1 to cpu/cpuX/online.
But I'm not sure how long the core will stay online before the kernel turns it off again because of
low load. On my phone this happens in a less than a second.
Another possible way is to scan /sys/.../cpu/ for the number of CPUs in the system,
register trace events for all that CPUs (by the way, is it possible to register a trace event
for the core that is now off?), sleep for the needed amount of time as usual, and before
the processing of data, temporarily turn every core on to find out information about it.
Or the PowerTOP could remember which cores was turned on before the testing, turn it all on,
read needed info, turn some cores off to restore the state of the system and begin test.
Or it could scan /sys/.../cpu/ with some interval (1 second) instead of just sleeping,
and grab the information about new cores brought online.
By the way, the PowerTOP scans /proc/ directory twice -- once before the start and once after
to get information about processes (to provide more information from trace events).
But if some process starts after the PowerTOP begins to sleep, and dies before the sleep ends,
then the PowerTOP will be unable to get information about that process (e.g. command line).
So the PowerTOP will know only its PID and shortened version of the command line (task->comm[16]).
I have a patch adding scanning of /proc/ capabilities to the PowerTOP. I use this /proc/ scanner
in MALI supporting patch, because MALI provides only the PID of the process in their events,
and that is not enough to know about the process. It needs more discussion so I will send the patch
little later. But I want to notice, that it could be useful for the rest of the PowerTOP too
to catch that processes. (The best solution will be to catch the process exit, but that event
provides only short task->comm[16]).
Anyway, the PowerTOP could do more instead of just sleeping.
What do you think?
Thank you.
--
Best regards,
Igor Zhbanov,
Expert Software Engineer,
phone: +7 (495) 797 25 00 ext 3806
e-mail: i.zhbanov(a)samsung.com
ASWG, Moscow R&D center, Samsung Electronics
12 Dvintsev street, building 1
127018, Moscow, Russian Federation
9 years, 9 months