提交 0ea0e355 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

perf tools: Add stat event read function

Introducing the perf_event__process_stat_event function to process a
'struct perf_stat' data from a stat event.
Signed-off-by: NJiri Olsa <jolsa@kernel.org>
Tested-by: NKan Liang <kan.liang@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1445784728-21732-17-git-send-email-jolsa@kernel.org
[ Renamed 'stat' parameter to 'st' to fix 'already defined' build error with older distros (e.g. RHEL6.7) ]
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 5796f8f0
...@@ -341,3 +341,26 @@ int perf_stat_process_counter(struct perf_stat_config *config, ...@@ -341,3 +341,26 @@ int perf_stat_process_counter(struct perf_stat_config *config,
return 0; return 0;
} }
int perf_event__process_stat_event(struct perf_tool *tool __maybe_unused,
union perf_event *event,
struct perf_session *session)
{
struct perf_counts_values count;
struct stat_event *st = &event->stat;
struct perf_evsel *counter;
count.val = st->val;
count.ena = st->ena;
count.run = st->run;
counter = perf_evlist__id2evsel(session->evlist, st->id);
if (!counter) {
pr_err("Failed to resolve counter for stat event.\n");
return -EINVAL;
}
*perf_counts(counter->counts, st->cpu, st->thread) = count;
counter->supported = true;
return 0;
}
...@@ -90,4 +90,10 @@ void perf_evlist__reset_stats(struct perf_evlist *evlist); ...@@ -90,4 +90,10 @@ void perf_evlist__reset_stats(struct perf_evlist *evlist);
int perf_stat_process_counter(struct perf_stat_config *config, int perf_stat_process_counter(struct perf_stat_config *config,
struct perf_evsel *counter); struct perf_evsel *counter);
struct perf_tool;
union perf_event;
struct perf_session;
int perf_event__process_stat_event(struct perf_tool *tool,
union perf_event *event,
struct perf_session *session);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册