Skip to contentSkip to conversation

show energy consumption info in perf tool

PATCH In review Zhang Rui 2 participants 3 messages May 26, 2011 perf events

lore
Share & tools
lore

Zhang Rui

author
#0 lore raw

PATCH 3/3 show energy consumption info in perf tool

Introduce four new perf software events
PERF_COUNT_SW_PKG_ENERGY
PERF_COUNT_SW_CORE_ENERGY
PERF_COUNT_SW_UNCORE_ENERGY
and
PERF_COUNT_SW_DRAM_ENERGY

To use it, users can run
perf stat -e pkg-energy foo
to get the package energy consumption when running foo.

---
 tools/perf/design.txt          |    4 ++++
 tools/perf/util/parse-events.c |    8 ++++++++
 2 files changed, 12 insertions(+)
tools/perf/design.txt +4 -0
Index: linux-2.6/tools/perf/design.txt
===================================================================
@@ -139,6 +139,10 @@ enum sw_event_ids {
 	PERF_COUNT_SW_PAGE_FAULTS_MAJ	= 6,
 	PERF_COUNT_SW_ALIGNMENT_FAULTS	= 7,
 	PERF_COUNT_SW_EMULATION_FAULTS	= 8,
+	PERF_COUNT_SW_PKG_ENERGY	= 9,
+	PERF_COUNT_SW_CORE_ENERGY	= 10,
+	PERF_COUNT_SW_UNCORE_ENERGY	= 11,
+	PERF_COUNT_SW_DRAM_ENERGY	= 12,
 };
 
 Counters of the type PERF_TYPE_TRACEPOINT are available when the ftrace event
tools/perf/util/parse-events.c +8 -0
Index: linux-2.6/tools/perf/util/parse-events.c
===================================================================
@@ -50,6 +50,10 @@ static struct event_symbol event_symbols
   { CSW(CPU_MIGRATIONS),		"cpu-migrations",		"migrations"		},
   { CSW(ALIGNMENT_FAULTS),		"alignment-faults",		""			},
   { CSW(EMULATION_FAULTS),		"emulation-faults",		""			},
+  { CSW(PKG_ENERGY),			"pkg-energy",			""			},
+  { CSW(CORE_ENERGY),			"core-energy",			""			},
+  { CSW(UNCORE_ENERGY),			"uncore-energy",		""			},
+  { CSW(DRAM_ENERGY),			"dram-energy",			""			},
 };
 
 #define __PERF_EVENT_FIELD(config, name) \
@@ -82,6 +86,10 @@ static const char *sw_event_names[PERF_C
 	"major-faults",
 	"alignment-faults",
 	"emulation-faults",
+	"package-energy-consumption",
+	"core-energy-consumption",
+	"uncore-energy-consumption",
+	"dram-energy-consumption",
 };
 
 #define MAX_ALIASES 8
#1 lore raw
Quoted 11 lines · Zhang Rui

Introduce four new perf software events

PERF_COUNT_SW_PKG_ENERGY
PERF_COUNT_SW_CORE_ENERGY
PERF_COUNT_SW_UNCORE_ENERGY
and
PERF_COUNT_SW_DRAM_ENERGY

To use it, users can run
perf stat -e pkg-energy foo
to get the package energy consumption when running foo.

That's very interesting - being able to profile workloads by power/energy use looks like a *very* powerful feature.

Are you allowed to show us some sample output of the data? What's the granularity of this info? Say what is the output of:

perf stat -e pkg-energy -e core-energy -e uncore-energy -e dram-energy -a sleep 10

?

Also, have you tried something like:

perf record -a -e pkg-energy sleep 60

perf report

To see where most of the energy is used within a 1 minute interval?

Also, conceptually these are really hardware events, right?

Thanks,

Ingo

#2 lore raw
In reply to Zhang Rui
Quoted 11 lines · Zhang Rui

Introduce four new perf software events

PERF_COUNT_SW_PKG_ENERGY
PERF_COUNT_SW_CORE_ENERGY
PERF_COUNT_SW_UNCORE_ENERGY
and
PERF_COUNT_SW_DRAM_ENERGY

To use it, users can run
perf stat -e pkg-energy foo
to get the package energy consumption when running foo.

That's very interesting - being able to profile workloads by power/energy use looks like a *very* powerful feature.

Are you allowed to show us some sample output of the data? What's the granularity of this info? Say what is the output of:

perf stat -e pkg-energy -e core-energy -e uncore-energy -e dram-energy -a sleep 10

?

Also, have you tried something like:

perf record -a -e pkg-energy sleep 60

perf report

To see where most of the energy is used within a 1 minute interval?

Also, conceptually these are really hardware events, right?

Thanks,

Ingo