[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-e51f806198306a8ad7ae6e34d1af0716ef73da80@git.kernel.org>
Date: Fri, 22 Mar 2019 15:06:34 -0700
From: tip-bot for Jiri Olsa <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: peterz@...radead.org, tglx@...utronix.de, hpa@...or.com,
alexey.budankov@...ux.intel.com, adrian.hunter@...el.com,
jolsa@...nel.org, mingo@...nel.org,
alexander.shishkin@...ux.intel.com, linux-kernel@...r.kernel.org,
eranian@...gle.com, namhyung@...nel.org, ak@...ux.intel.com,
acme@...hat.com
Subject: [tip:perf/urgent] perf session: Add process callback to reader
object
Commit-ID: e51f806198306a8ad7ae6e34d1af0716ef73da80
Gitweb: https://git.kernel.org/tip/e51f806198306a8ad7ae6e34d1af0716ef73da80
Author: Jiri Olsa <jolsa@...nel.org>
AuthorDate: Fri, 8 Mar 2019 14:47:40 +0100
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Mon, 11 Mar 2019 11:56:03 -0300
perf session: Add process callback to reader object
Adding callback function to reader object so callers can process data in
different ways.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: Alexey Budankov <alexey.budankov@...ux.intel.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Stephane Eranian <eranian@...gle.com>
Link: http://lkml.kernel.org/r/20190308134745.5057-7-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/session.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index de777bdc0ed3..0ec34227bd60 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1847,10 +1847,17 @@ fetch_mmaped_event(struct perf_session *session,
#define NUM_MMAPS 128
#endif
+struct reader;
+
+typedef s64 (*reader_cb_t)(struct perf_session *session,
+ union perf_event *event,
+ u64 file_offset);
+
struct reader {
- int fd;
- u64 data_size;
- u64 data_offset;
+ int fd;
+ u64 data_size;
+ u64 data_offset;
+ reader_cb_t process;
};
static int
@@ -1921,7 +1928,7 @@ more:
size = event->header.size;
if (size < sizeof(struct perf_event_header) ||
- (skip = perf_session__process_event(session, event, file_pos)) < 0) {
+ (skip = rd->process(session, event, file_pos)) < 0) {
pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n",
file_offset + head, event->header.size,
event->header.type);
@@ -1947,12 +1954,20 @@ out:
return err;
}
+static s64 process_simple(struct perf_session *session,
+ union perf_event *event,
+ u64 file_offset)
+{
+ return perf_session__process_event(session, event, file_offset);
+}
+
static int __perf_session__process_events(struct perf_session *session)
{
struct reader rd = {
.fd = perf_data__fd(session->data),
.data_size = session->header.data_size,
.data_offset = session->header.data_offset,
+ .process = process_simple,
};
struct ordered_events *oe = &session->ordered_events;
struct perf_tool *tool = session->tool;
Powered by blists - more mailing lists