Seg Fault due to function format_watts in file src/lib.cpp
by Ganapati Bhat
Dear All,
I was compiling powertop as an Android external module and using the option
powertop --html. However, there used to be a segmentation fault. When i
looked into it, I observed that in the function format_watts in
src/lib.cpp, the last argument to mbstows was zero. By changing the
argument to len, which is itself an argument to the function format_watts,
powertop worked properly? Does this also happen on an x86 machine? ( I am
unable to verify this due to some problems in my laptop which I have not
yet resolved.) If not then can someone explain to me why is it happening in
the case of android?
Thanks and Regards,
Ganapati
9 years, 1 month
[PATCH 0/8] Power Top RAPL interface v04
by Srinivas Pandruvada
This patch adds RAPL interface to powertop. RAPL can give energy consumed for a domain. For
client platform, domain are "PKG", "PP0" and "PP1". For servers "PKG", "DRAM" and "PP0".
PP0 refers to CPU energy comsumtion and PP1 refers to GPUs. DRAM is for DRAM in servers only.
Powertop estimates how much power CPU and GPU is consuming based on the measured power and
load. This patch splits this into the following:
- Actual CPU/GPU power reported by RAPL
- DRAM power for servers
- Remaining as "misc" usage for CPU/GPU
As more domain are getting added, this patch creates a parent/child relationship for CPU/GPU.
This way when new domains are added these files don't need change. Only inherit CPU/GPU class,
and implement virtual method for consumed power.
v04 changes:
Rebase with the latest git tree
Add MSR access error message from previous commit to lib.cpp MSR api
"_("Model-specific registers (MSR) not found (try enabling CONFIG_X86_MSR)"
v03 changes:
close fd when pread/pwrite fails.
v02 changes:
Addressed review comments
Moved MSR handling to library
Added interface to get the first CPU in a package
Fix error in reading RAPL when system has multiple packages
Srinivas Pandruvada (8):
Common read/write MSR API
Use MSR Lib MSR functions
RAPL Interface
cpu device as parent class
Interface to get first cpu
Added PP0 RAPL domain for CPU
Add RAPL DRAM domain
Add RAPL PP1 domain for GPU
src/Makefile.am | 4 +-
src/cpu/cpu.cpp | 16 ++
src/cpu/cpu.h | 1 +
src/cpu/cpu_rapl_device.cpp | 74 +++++
src/cpu/cpu_rapl_device.h | 57 ++++
src/cpu/cpudevice.cpp | 14 +
src/cpu/cpudevice.h | 6 +-
src/cpu/dram_rapl_device.cpp | 75 +++++
src/cpu/dram_rapl_device.h | 57 ++++
src/cpu/intel_cpus.cpp | 23 +-
src/cpu/rapl/rapl_interface.cpp | 611 ++++++++++++++++++++++++++++++++++++++++
src/cpu/rapl/rapl_interface.h | 85 ++++++
src/devices/gpu_rapl_device.cpp | 70 +++++
src/devices/gpu_rapl_device.h | 57 ++++
src/devices/i915-gpu.cpp | 21 ++
src/devices/i915-gpu.h | 6 +-
src/lib.cpp | 65 +++++
src/lib.h | 3 +-
18 files changed, 1222 insertions(+), 23 deletions(-)
create mode 100644 src/cpu/cpu_rapl_device.cpp
create mode 100644 src/cpu/cpu_rapl_device.h
create mode 100644 src/cpu/dram_rapl_device.cpp
create mode 100644 src/cpu/dram_rapl_device.h
create mode 100644 src/cpu/rapl/rapl_interface.cpp
create mode 100644 src/cpu/rapl/rapl_interface.h
create mode 100644 src/devices/gpu_rapl_device.cpp
create mode 100644 src/devices/gpu_rapl_device.h
--
1.7.11.7
9 years, 2 months
[PATCH 0/8] Power Top RAPL interface v03
by Srinivas Pandruvada
This patch adds RAPL interface to powertop. RAPL can give energy consumed for a domain. For
client platform, domain are "PKG", "PP0" and "PP1". For servers "PKG", "DRAM" and "PP0".
PP0 refers to CPU energy comsumtion and PP1 refers to GPUs. DRAM is for DRAM in servers only.
Powertop estimates how much power CPU and GPU is consuming based on the measured power and
load. This patch splits this into the following:
- Actual CPU/GPU power reported by RAPL
- DRAM power for servers
- Remaining as "misc" usage for CPU/GPU
As more domain are getting added, this patch creates a parent/child relationship for CPU/GPU.
This way when new domains are added these files don't need change. Only inherit CPU/GPU class,
and implement virtual method for consumed power.
v03 changes:
close fd when pread/pwrite fails.
v02 changes:
Addressed review comments
Moved MSR handling to library
Added interface to get the first CPU in a package
Fix error in reading RAPL when system has multiple packages
Srinivas Pandruvada (8):
Common read/write MSR API
Use MSR Lib MSR functions
RAPL Interface
cpu device as parent class
Interface to get first cpu
Added PP0 RAPL domain for CPU
Add RAPL DRAM domain
Add RAPL PP1 domain for GPU
src/Makefile.am | 4 +-
src/cpu/cpu.cpp | 16 ++
src/cpu/cpu.h | 1 +
src/cpu/cpu_rapl_device.cpp | 74 +++++
src/cpu/cpu_rapl_device.h | 57 ++++
src/cpu/cpudevice.cpp | 14 +
src/cpu/cpudevice.h | 6 +-
src/cpu/dram_rapl_device.cpp | 75 +++++
src/cpu/dram_rapl_device.h | 57 ++++
src/cpu/intel_cpus.cpp | 23 +-
src/cpu/rapl/rapl_interface.cpp | 611 ++++++++++++++++++++++++++++++++++++++++
src/cpu/rapl/rapl_interface.h | 85 ++++++
src/devices/gpu_rapl_device.cpp | 70 +++++
src/devices/gpu_rapl_device.h | 57 ++++
src/devices/i915-gpu.cpp | 21 ++
src/devices/i915-gpu.h | 6 +-
src/lib.cpp | 61 ++++
src/lib.h | 3 +-
18 files changed, 1218 insertions(+), 23 deletions(-)
create mode 100644 src/cpu/cpu_rapl_device.cpp
create mode 100644 src/cpu/cpu_rapl_device.h
create mode 100644 src/cpu/dram_rapl_device.cpp
create mode 100644 src/cpu/dram_rapl_device.h
create mode 100644 src/cpu/rapl/rapl_interface.cpp
create mode 100644 src/cpu/rapl/rapl_interface.h
create mode 100644 src/devices/gpu_rapl_device.cpp
create mode 100644 src/devices/gpu_rapl_device.h
--
1.7.11.7
9 years, 2 months
[PATCH 0/8] Power Top RAPL interface v02
by Srinivas Pandruvada
This patch adds RAPL interface to powertop. RAPL can give energy consumed for a domain. For
client platform, domain are "PKG", "PP0" and "PP1". For servers "PKG", "DRAM" and "PP0".
PP0 refers to CPU energy comsumtion and PP1 refers to GPUs. DRAM is for DRAM in servers only.
Powertop estimates how much power CPU and GPU is consuming based on the measured power and
load. This patch splits this into the following:
- Actual CPU/GPU power reported by RAPL
- DRAM power for servers
- Remaining as "misc" usage for CPU/GPU
As more domain are getting added, this patch creates a parent/child relationship for CPU/GPU.
This way when new domains are added these files don't need change. Only inherit CPU/GPU class,
and implement virtual method for consumed power.
v02 changes:
Addressed review comments
Moved MSR handling to library
Added interface to get the first CPU in a package
Fix error in reading RAPL when system has multiple packages
Srinivas Pandruvada (8):
Common read/write MSR API
Use MSR Lib MSR functions
RAPL Interface
cpu device as parent class
Interface to get first cpu
Added PP0 RAPL domain for CPU
Add RAPL DRAM domain
Add RAPL PP1 domain for GPU
src/Makefile.am | 4 +-
src/cpu/cpu.cpp | 16 ++
src/cpu/cpu.h | 1 +
src/cpu/cpu_rapl_device.cpp | 74 +++++
src/cpu/cpu_rapl_device.h | 57 ++++
src/cpu/cpudevice.cpp | 14 +
src/cpu/cpudevice.h | 6 +-
src/cpu/dram_rapl_device.cpp | 75 +++++
src/cpu/dram_rapl_device.h | 57 ++++
src/cpu/intel_cpus.cpp | 23 +-
src/cpu/rapl/rapl_interface.cpp | 611 ++++++++++++++++++++++++++++++++++++++++
src/cpu/rapl/rapl_interface.h | 85 ++++++
src/devices/gpu_rapl_device.cpp | 70 +++++
src/devices/gpu_rapl_device.h | 57 ++++
src/devices/i915-gpu.cpp | 21 ++
src/devices/i915-gpu.h | 6 +-
src/lib.cpp | 61 ++++
src/lib.h | 3 +-
18 files changed, 1218 insertions(+), 23 deletions(-)
create mode 100644 src/cpu/cpu_rapl_device.cpp
create mode 100644 src/cpu/cpu_rapl_device.h
create mode 100644 src/cpu/dram_rapl_device.cpp
create mode 100644 src/cpu/dram_rapl_device.h
create mode 100644 src/cpu/rapl/rapl_interface.cpp
create mode 100644 src/cpu/rapl/rapl_interface.h
create mode 100644 src/devices/gpu_rapl_device.cpp
create mode 100644 src/devices/gpu_rapl_device.h
--
1.7.11.7
9 years, 2 months
[PATCH 0/5] Power Top RAPL interface
by Srinivas Pandruvada
This patch adds RAPL interface to powertop. RAPL can give energy consumed for a domain. For
client platform, domain are "PKG", "PP0" and "PP1". For servers "PKG", "DRAM" and "PP0".
PP0 refers to CPU energy comsumtion and PP1 refers to GPUs. DRAM is for DRAM in servers only.
Powertop estimates how much power CPU and GPU is consuming based on the measured power and
load. This patch splits this into the following:
- Actual CPU/GPU power reported by RAPL
- DRAM power for servers
- Remaining as "misc" usage for CPU/GPU
As more domain are getting added, this patch creates a parent/child relationship for CPU/GPU.
This way when new domains are added these files don't need change. Only inherit CPU/GPU class,
and implement virtual method for consumed power.
Srinivas Pandruvada (5):
RAPL Interface
cpu device as parent class
Added PP0 RAPL domain for CPU
Add RAPL DRAM domain
Add RAPL PP1 domain for GPU
src/Makefile.am | 4 +-
src/cpu/cpu.cpp | 16 +
src/cpu/cpu_rapl_device.cpp | 70 +++++
src/cpu/cpu_rapl_device.h | 56 ++++
src/cpu/cpudevice.cpp | 14 +
src/cpu/cpudevice.h | 6 +-
src/cpu/dram_rapl_device.cpp | 71 +++++
src/cpu/dram_rapl_device.h | 56 ++++
src/cpu/rapl/rapl_interface.cpp | 662 ++++++++++++++++++++++++++++++++++++++++
src/cpu/rapl/rapl_interface.h | 87 ++++++
src/devices/gpu_rapl_device.cpp | 70 +++++
src/devices/gpu_rapl_device.h | 57 ++++
src/devices/i915-gpu.cpp | 21 ++
src/devices/i915-gpu.h | 6 +-
14 files changed, 1193 insertions(+), 3 deletions(-)
create mode 100644 src/cpu/cpu_rapl_device.cpp
create mode 100644 src/cpu/cpu_rapl_device.h
create mode 100644 src/cpu/dram_rapl_device.cpp
create mode 100644 src/cpu/dram_rapl_device.h
create mode 100644 src/cpu/rapl/rapl_interface.cpp
create mode 100644 src/cpu/rapl/rapl_interface.h
create mode 100644 src/devices/gpu_rapl_device.cpp
create mode 100644 src/devices/gpu_rapl_device.h
--
1.7.11.7
9 years, 2 months
[PATCH] cpu: allow for more package than core cstates
by Kristen Carlson Accardi
Change reporting code to walk package, then core, the cpu to determine max
number of cstate vs. just walking the logical cpus.
change display function to obtain max cstate num the same way.
---
src/cpu/cpu.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 55 insertions(+), 13 deletions(-)
diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index afe6a8c..9e075bd 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -402,20 +402,64 @@ static const char * fill_state_line(class abstract_cpu *acpu, int state, int lin
return "-EINVAL";
}
+static int get_cstates_num(void)
+{
+ unsigned int package, core, cpu;
+ class abstract_cpu *_package, * _core, * _cpu;
+ unsigned int i;
+ int cstates_num;
+
+ for (package = 0, cstates_num = 0;
+ package < system_level.children.size(); package++) {
+ _package = system_level.children[package];
+ if (_package == NULL)
+ continue;
+
+ /* walk package cstates and get largest cstates number */
+ for (i = 0; i < _package->cstates.size(); i++)
+ cstates_num = std::max(cstates_num,
+ (_package->cstates[i])->line_level);
+
+ /*
+ * for each core in this package, walk core cstates and get
+ * largest cstates number
+ */
+ for (core = 0; core < _package->children.size(); core++) {
+ _core = _package->children[core];
+ if (_core == NULL)
+ continue;
+
+ for (i = 0; i < _core->cstates.size(); i++)
+ cstates_num = std::max(cstates_num,
+ (_core->cstates[i])->line_level);
+
+ /*
+ * for each core, walk the logical cpus in case
+ * there is are more linux cstates than hw cstates
+ */
+ for (cpu = 0; cpu < _core->children.size(); cpu++) {
+ _cpu = _core->children[cpu];
+ if (_cpu == NULL)
+ continue;
+
+ for (i = 0; i < _cpu->cstates.size(); i++)
+ cstates_num = std::max(cstates_num,
+ (_cpu->cstates[i])->line_level);
+ }
+ }
+ }
+
+ return cstates_num;
+}
+
void report_display_cpu_cstates(void)
{
char buffer[512], buffer2[512];
unsigned int package, core, cpu;
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);
- }
+ cstates_num = get_cstates_num();
report.begin_section(SECTION_CPUIDLE);
report.add_header("Processor Idle state report");
@@ -644,17 +688,15 @@ void impl_w_display_cpu_states(int state)
int line, loop, cstates_num, pstates_num;
class abstract_cpu *_package, * _core, * _cpu;
int ctr = 0;
- unsigned int i, j;
+ unsigned int i;
- for (i = 0, cstates_num = 0, pstates_num = 0; i < all_cpus.size(); i++) {
+ cstates_num = get_cstates_num();
+
+ for (i = 0, pstates_num = 0; i < all_cpus.size(); i++) {
if (!all_cpus[i])
continue;
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) {
--
1.7.11.7
9 years, 2 months
[PATCH] cpu: add support for new package states
by Kristen Carlson Accardi
The next generation Intel cpu supports package states c8/c9/c10.
Add the code to read the relevant MSR counters.
---
src/cpu/cpu.cpp | 4 ++++
src/cpu/intel_cpus.cpp | 21 +++++++++++++++++++++
src/cpu/intel_cpus.h | 7 +++++++
3 files changed, 32 insertions(+)
diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index 9e075bd..0a6d4dc 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -78,7 +78,11 @@ static class abstract_cpu * new_package(int package, int cpu, char * vendor, int
case 0x3A: /* IVB */
case 0x3C:
case 0x3D: /* IVB Xeon */
+ has_c2c7_res = 1;
+ ret = new class nhm_package;
+ break;
case 0x45: /* Next Gen Intel Core Processor */
+ has_c8c9c10_res = 1;
has_c2c7_res = 1;
ret = new class nhm_package;
break;
diff --git a/src/cpu/intel_cpus.cpp b/src/cpu/intel_cpus.cpp
index 2b78d31..f50bc0b 100644
--- a/src/cpu/intel_cpus.cpp
+++ b/src/cpu/intel_cpus.cpp
@@ -42,6 +42,7 @@
int has_c2c7_res;
+int has_c8c9c10_res;
@@ -248,6 +249,11 @@ void nhm_package::measurement_start(void)
c6_before = get_msr(number, MSR_PKG_C6_RESIDENCY);
if (has_c2c7_res)
c7_before = get_msr(number, MSR_PKG_C7_RESIDENCY);
+ if (has_c8c9c10_res) {
+ c8_before = get_msr(number, MSR_PKG_C8_RESIDENCY);
+ c9_before = get_msr(number, MSR_PKG_C9_RESIDENCY);
+ c10_before = get_msr(number, MSR_PKG_C10_RESIDENCY);
+ }
tsc_before = get_msr(first_cpu, MSR_TSC);
if (has_c2c7_res)
@@ -257,6 +263,11 @@ void nhm_package::measurement_start(void)
insert_cstate("pkg c6", "C6 (pc6)", 0, c6_before, 1);
if (has_c2c7_res)
insert_cstate("pkg c7", "C7 (pc7)", 0, c7_before, 1);
+ if (has_c8c9c10_res) {
+ insert_cstate("pkg c8", "C8 (pc8)", 0, c8_before, 1);
+ insert_cstate("pkg c9", "C9 (pc9)", 0, c9_before, 1);
+ insert_cstate("pkg c10", "C10 (pc10)", 0, c10_before, 1);
+ }
}
void nhm_package::measurement_end(void)
@@ -276,6 +287,11 @@ void nhm_package::measurement_end(void)
c6_after = get_msr(number, MSR_PKG_C6_RESIDENCY);
if (has_c2c7_res)
c7_after = get_msr(number, MSR_PKG_C7_RESIDENCY);
+ if (has_c8c9c10_res) {
+ c8_after = get_msr(number, MSR_PKG_C8_RESIDENCY);
+ c9_after = get_msr(number, MSR_PKG_C9_RESIDENCY);
+ c10_after = get_msr(number, MSR_PKG_C10_RESIDENCY);
+ }
tsc_after = get_msr(first_cpu, MSR_TSC);
gettimeofday(&stamp_after, NULL);
@@ -289,6 +305,11 @@ void nhm_package::measurement_end(void)
finalize_cstate("pkg c6", 0, c6_after, 1);
if (has_c2c7_res)
finalize_cstate("pkg c7", 0, c7_after, 1);
+ if (has_c8c9c10_res) {
+ finalize_cstate("pkg c8", 0, c8_after, 1);
+ finalize_cstate("pkg c9", 0, c9_after, 1);
+ finalize_cstate("pkg c10", 0, c10_after, 1);
+ }
for (i = 0; i < children.size(); i++)
if (children[i])
diff --git a/src/cpu/intel_cpus.h b/src/cpu/intel_cpus.h
index a51a6d1..64d74f2 100644
--- a/src/cpu/intel_cpus.h
+++ b/src/cpu/intel_cpus.h
@@ -37,6 +37,9 @@
#define MSR_PKG_C3_RESIDENCY 0x3F8
#define MSR_PKG_C6_RESIDENCY 0x3F9
#define MSR_PKG_C7_RESIDENCY 0x3FA
+#define MSR_PKG_C8_RESIDENCY 0x630
+#define MSR_PKG_C9_RESIDENCY 0x631
+#define MSR_PKG_C10_RESIDENCY 0x632
#define MSR_CORE_C3_RESIDENCY 0x3FC
#define MSR_CORE_C6_RESIDENCY 0x3FD
#define MSR_CORE_C7_RESIDENCY 0x3FE
@@ -49,6 +52,9 @@ private:
uint64_t c3_before, c3_after;
uint64_t c6_before, c6_after;
uint64_t c7_before, c7_after;
+ uint64_t c8_before, c8_after;
+ uint64_t c9_before, c9_after;
+ uint64_t c10_before, c10_after;
uint64_t tsc_before, tsc_after;
uint64_t last_stamp;
@@ -118,6 +124,7 @@ public:
extern int has_c2c7_res;
+extern int has_c8c9c10_res;
class i965_core: public cpu_core
{
--
1.7.11.7
9 years, 2 months
How to make powertop auto-tun when AC power is unpluged?
by 陳韋任 (Wei-Ren Chen)
Hi all,
powertop is a great tool, and I love it. However, there is a place I
would like to know if it can be improved or done. When the AC power is
off, I always have to turn on those tunable options shown in powertop
to save power. Is it possible to make powertop do that automatically
for me?
T.I.A.
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
9 years, 3 months