[PATCH] csstoh.sh shell script fixes cross compiling issues
by Thomas Waldecker
From: Thomas Waldecker <thomas.waldecker(a)tqs.de>
Added the csstoh.sh shell script from Igor Zhbanov found here:
http://lists.01.org/pipermail/powertop/2012-July/000151.html
also patched the Makefile.am to use the csstoh.sh script.
The compiled csstoh binary doesn't work for cross compiling,
however Igors Patch never got applied upstream.
---
src/Makefile.am | 8 +++-----
src/csstoh.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 5 deletions(-)
create mode 100755 src/csstoh.sh
diff --git a/src/Makefile.am b/src/Makefile.am
index f60426a..a53d942 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,6 @@
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = -I ../m4
-noinst_PROGRAMS = csstoh
-csstoh_SOURCES = csstoh.c
-
sbin_PROGRAMS = powertop
nodist_powertop_SOURCES = css.h
@@ -48,6 +45,7 @@ AM_LDFLAGS = $(LIBS) $(NCURSES_LIBS) $(PCIUTILS_LIBS) $(LIBNL_LIBS) $(LIBZ_LIBS)
BUILT_SOURCES = css.h
CLEANFILES = css.h
-css.h: csstoh powertop.css
- ./csstoh "$(srcdir)"/powertop.css css.h
+css.h: powertop.css
+ chmod +x ./csstoh.sh
+ ./csstoh.sh "$(srcdir)"/powertop.css css.h
diff --git a/src/csstoh.sh b/src/csstoh.sh
new file mode 100755
index 0000000..5918d12
--- /dev/null
+++ b/src/csstoh.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# This program file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program in a file named COPYING; if not, write to the
+# Free Software Foundation, Inc,
+# 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301 USA
+# or just google for it.
+#
+# Written by Igor Zhbanov<i.zhbanov at samsung.com>
+
+
+if [ $# -lt 2 ]; then
+ echo "Usage: csstoh.sh cssfile header.h"
+ exit 1
+fi
+
+if [ ! -r $1 ]; then
+ echo "Can't find file $1"
+ exit 1
+fi
+
+if ! echo -n>$2; then
+ echo "Can't open file $2 for writing."
+ exit 1
+fi
+
+echo "#ifndef __INCLUDE_GUARD_CCS_H">> $2
+echo "#define __INCLUDE_GUARD_CCS_H">> $2
+echo>> $2
+echo "const char css[] = ">> $2
+
+sed -r 's/^(.*)$/\t\"\1\\n\"/' $1>> $2
+
+echo ";">> $2
+echo "#endif">> $2
--
1.7.9.5
9 years, 4 months
[PATCH] V2: Fix C states and P states presentation issue.
by Austin Zhang
If using '10' in this 'for' loop, for P states, once the processor
provides more than 10 P states, those additional ones cannot been
presented; and for C states, once the processor provides maximize
C states level more than 9, for example, it only has POLL, C1, C3,
C6, C10, the additional one like C10 also cannot be presented.
Now we get the loop numbers from the system information we had got
before.
Changes from V1:
Using std:max to simplify codes
Signed-off-by: Austin Zhang <zhang.austin(a)gmail.com>
---
src/cpu/cpu.cpp | 36 +++++++++++++++++++++++++++++-------
1 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index 7f3af69..1bae255 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -402,8 +402,16 @@ void report_display_cpu_cstates(void)
{
char buffer[512], buffer2[512];
unsigned int package, core, cpu;
- int line;
+ int line, cstates_num;
class abstract_cpu *_package, * _core, * _cpu;
+ unsigned int i, j;
+
+ for (i = 0, cstates_num = 0; i < all_cpus.size(); i++) {
+ if (all_cpus[i])
+ for (j = 0; j < all_cpus[i]->cstates.size(); j++)
+ cstates_num = std::max(cstates_num,
+ (all_cpus[i]->cstates[j])->line_level);
+ }
report.begin_section(SECTION_CPUIDLE);
report.add_header("Processor Idle state report");
@@ -421,7 +429,7 @@ void report_display_cpu_cstates(void)
if (!_core)
continue;
- for (line = LEVEL_HEADER; line < 10; line++) {
+ for (line = LEVEL_HEADER; line <= cstates_num; line++) {
bool first_cpu = true;
if (!_package->has_cstate_level(line))
@@ -628,14 +636,29 @@ void impl_w_display_cpu_states(int state)
char buffer[128];
char linebuf[1024];
unsigned int package, core, cpu;
- int line;
+ int line, loop, cstates_num, pstates_num;
class abstract_cpu *_package, * _core, * _cpu;
int ctr = 0;
+ unsigned int i, j;
+
+ for (i = 0, cstates_num = 0, pstates_num = 0; i < all_cpus.size(); i++) {
+ if (!all_cpus[i])
+ continue;
- if (state == PSTATE)
+ pstates_num = std::max<int>(pstates_num, all_cpus[i]->pstates.size());
+
+ for (j = 0; j < all_cpus[i]->cstates.size(); j++)
+ cstates_num = std::max(cstates_num,
+ (all_cpus[i]->cstates[j])->line_level);
+ }
+
+ if (state == PSTATE) {
win = get_ncurses_win("Frequency stats");
- else
+ loop = pstates_num;
+ } else {
win = get_ncurses_win("Idle stats");
+ loop = cstates_num;
+ }
if (!win)
return;
@@ -656,8 +679,7 @@ void impl_w_display_cpu_states(int state)
if (!_core->has_pstates() && state == PSTATE)
continue;
-
- for (line = LEVEL_HEADER; line < 10; line++) {
+ for (line = LEVEL_HEADER; line <= loop; line++) {
int first = 1;
ctr = 0;
linebuf[0] = 0;
--
1.7.5.4
9 years, 4 months
[PATCH] Do not call abstract_cpu::wiggle for GPU
by Jaroslav Škarvada
first_cpu is uninitialized there which results in:
open("/sys/devices/system/cpu/cpu1330597711/cpufreq/scaling_max_freq", O_RDONLY)
---
src/cpu/intel_cpus.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/cpu/intel_cpus.h b/src/cpu/intel_cpus.h
index 1949af1..752e8d0 100644
--- a/src/cpu/intel_cpus.h
+++ b/src/cpu/intel_cpus.h
@@ -158,5 +158,6 @@ public:
virtual char * fill_cstate_line(int line_nr, char *buffer, const char *separator);
virtual int has_pstate_level(int level) { return 0; };
virtual int has_pstates(void) { return 0; };
+ virtual void wiggle(void) { };
};
--
1.7.11.7
9 years, 5 months
[PATCH] main: Fix output when running workload
by Namhyung Kim
Currently one_measurement() function prints following message after
a successful run of the workload.
$ sudo powertop --html --workload="sleep 1"
Loaded 1 prior measurements
Preparing to take measurements
Measuring workload sleep 1.
Unknown issue running workload! <-- here
PowerTOP outputing using base filename powertop.html
It seems this was because it wrongly checks return value of system.
The return value of the system() call is the status of wait() call
so that it should be zero if things went well.
Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
src/main.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main.cpp b/src/main.cpp
index b22d11d..0883424 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -191,7 +191,7 @@ void one_measurement(int seconds, char *workload)
start_cpu_measurement();
if (workload && workload[0]) {
- if (!system(workload))
+ if (system(workload))
fprintf(stderr, _("Unknown issue running workload!\n"));
} else {
do_sleep(seconds);
--
1.7.9.2
9 years, 5 months
[PATCH] main: 'quiet' option does not take an argument
by Namhyung Kim
Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
src/main.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main.cpp b/src/main.cpp
index e6036ae..b22d11d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -77,7 +77,7 @@ static const struct option long_options[] =
{"time", optional_argument, NULL, 't'},
{"iteration", optional_argument, NULL, 'i'},
{"workload", optional_argument, NULL, 'w'},
- {"quiet", optional_argument, NULL, 'q'},
+ {"quiet", no_argument, NULL, 'q'},
{NULL, 0, NULL, 0}
};
--
1.7.9.2
9 years, 5 months
[PATCH 1/3] Suppress compiler warnings on write()
by Namhyung Kim
Modern linux distribution forces to check result of write() call.
It emits following warnings:
CXX calibrate/powertop-calibrate.o
calibrate/calibrate.cpp: In function ‘void* burn_disk(void*)’:
calibrate/calibrate.cpp:297: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result
...
CXX measurement/powertop-extech.o
measurement/extech.cpp: In member function ‘void extech_power_meter::measure()’:
measurement/extech.cpp:290: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result
Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
src/calibrate/calibrate.cpp | 3 ++-
src/measurement/extech.cpp | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/calibrate/calibrate.cpp b/src/calibrate/calibrate.cpp
index 5457cf8..2d4c1af 100644
--- a/src/calibrate/calibrate.cpp
+++ b/src/calibrate/calibrate.cpp
@@ -294,7 +294,8 @@ static void *burn_disk(void *dummy)
while (!stop_measurement) {
lseek(fd, 0, SEEK_SET);
- write(fd, buffer, 64*1024);
+ if (write(fd, buffer, 64*1024))
+ /* make gcc silent */;
fdatasync(fd);
}
close(fd);
diff --git a/src/measurement/extech.cpp b/src/measurement/extech.cpp
index 4e8bf8a..b9e95ca 100644
--- a/src/measurement/extech.cpp
+++ b/src/measurement/extech.cpp
@@ -287,7 +287,8 @@ extech_power_meter::extech_power_meter(const char *extech_name)
void extech_power_meter::measure(void)
{
/* trigger the extech to send data */
- write(fd, " ", 1);
+ if (write(fd, " ", 1) < 0)
+ return;
rate = extech_read(fd);
--
1.7.9.2
9 years, 5 months
[PATCH] tab_window: null members on construction
by Sergey Senozhatsky
introduce tab_window ctor and null memebers during construction. show_tab() may be
called before window_refresh() [which sets ypad_pos and xpad_pos to 0], causing prefresh()
call with uninit win->ypad_pos, win->xpad_pos args.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>
---
src/display.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/display.h b/src/display.h
index b450f8b..9af3ec0 100644
--- a/src/display.h
+++ b/src/display.h
@@ -53,6 +53,14 @@ public:
short int xpad_pos, ypad_pos;
WINDOW *win;
+ tab_window() {
+ cursor_pos = 0;
+ cursor_max = 0;
+ xpad_pos =0;
+ ypad_pos = 0;
+ win = NULL;
+ }
+
virtual void cursor_down(void) {
if (cursor_pos < cursor_max ) cursor_pos++; repaint();
} ;
9 years, 5 months
[PATCH 2/2] runtime_pm: register parameters
by Sergey Senozhatsky
register parameter during runtime_pmdevice() construction, making
call to get_parameter_value() in power_usage() valid.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>
---
src/devices/runtime_pm.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/devices/runtime_pm.cpp b/src/devices/runtime_pm.cpp
index 0d13cab..bbc3bf0 100644
--- a/src/devices/runtime_pm.cpp
+++ b/src/devices/runtime_pm.cpp
@@ -49,11 +49,11 @@ runtime_pmdevice::runtime_pmdevice(const char *_name, const char *path) : device
before_suspended_time = 0;
before_active_time = 0;
- after_suspended_time = 0;
+ after_suspended_time = 0;
after_active_time = 0;
-}
-
+ register_parameter(humanname);
+}
void runtime_pmdevice::start_measurement(void)
{
@@ -237,4 +237,4 @@ void create_all_runtime_pm_devices(void)
do_bus("spi");
do_bus("platform");
do_bus("i2c");
-}
\ No newline at end of file
+}
9 years, 5 months
[PATCH 1/2] parameters: fix uninitialized values in param/result getters
by Sergey Senozhatsky
-- get_param_index()/get_result_index() may be called for unknown parameter,
causing new map entry creation via operator[] access. it's not safe to check
returned pair->second value for newly created map entry, since there is no default
ctor for int type. use map::find() instead.
-- get_parameter_value(char *) now uses get_parameter_value(uint), which performs
parameters overflow detection and prevents illegal read. this one was affecting
power_device_sort(), returning garbage to compare function.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>
---
src/parameters/parameters.cpp | 40 ++++++++++++++++++++++++----------------
src/parameters/parameters.h | 2 +-
2 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/src/parameters/parameters.cpp b/src/parameters/parameters.cpp
index 1a89b14..936d789 100644
--- a/src/parameters/parameters.cpp
+++ b/src/parameters/parameters.cpp
@@ -44,11 +44,15 @@ static int maxresindex = 1;
int get_param_index(const char *name)
{
- int index;
- index = param_index[name];
- if (index == 0) {
- index = param_index[name] = ++maxindex;
- }
+ std::map<string, int>::iterator it;
+ int index = 0;
+
+ it = param_index.find(name);
+ if (it == param_index.end()) {
+ param_index[name] = ++maxindex;
+ index = maxindex;
+ } else
+ index = it->second;
if (index == 0)
printf("OH BLA\n");
@@ -57,11 +61,15 @@ int get_param_index(const char *name)
int get_result_index(const char *name)
{
- int index;
- index = result_index[name];
- if (index == 0) {
- index = result_index[name] = ++maxresindex;
- }
+ std::map<string, int>::iterator it;
+ int index = 0;
+
+ it = result_index.find(name);
+ if (it == result_index.end()) {
+ result_index[name] = ++maxresindex;
+ index = maxresindex;
+ } else
+ index = it->second;
return index;
}
@@ -101,16 +109,16 @@ void set_parameter_value(const char *name, double value, struct parameter_bundle
double get_parameter_value(const char *name, struct parameter_bundle *the_bundle)
{
unsigned int index;
-
index = get_param_index(name);
- if (index >= the_bundle->parameters.size()) {
- fprintf(stderr, "BUG: requesting unregistered parameter %s\n", name);
- }
- return the_bundle->parameters[index];
+ return get_parameter_value(index, the_bundle);
}
-double get_parameter_value(int index, struct parameter_bundle *the_bundle)
+double get_parameter_value(unsigned int index, struct parameter_bundle *the_bundle)
{
+ if (index >= the_bundle->parameters.size()) {
+ fprintf(stderr, "BUG: requesting unregistered parameter %d\n", index);
+ return 0;
+ }
return the_bundle->parameters[index];
}
diff --git a/src/parameters/parameters.h b/src/parameters/parameters.h
index a8c1154..bd9fee8 100644
--- a/src/parameters/parameters.h
+++ b/src/parameters/parameters.h
@@ -60,7 +60,7 @@ extern int get_result_index(const char *param);
extern void register_parameter(const char *name, double default_value = 0.00, double weight = 1.0);
extern double get_parameter_value(const char *name, struct parameter_bundle *bundle = &all_parameters);
-extern double get_parameter_value(int index, struct parameter_bundle *bundle = &all_parameters);
+extern double get_parameter_value(unsigned int index, struct parameter_bundle *bundle = &all_parameters);
extern void set_parameter_value(const char *name, double value, struct parameter_bundle *bundle = &all_parameters);
9 years, 5 months
[RFC] [PATCHv2 00/10] Code deduplication in cpu/*
by Ivan Shapovalov
This is a resend (unchanged but rebased) of the patch series about refactoring code
in cpu/* by deduplication. From this series, only the last bugfix patch has been applied
so far due to a code freeze.
Ivan Shapovalov (10):
Fix includes: do not include intel_cpus.h inside cpu.h
Deduplication: move is_turbo() function to lib
Deduplication: move all instances of account_freq() to abstract_cpu::account_freq()
Deduplication: remove nhm_cpu::account_freq() almost identical to abstract_cpu::account_freq()
Deduplication: remove nhm_{cpu,core,package}::change_effective_frequency() identical to cpu_{linux,core,package}::change_effective_frequency()
Deduplication: merge cpu_{core,linux,package}::change_effective_frequency() into abstract_cpu::change_effective_frequency()
Deduplication: remove {cpu,nhm}_core::calculate_freq() identical to abstract_cpu::calculate_freq()
Deduplication: remove nhm_package::calculate_freq() identical to cpu_package::calculate_freq()
Deduplication: properly merge cpu_package::calculate_freq() into abstract_cpu::calculate_freq()
Deduplication: merge go_idle()/go_unidle()/change_freq() overrides into abstract_cpu() class
9 years, 5 months