lkml.org 
[lkml]   [2015]   [Oct]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 15/57] perf tools: Add stat event read function
Date
Introducing perf_event__process_stat_event function to process
'struct perf_stat' data from stat event.

Link: http://lkml.kernel.org/n/tip-2bvpxxp60e0qqcsecohgeju3@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/stat.c | 23 +++++++++++++++++++++++
tools/perf/util/stat.h | 6 ++++++
2 files changed, 29 insertions(+)

diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 2d065d065b67..0369b4516c29 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -340,3 +340,26 @@ int perf_stat_process_counter(struct perf_stat_config *config,

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 *stat = &event->stat;
+ struct perf_evsel *counter;
+
+ count.val = stat->val;
+ count.ena = stat->ena;
+ count.run = stat->run;
+
+ counter = perf_evlist__id2evsel(session->evlist, stat->id);
+ if (!counter) {
+ pr_err("Failed to resolve counter for stat event.\n");
+ return -EINVAL;
+ }
+
+ *perf_counts(counter->counts, stat->cpu, stat->thread) = count;
+ counter->supported = true;
+ return 0;
+}
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 62448c8175d3..a61cb0a9f23a 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -89,4 +89,10 @@ void perf_evlist__reset_stats(struct perf_evlist *evlist);

int perf_stat_process_counter(struct perf_stat_config *config,
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
--
2.4.3


\
 
 \ /
  Last update: 2015-10-16 13:01    [W:0.283 / U:0.932 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site