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 7/9] perf,tools: save APERF/MPERF/TSC in struct perf_sample
Date
From: Kan Liang <kan.liang@intel.com>

Save APERF/MPERF/TSC in struct perf_sample, so the following sample
process function can easily handle it.

Signed-off-by: Kan Liang <kan.liang@intel.com>
---
tools/perf/util/event.h | 3 +++
tools/perf/util/session.c | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+)

diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index c53f363..5a5431f 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -191,6 +191,9 @@ struct perf_sample {
u64 data_src;
u32 flags;
u16 insn_len;
+ u64 tsc;
+ u64 aperf;
+ u64 mperf;
void *raw_data;
struct ip_callchain *callchain;
struct branch_stack *branch_stack;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 6a142d8..bffa58b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1005,6 +1005,8 @@ static int deliver_sample_value(struct perf_evlist *evlist,
struct machine *machine)
{
struct perf_sample_id *sid = perf_evlist__id2sid(evlist, v->id);
+ struct perf_evsel *evsel;
+ u64 nr = 0;

if (sid) {
sample->id = v->id;
@@ -1017,6 +1019,24 @@ static int deliver_sample_value(struct perf_evlist *evlist,
return 0;
}

+ if (perf_evsel__is_group_leader(sid->evsel)) {
+ evsel = sid->evsel;
+ evlist__for_each_continue(evlist, evsel) {
+ if ((evsel->leader != sid->evsel) ||
+ (++nr >= sample->read.group.nr))
+ break;
+
+ if (evsel->attr.type == PERF_TYPE_CORE_MISC_FREE) {
+ if (evsel->attr.config == PERF_POWER_APERF)
+ sample->aperf = sample->read.group.values[nr].value;
+ if (evsel->attr.config == PERF_POWER_MPERF)
+ sample->mperf = sample->read.group.values[nr].value;
+ if (evsel->attr.config == PERF_TSC)
+ sample->tsc = sample->read.group.values[nr].value;
+ }
+ }
+ }
+
return tool->sample(tool, event, sample, sid->evsel, machine);
}

--
1.8.3.1


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