[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180124115143.14322-12-jolsa@kernel.org>
Date: Wed, 24 Jan 2018 12:51:33 +0100
From: Jiri Olsa <jolsa@...nel.org>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Ingo Molnar <mingo@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Namhyung Kim <namhyung@...nel.org>,
David Ahern <dsahern@...il.com>,
Andi Kleen <ak@...ux.intel.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Andy Lutomirski <luto@...capital.net>,
Arnaldo Carvalho de Melo <acme@...nel.org>
Subject: [PATCH 11/21] perf tools: Add perf_sample__parse function
Adding perf_sample__parse function to separate out
the parse sampling. It will be used later in the
patchset.
Link: http://lkml.kernel.org/n/tip-q4u4tp1jra0x5x3vly7wwvir@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/util/evsel.c | 47 +++++++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 20 deletions(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 0f62de48594e..5a95839994a1 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2045,8 +2045,9 @@ perf_event__check_size(union perf_event *event, unsigned int sample_size)
return 0;
}
-int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
- struct perf_sample *data)
+static int
+perf_sample__parse(struct perf_sample *data, struct perf_evsel *evsel,
+ union perf_event *event)
{
u64 type = evsel->attr.sample_type;
bool swapped = evsel->needs_swap;
@@ -2061,26 +2062,8 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
*/
union u64_swap u;
- memset(data, 0, sizeof(*data));
- data->cpu = data->pid = data->tid = -1;
- data->stream_id = data->id = data->time = -1ULL;
- data->period = evsel->attr.sample_period;
- data->cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
- data->misc = event->header.misc;
- data->id = -1ULL;
- data->data_src = PERF_MEM_DATA_SRC_NONE;
-
- if (event->header.type != PERF_RECORD_SAMPLE) {
- if (!evsel->attr.sample_id_all)
- return 0;
- return perf_evsel__parse_id_sample(evsel, event, data);
- }
-
array = event->sample.array;
- if (perf_event__check_size(event, evsel->sample_size))
- return -EFAULT;
-
if (type & PERF_SAMPLE_IDENTIFIER) {
data->id = *array;
array++;
@@ -2324,6 +2307,30 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
return 0;
}
+int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
+ struct perf_sample *data)
+{
+ memset(data, 0, sizeof(*data));
+ data->cpu = data->pid = data->tid = -1;
+ data->stream_id = data->id = data->time = -1ULL;
+ data->period = evsel->attr.sample_period;
+ data->cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
+ data->misc = event->header.misc;
+ data->id = -1ULL;
+ data->data_src = PERF_MEM_DATA_SRC_NONE;
+
+ if (event->header.type != PERF_RECORD_SAMPLE) {
+ if (!evsel->attr.sample_id_all)
+ return 0;
+ return perf_evsel__parse_id_sample(evsel, event, data);
+ }
+
+ if (perf_event__check_size(event, evsel->sample_size))
+ return -EFAULT;
+
+ return perf_sample__parse(data, evsel, event);
+}
+
int perf_evsel__parse_sample_timestamp(struct perf_evsel *evsel,
union perf_event *event,
u64 *timestamp)
--
2.13.6
Powered by blists - more mailing lists