Skip to contentSkip to conversation

Add support for Intel GPU statistics

PATCH New Arjan van de Ven 1 participant 1 message Aug 5, 2012

lore
Share & tools
lore

Arjan van de Ven

author
#0 lore raw

PATCH v2 1/1 Add support for Intel GPU statistics

Quoted 1 line

From 6fd9783d4def5e4f6fc2647225a4cb34949afef9 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <arjan(a)linux.intel.com>
Date: Sun, 5 Aug 2012 10:04:02 -0700
Subject: [PATCH] Add support for Intel GPU statistics

As of the 3.5 kernel, the Intel GPUs report their C states (power gating) via sysfs. This patch will show them as part of the C state tab, arranged like a core inside package 0 (which matches physical topology)

Changes since v1: incorporated feedback from Sergey

---
 src/Makefile.am       |    2 +-
 src/cpu/cpu.cpp       |   33 +++++++++++++
 src/cpu/intel_cpus.h  |   23 +++++++++
 src/cpu/intel_gpu.cpp |  122 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 179 insertions(+), 1 deletions(-)
 create mode 100644 src/cpu/intel_gpu.cpp
src/Makefile.am +1 -1
index d0976fd..d233d85 100644
@@ -30,7 +30,7 @@ powertop_SOURCES = parameters/persistent.cpp parameters/learn.cpp parameters/par
 		calibrate/calibrate.h measurement/measurement.cpp measurement/power_supply.cpp \
 		measurement/measurement.h measurement/acpi.cpp measurement/sysfs.h measurement/sysfs.cpp \
 		measurement/acpi.h measurement/extech.cpp measurement/power_supply.h measurement/extech.h \
-		main.cpp css.h powertop.css
+		main.cpp css.h powertop.css cpu/intel_gpu.cpp
 
 
 powertop_CXXFLAGS = -fno-omit-frame-pointer -fstack-protector -Wall -Wshadow -Wformat $(NCURSES_CFLAGS) $(PCIUTILS_CFLAGS) $(LIBNL_CFLAGS) $(GLIB2_CFLAGS)
src/cpu/cpu.cpp +33 -0
index 63e48ee..0c36bae 100644
@@ -123,6 +123,16 @@ static class abstract_cpu * new_core(int core, int cpu, char * vendor, int famil
 	return ret;
 }
 
+static class abstract_cpu * new_i965_gpu(void)
+{
+	class abstract_cpu *ret = NULL;
+
+	ret = new class i965_core;
+	ret->childcount = 0;
+
+	return ret;
+}
+
 static class abstract_cpu * new_cpu(int number, char * vendor, int family, int model)
 {
 	class abstract_cpu * ret = NULL;
@@ -218,6 +228,26 @@ static void handle_one_cpu(unsigned int number, char *vendor, int family, int mo
 	all_cpus[number] = cpu;
 }
 
+static void handle_i965_gpu(void)
+{
+	unsigned int core_number = 0;
+	class abstract_cpu *package;
+
+
+	package = system_level.children[0];
+	
+	core_number = package->children.size();
+
+	if (package->children.size() <= core_number)
+		package->children.resize(core_number + 1, NULL);
+
+	if (!package->children[core_number]) {
+		package->children[core_number] = new_i965_gpu();
+		package->childcount++;
+	}
+}
+
+
 void enumerate_cpus(void)
 {
 	ifstream file;
@@ -288,6 +318,9 @@ void enumerate_cpus(void)
 
 	file.close();
 
+	if (access("/sys/class/drm/card0/power/rc6_residency_ms", R_OK) == 0)
+		handle_i965_gpu();
+
 	perf_events = new perf_power_bundle();
 
 	if (!perf_events->add_event("power:cpu_idle")){
src/cpu/intel_cpus.h +23 -0
index b69c5c6..1949af1 100644
@@ -137,3 +137,26 @@ public:
 
 
 extern int has_c2c7_res;
+
+class i965_core: public cpu_core
+{
+private:
+	uint64_t	rc6_before, rc6_after;
+	uint64_t	rc6p_before, rc6p_after;
+	uint64_t	rc6pp_before, rc6pp_after;
+	
+	struct timeval	before;
+	struct timeval	after;
+
+public:
+	virtual void	measurement_start(void);
+	virtual void	measurement_end(void);
+	virtual int     can_collapse(void) { return 0;};
+
+	virtual char *  fill_pstate_line(int line_nr, char *buffer);
+	virtual char *  fill_pstate_name(int line_nr, char *buffer);
+	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; };
+
+};
src/cpu/intel_gpu.cpp new file +122 -0

122 lines not on this page · raw message

Signature · 1 line
1.7.7.6