lkml.org 
[lkml]   [2015]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 6/9] perf,tools: Dump per-sample freq in report -D
Date
From: Kan Liang <kan.liang@intel.com>

The group read results of TSC/ASTATE/MSTATE event can be used to
calculate the frequency during each sampling period.
Show it in report -D.

Here is an example:

$ perf record -e
'{ref-cycles,core_misc/tsc/,core_misc/power-mperf/,core_misc/power-aperf/}:S'
--running-time -a ~/tchain_edit

Here is one sample from perf report -D

18 506413677835 0x3f1d8 [0x90]: PERF_RECORD_SAMPLE(IP, 0x1): 8/8:
0xffffffff810cba6d period: 62219 addr: 0
... sample_read:
...... time enabled 000000000025a464
...... time running 000000000025a464
.... group nr 4
..... id 00000000000001a0, value 000000000008a605
..... id 00000000000001e2, value 0000000000565ac5
..... id 0000000000000222, value 0000000000079bc8
..... id 0000000000000262, value 0000000000068d69
..... TSC_MHz 2294
..... AVG_MHz 174
..... Bzy_MHz 2663

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
tools/perf/util/session.c | 40 +++++++++++++++++++++++++++++++++++-----
tools/perf/util/session.h | 4 ++++
2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index ed9dc25..6a142d8 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -851,8 +851,14 @@ static void perf_evlist__print_tstamp(struct perf_evlist *evlist,
printf("%" PRIu64 " ", sample->time);
}

-static void sample_read__printf(struct perf_sample *sample, u64 read_format)
+static void sample_read__printf(struct perf_evlist *evlist,
+ struct perf_sample *sample,
+ u64 read_format)
{
+ struct perf_evsel *evsel;
+ struct perf_sample_id *sid;
+ u64 tsc = 0, aperf = 0, mperf = 0;
+
printf("... sample_read:\n");

if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
@@ -875,10 +881,33 @@ static void sample_read__printf(struct perf_sample *sample, u64 read_format)
printf("..... id %016" PRIx64
", value %016" PRIx64 "\n",
value->id, value->value);
+
+ if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
+ sid = perf_evlist__id2sid(evlist, value->id);
+ evsel = sid->evsel;
+ if ((evsel != NULL) &&
+ (evsel->attr.type == PERF_TYPE_CORE_MISC_FREE)) {
+ if (evsel->attr.config == PERF_POWER_APERF)
+ aperf = value->value;
+ if (evsel->attr.config == PERF_POWER_MPERF)
+ mperf = value->value;
+ if (evsel->attr.config == PERF_TSC)
+ tsc = value->value;
+ }
+ }
}
} else
printf("..... id %016" PRIx64 ", value %016" PRIx64 "\n",
sample->read.one.id, sample->read.one.value);
+
+ if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
+ if (tsc > 0)
+ printf("..... TSC_MHz %lu\n", (1000 * tsc) / sample->read.time_running);
+ if (aperf > 0)
+ printf("..... AVG_MHz %lu\n", (1000 * aperf) / sample->read.time_running);
+ if ((tsc > 0) && (aperf > 0) && (mperf > 0))
+ printf("..... Bzy_MHz %lu\n", (1000 * tsc / aperf * mperf) / sample->read.time_running);
+ }
}

static void dump_event(struct perf_evlist *evlist, union perf_event *event,
@@ -899,8 +928,8 @@ static void dump_event(struct perf_evlist *evlist, union perf_event *event,
event->header.size, perf_event__name(event->header.type));
}

-static void dump_sample(struct perf_evsel *evsel, union perf_event *event,
- struct perf_sample *sample)
+static void dump_sample(struct perf_evlist *evlist, struct perf_evsel *evsel,
+ union perf_event *event, struct perf_sample *sample)
{
u64 sample_type;

@@ -938,7 +967,7 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event,
printf("... transaction: %" PRIx64 "\n", sample->transaction);

if (sample_type & PERF_SAMPLE_READ)
- sample_read__printf(sample, evsel->attr.read_format);
+ sample_read__printf(evlist, sample, evsel->attr.read_format);
}

static struct machine *machines__find_for_cpumode(struct machines *machines,
@@ -1053,11 +1082,12 @@ static int machines__deliver_event(struct machines *machines,

switch (event->header.type) {
case PERF_RECORD_SAMPLE:
- dump_sample(evsel, event, sample);
if (evsel == NULL) {
++evlist->stats.nr_unknown_id;
return 0;
}
+ dump_sample(evlist, evsel, event, sample);
+
if (machine == NULL) {
++evlist->stats.nr_unprocessable_samples;
return 0;
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index b44afc7..220cfb3 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -42,6 +42,10 @@ struct perf_session {
#define PRINT_IP_OPT_ONELINE (1<<4)
#define PRINT_IP_OPT_SRCLINE (1<<5)

+#define PERF_POWER_APERF 1
+#define PERF_POWER_MPERF 2
+#define PERF_TSC 5
+
struct perf_tool;

struct perf_session *perf_session__new(struct perf_data_file *file,
--
1.8.3.1


\
 
 \ /
  Last update: 2015-07-17 06:01    [W:0.233 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site