Skip to contentSkip to conversation

Power Top RAPL interface v04

PATCH Applied Srinivas Pandruvada 3 participants 11 messages Apr 15, 2013 – Apr 19, 2013

lore
Share & tools
lore

Srinivas Pandruvada

author
#0 lore raw

cover Power Top RAPL interface v04

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
Signature · 1 line
1.7.11.7
author
#1 lore raw

PATCH 1/8 Common read/write MSR API

Added two new interfaces:
extern int read_msr(int cpu, uint64_t offset, uint64_t *value); extern int write_msr(int cpu, uint64_t offset, uint64_t value);

This way all MSR interface can use this instead of reimplementing.

Signed-off-by Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
 src/lib.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/lib.h   |  3 ++-
 2 files changed, 67 insertions(+), 1 deletion(-)
src/lib.cpp +65 -0
index 723517a..028f893 100644
@@ -56,6 +56,7 @@ extern "C" {
 #include <limits>
 #include <math.h>
 #include <ncurses.h>
+#include <fcntl.h>
 
 static int kallsyms_read = 0;
 
@@ -450,3 +451,67 @@ int get_user_input(char *buf, unsigned sz)
 	/* to distinguish between getnstr error and empty line */
 	return ret || strlen(buf);
 }
+
+int read_msr(int cpu, uint64_t offset, uint64_t *value)
+{
+	ssize_t retval;
+	uint64_t msr;
+	int fd;
+	char msr_path[256];
+
+	fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
+
+	if (access(msr_path, R_OK) != 0){
+		fd = sprintf(msr_path, "/dev/msr%d", cpu);
+
+		if (access(msr_path, R_OK) != 0){
+			fprintf(stderr,
+			 _("Model-specific registers (MSR)\
+			 not found (try enabling CONFIG_X86_MSR).\n"));
+			return -1;
+		}
+	}
+
+	fd = open(msr_path, O_RDONLY);
+	if (fd < 0)
+		return -1;
+	retval = pread(fd, &msr, sizeof msr, offset);
+	close(fd);
+	if (retval != sizeof msr) {
+		return -1;
+	}
+	*value = msr;
+
+	return retval;
+}
+
+int write_msr(int cpu, uint64_t offset, uint64_t value)
+{
+	ssize_t retval;
+	int fd;
+	char msr_path[256];
+
+	fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
+
+	if (access(msr_path, R_OK) != 0){
+		fd = sprintf(msr_path, "/dev/msr%d", cpu);
+
+		if (access(msr_path, R_OK) != 0){
+			fprintf(stderr,
+			 _("Model-specific registers (MSR)\
+			 not found (try enabling CONFIG_X86_MSR).\n"));
+			return -1;
+		}
+	}
+
+	fd = open(msr_path, O_WRONLY);
+	if (fd < 0)
+		return -1;
+	retval = pwrite(fd, &value, sizeof value, offset);
+	close(fd);
+	if (retval != sizeof value) {
+		return -1;
+	}
+
+	return retval;
+}
src/lib.h +2 -1
index de2de5a..2b0e5f5 100644
@@ -74,5 +74,6 @@ typedef void (*callback)(const char*);
 extern void process_directory(const char *d_name, callback fn);
 extern int utf_ok;
 extern int get_user_input(char *buf, unsigned sz);
-
+extern int read_msr(int cpu, uint64_t offset, uint64_t *value);
+extern int write_msr(int cpu, uint64_t offset, uint64_t value);
 #endif
Signature · 1 line
1.7.11.7
author
#2 lore raw

PATCH 2/8 Use MSR Lib MSR functions

In reply to Srinivas Pandruvada

MSR read is implemented in lib.c. Use this API instead.

Signed-off-by Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
 src/cpu/intel_cpus.cpp | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)
src/cpu/intel_cpus.cpp +4 -19
index d17a605..d1205b2 100644
@@ -50,30 +50,15 @@ static uint64_t get_msr(int cpu, uint64_t offset)
 {
 	ssize_t retval;
 	uint64_t msr;
-	int fd;
-	char msr_path[256];
 
-	fd = sprintf(msr_path, "/dev/cpu/%d/msr", cpu);
-
-	if (access(msr_path, R_OK) != 0){
-		fd = sprintf(msr_path, "/dev/msr%d", cpu);
-
-		if (access(msr_path, R_OK) != 0){
-			fprintf(stderr, _("Model-specific registers (MSR) not found (try enabling CONFIG_X86_MSR).\n"));
-			exit(-2);
-		}
-	}
-
-	fd = open(msr_path, O_RDONLY);
-
-	retval = pread(fd, &msr, sizeof msr, offset);
-	if (retval != sizeof msr) {
+	retval = read_msr(cpu, offset, &msr);
+	if (retval < 0) {
 		reset_display();
-		fprintf(stderr, _("pread cpu%d 0x%llx : "), cpu, (unsigned long long)offset);
+		fprintf(stderr, _("read_msr cpu%d 0x%llx : "), cpu, (unsigned long long)offset);
 		fprintf(stderr, "%s\n", strerror(errno));
 		exit(-2);
 	}
-	close(fd);
+
 	return msr;
 }
 
Signature · 1 line
1.7.11.7
author
#3 lore raw

PATCH 3/8 RAPL Interface

In reply to Srinivas Pandruvada

Added RAPL interface class. This provides methods to get the status of RAPL domains and get energy and power status.

Signed-off-by Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
 src/Makefile.am                 |   3 +-
 src/cpu/rapl/rapl_interface.cpp | 611 ++++++++++++++++++++++++++++++++++++++++
 src/cpu/rapl/rapl_interface.h   |  85 ++++++
 3 files changed, 698 insertions(+), 1 deletion(-)
 create mode 100644 src/cpu/rapl/rapl_interface.cpp
 create mode 100644 src/cpu/rapl/rapl_interface.h
src/Makefile.am +2 -1
index 398b8a7..0983b51 100644
@@ -31,7 +31,8 @@ powertop_SOURCES = parameters/persistent.cpp parameters/learn.cpp parameters/par
 		report/report-formatter-base.cpp report/report-formatter-base.h \
 		report/report-formatter-csv.cpp report/report-formatter-csv.h \
 		report/report-formatter-html.cpp report/report-formatter-html.h \
-		main.cpp css.h powertop.css cpu/intel_gpu.cpp
+		main.cpp css.h powertop.css cpu/intel_gpu.cpp \
+		cpu/rapl/rapl_interface.cpp
 
 
 powertop_CXXFLAGS = -fno-omit-frame-pointer -fstack-protector -Wall -Wshadow -Wformat $(NCURSES_CFLAGS) $(PCIUTILS_CFLAGS) $(LIBNL_CFLAGS) $(GLIB2_CFLAGS)
src/cpu/rapl/rapl_interface.cpp new file +611 -0

611 lines not on this page · raw message

src/cpu/rapl/rapl_interface.h new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
1.7.11.7
author
#4 lore raw

PATCH 4/8 cpu device as parent class

In reply to Srinivas Pandruvada

Added members and methods so that it can have children. Other cpu type device can inherit and overide functionality.
If there are children, the power_usage method will not include the power reported by children, as they will be reporting as its own device.

Signed-off-by Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
 src/cpu/cpudevice.cpp | 14 ++++++++++++++
 src/cpu/cpudevice.h   |  6 +++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
src/cpu/cpudevice.cpp +14 -0
index 48fbcf5..371d8a8 100644
@@ -40,12 +40,20 @@ cpudevice::cpudevice(const char *classname, const char *dev_name, class abstract
 	r_consumption_index = get_result_index("cpu-consumption");;
 }
 
+const char * cpudevice::device_name(void)
+{
+	if (child_devices.size())
+		return "CPU misc";
+	else
+		return "CPU use";
+}
 
 double cpudevice::power_usage(struct result_bundle *result, struct parameter_bundle *bundle)
 {
 	double power;
 	double factor;
 	double _utilization;
+	double child_power;
 
 	power = 0;
 	factor = get_parameter_value(wake_index, bundle);
@@ -58,6 +66,12 @@ double cpudevice::power_usage(struct result_bundle *result, struct parameter_bun
 
 	power += _utilization * factor;
 
+	for (unsigned int i = 0; i < child_devices.size(); ++i) {
+		child_power = child_devices[i]->power_usage(result, bundle);
+		if ((power - child_power) > 0.0)
+			power -= child_power;
+	}
+
 	return power;
 }
 
src/cpu/cpudevice.h +5 -1
index 6a5636f..841a101 100644
@@ -34,6 +34,7 @@ using namespace std;
 #include "cpu.h"
 
 class cpudevice: public device {
+protected:
 	char _class[128];
 	char _cpuname[128];
 
@@ -44,15 +45,18 @@ class cpudevice: public device {
 	int r_wake_index;
 	int r_consumption_index;
 
+	vector<device *>child_devices;
+
 public:
 	cpudevice(const char *classname = "cpu", const char *device_name = "cpu0", class abstract_cpu *_cpu = NULL);
 	virtual const char * class_name(void) { return _class;};
 
-	virtual const char * device_name(void) {return "CPU use";};
+	virtual const char * device_name(void);
 
 	virtual double power_usage(struct result_bundle *result, struct parameter_bundle *bundle);
 	virtual bool show_in_list(void) {return false;};
 	virtual double	utilization(void); /* percentage */
+	void add_child(device *dev_ptr) { child_devices.push_back(dev_ptr);}
 };
 
 
Signature · 1 line
1.7.11.7
author
#5 lore raw

PATCH 5/8 Interface to get first cpu

In reply to Srinivas Pandruvada

Added get interface to get the first cpu number for this cpu device.

Signed-off-by Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
 src/cpu/cpu.h | 1 +
 1 file changed, 1 insertion(+)
src/cpu/cpu.h +1 -0
index a863b49..18ebeb7 100644
@@ -105,6 +105,7 @@ public:
 	class abstract_cpu *parent;
 
 
+	int	get_first_cpu() { return first_cpu; }
 	void	set_number(int _number, int cpu) {this->number = _number; this->first_cpu = cpu;};
 	void	set_type(const char* _name) {this->name = _name;};
 	int	get_number(void) { return number; };
Signature · 1 line
1.7.11.7
author
#6 lore raw

PATCH 6/8 Added PP0 RAPL domain for CPU

In reply to Srinivas Pandruvada

Added PP0 RAPL domain as core CPU power. This will display as "cpu core" in the device stats.

Signed-off-by Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
 src/Makefile.am             |  2 +-
 src/cpu/cpu.cpp             |  9 ++++++
 src/cpu/cpu_rapl_device.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++
 src/cpu/cpu_rapl_device.h   | 57 ++++++++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 src/cpu/cpu_rapl_device.cpp
 create mode 100644 src/cpu/cpu_rapl_device.h
src/Makefile.am +1 -1
index 0983b51..fde079a 100644
@@ -32,7 +32,7 @@ powertop_SOURCES = parameters/persistent.cpp parameters/learn.cpp parameters/par
 		report/report-formatter-csv.cpp report/report-formatter-csv.h \
 		report/report-formatter-html.cpp report/report-formatter-html.h \
 		main.cpp css.h powertop.css cpu/intel_gpu.cpp \
-		cpu/rapl/rapl_interface.cpp
+		cpu/rapl/rapl_interface.cpp cpu/cpu_rapl_device.cpp
 
 
 powertop_CXXFLAGS = -fno-omit-frame-pointer -fstack-protector -Wall -Wshadow -Wformat $(NCURSES_CFLAGS) $(PCIUTILS_CFLAGS) $(LIBNL_CFLAGS) $(GLIB2_CFLAGS)
src/cpu/cpu.cpp +9 -0
index 0a6d4dc..685f067 100644
@@ -31,6 +31,7 @@
 #include <unistd.h>
 #include "cpu.h"
 #include "cpudevice.h"
+#include "cpu_rapl_device.h"
 #include "intel_cpus.h"
 #include "../parameters/parameters.h"
 
@@ -59,6 +60,8 @@ static class abstract_cpu * new_package(int package, int cpu, char * vendor, int
 {
 	class abstract_cpu *ret = NULL;
 	class cpudevice *cpudev;
+	class cpu_rapl_device *cpu_rapl_dev;
+
 	char packagename[128];
 	if (strcmp(vendor, "GenuineIntel") == 0) {
 		if (family == 6)
@@ -99,6 +102,12 @@ static class abstract_cpu * new_package(int package, int cpu, char * vendor, int
 	sprintf(packagename, _("cpu package %i"), cpu);
 	cpudev = new class cpudevice(_("cpu package"), packagename, ret);
 	all_devices.push_back(cpudev);
+
+	sprintf(packagename, _("cpu rapl package %i"), cpu);
+	cpu_rapl_dev = new class cpu_rapl_device(cpudev, _("cpu rapl package"), packagename, ret);
+	if (cpu_rapl_dev->device_present())
+		all_devices.push_back(cpu_rapl_dev);
+
 	return ret;
 }
 
src/cpu/cpu_rapl_device.cpp new file +74 -0

74 lines not on this page · raw message

src/cpu/cpu_rapl_device.h new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
1.7.11.7
author
#7 lore raw

PATCH 7/8 Add RAPL DRAM domain

In reply to Srinivas Pandruvada

Added DRAM RAPL domain as core CPU power. This will display as "DRAM" in the device stats, if present.

Signed-off-by Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
 src/Makefile.am              |  3 +-
 src/cpu/cpu.cpp              |  7 +++++
 src/cpu/dram_rapl_device.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++
 src/cpu/dram_rapl_device.h   | 57 +++++++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 src/cpu/dram_rapl_device.cpp
 create mode 100644 src/cpu/dram_rapl_device.h
src/Makefile.am +2 -1
index fde079a..cc4b6d7 100644
@@ -32,7 +32,8 @@ powertop_SOURCES = parameters/persistent.cpp parameters/learn.cpp parameters/par
 		report/report-formatter-csv.cpp report/report-formatter-csv.h \
 		report/report-formatter-html.cpp report/report-formatter-html.h \
 		main.cpp css.h powertop.css cpu/intel_gpu.cpp \
-		cpu/rapl/rapl_interface.cpp cpu/cpu_rapl_device.cpp
+		cpu/rapl/rapl_interface.cpp cpu/cpu_rapl_device.cpp \
+		cpu/dram_rapl_device.cpp
 
 
 powertop_CXXFLAGS = -fno-omit-frame-pointer -fstack-protector -Wall -Wshadow -Wformat $(NCURSES_CFLAGS) $(PCIUTILS_CFLAGS) $(LIBNL_CFLAGS) $(GLIB2_CFLAGS)
src/cpu/cpu.cpp +7 -0
index 685f067..5d0db28 100644
@@ -32,6 +32,7 @@
 #include "cpu.h"
 #include "cpudevice.h"
 #include "cpu_rapl_device.h"
+#include "dram_rapl_device.h"
 #include "intel_cpus.h"
 #include "../parameters/parameters.h"
 
@@ -61,6 +62,7 @@ static class abstract_cpu * new_package(int package, int cpu, char * vendor, int
 	class abstract_cpu *ret = NULL;
 	class cpudevice *cpudev;
 	class cpu_rapl_device *cpu_rapl_dev;
+	class dram_rapl_device *dram_rapl_dev;
 
 	char packagename[128];
 	if (strcmp(vendor, "GenuineIntel") == 0) {
@@ -108,6 +110,11 @@ static class abstract_cpu * new_package(int package, int cpu, char * vendor, int
 	if (cpu_rapl_dev->device_present())
 		all_devices.push_back(cpu_rapl_dev);
 
+	sprintf(packagename, _("dram rapl package %i"), cpu);
+	dram_rapl_dev = new class dram_rapl_device(cpudev, _("dram rapl package"), packagename, ret);
+	if (dram_rapl_dev->device_present())
+		all_devices.push_back(dram_rapl_dev);
+
 	return ret;
 }
 
src/cpu/dram_rapl_device.cpp new file +75 -0

75 lines not on this page · raw message

src/cpu/dram_rapl_device.h new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
1.7.11.7
author
#8 lore raw

PATCH 8/8 Add RAPL PP1 domain for GPU

In reply to Srinivas Pandruvada

Added RAPL PP1 domain as GPU core power. This will show "GPU misc" and "GPU core" in device stats, if PP1 domain is present.

Signed-off-by Srinivas Pandruvada <srinivas.pandruvada(a)linux.intel.com>
---
 src/Makefile.am                 |  2 +-
 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 +++-
 5 files changed, 154 insertions(+), 2 deletions(-)
 create mode 100644 src/devices/gpu_rapl_device.cpp
 create mode 100644 src/devices/gpu_rapl_device.h
src/Makefile.am +1 -1
index cc4b6d7..7c37356 100644
@@ -33,7 +33,7 @@ powertop_SOURCES = parameters/persistent.cpp parameters/learn.cpp parameters/par
 		report/report-formatter-html.cpp report/report-formatter-html.h \
 		main.cpp css.h powertop.css cpu/intel_gpu.cpp \
 		cpu/rapl/rapl_interface.cpp cpu/cpu_rapl_device.cpp \
-		cpu/dram_rapl_device.cpp
+		cpu/dram_rapl_device.cpp devices/gpu_rapl_device.cpp
 
 
 powertop_CXXFLAGS = -fno-omit-frame-pointer -fstack-protector -Wall -Wshadow -Wformat $(NCURSES_CFLAGS) $(PCIUTILS_CFLAGS) $(LIBNL_CFLAGS) $(GLIB2_CFLAGS)
src/devices/gpu_rapl_device.cpp new file +70 -0

70 lines not on this page · raw message

src/devices/gpu_rapl_device.h new file +57 -0

57 lines not on this page · raw message

src/devices/i915-gpu.cpp +21 -0
index bcc07cc..a2cfaa5 100644
@@ -37,6 +37,7 @@ using namespace std;
 #include "i915-gpu.h"
 #include "../parameters/parameters.h"
 #include "../process/powerconsumer.h"
+#include "gpu_rapl_device.h"
 
 #include <string.h>
 #include <unistd.h>
@@ -47,6 +48,14 @@ i915gpu::i915gpu(): device()
 	rindex = get_result_index("gpu-operations");
 }
 
+const char * i915gpu::device_name(void)
+{
+	if (child_devices.size())
+		return "GPU misc";
+	else
+		return "GPU";
+}
+
 void i915gpu::start_measurement(void)
 {
 }
@@ -66,6 +75,7 @@ void create_i915_gpu(void)
 {
 	char filename[4096];
 	class i915gpu *gpu;
+	gpu_rapl_device *rapl_dev;
 
 	strcpy(filename, "/sys/kernel/debug/tracing/events/i915/i915_gem_ring_dispatch/format");
 
@@ -80,6 +90,10 @@ void create_i915_gpu(void)
 
 	gpu = new class i915gpu();
 	all_devices.push_back(gpu);
+
+	rapl_dev = new class gpu_rapl_device(gpu);
+	if (rapl_dev->device_present())
+		all_devices.push_back(rapl_dev);
 }
 
 
@@ -89,11 +103,18 @@ double i915gpu::power_usage(struct result_bundle *result, struct parameter_bundl
 	double power;
 	double factor;
 	double util;
+	double child_power;
 
 	power = 0;
 	factor = get_parameter_value(index, bundle);
 	util = get_result_value(rindex, result);
 
 	power += util * factor / 100.0;
+	for (unsigned int i = 0; i < child_devices.size(); ++i) {
+		child_power = child_devices[i]->power_usage(result, bundle);
+		if ((power - child_power) > 0.0)
+			power -= child_power;
+	}
+
 	return power;
 }
src/devices/i915-gpu.h +5 -1
index 25cf748..7653b94 100644
@@ -31,6 +31,8 @@
 class i915gpu: public device {
 	int index;
 	int rindex;
+	vector<device *>child_devices;
+
 public:
 
 	i915gpu();
@@ -42,10 +44,12 @@ public:
 
 	virtual const char * class_name(void) { return "GPU";};
 
-	virtual const char * device_name(void) { return "GPU";};
+	virtual const char * device_name(void);
 	virtual double power_usage(struct result_bundle *result, struct parameter_bundle *bundle);
 	virtual bool show_in_list(void) {return false;};
 	virtual const char * util_units(void) { return " ops/s"; };
+
+	virtual void add_child(device *dev_ptr) { child_devices.push_back(dev_ptr);}
 };
 
 extern void create_i915_gpu(void);
Signature · 1 line
1.7.11.7
#9 lore raw
In reply to Srinivas Pandruvada
Quoted 10 lines · 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

Quoted 4 lines

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.

Hello,
looks good to me. thanks.

any objections/inputs/etc. from list members are welcomed.

	-ss
Quoted 61 lines

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
Signature · 6 lines
1.7.11.7

_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop
Applied
#10 lore raw
Quoted 16 lines · On Mon, 15 Apr 2013 23:35:43 +0300 Sergey Senozhatsky…
Quoted 10 lines · 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

Quoted 4 lines

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.

Quoted 8 lines

Hello,
looks good to me. thanks.

any objections/inputs/etc. from list members are welcomed.

	-ss

Applied.

Thanks!