[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1386765443-26966-63-git-send-email-alexander.shishkin@linux.intel.com>
Date: Wed, 11 Dec 2013 14:37:14 +0200
From: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc: Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
David Ahern <dsahern@...il.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Jiri Olsa <jolsa@...hat.com>, Mike Galbraith <efault@....de>,
Namhyung Kim <namhyung@...il.com>,
Paul Mackerras <paulus@...ba.org>,
Stephane Eranian <eranian@...gle.com>,
Andi Kleen <ak@...ux.intel.com>,
Adrian Hunter <adrian.hunter@...el.com>
Subject: [PATCH v0 62/71] perf inject: Cut Instruction Tracing samples
From: Adrian Hunter <adrian.hunter@...el.com>
After decoding Instruction Tracing samples, the
Instruction Tracing data is no longer needed
(having been replaced by synthesized events)
so cut it out.
Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
---
tools/perf/builtin-inject.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index feeeb56..ed2b48f 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -32,6 +32,7 @@ struct perf_inject {
u64 bytes_written;
struct list_head samples;
struct itrace_synth_opts itrace_synth_opts;
+ char event_copy[PERF_SAMPLE_MAX_SIZE];
};
struct event_entry {
@@ -143,6 +144,28 @@ static int perf_event__repipe(struct perf_tool *tool,
return perf_event__repipe_synth(tool, event);
}
+static union perf_event *
+perf_inject__cut_itrace_sample(struct perf_inject *inject,
+ union perf_event *event,
+ struct perf_sample *sample)
+{
+ size_t sz1 = sample->itrace_sample.data - (void *)event;
+ size_t sz2 = event->header.size - sample->itrace_sample.size - sz1;
+ union perf_event *ev = (union perf_event *)inject->event_copy;
+
+ if (sz1 > event->header.size || sz2 > event->header.size ||
+ sz1 + sz2 > event->header.size ||
+ sz1 < sizeof(struct perf_event_header) + sizeof(u64))
+ return event;
+
+ memcpy(ev, event, sz1);
+ memcpy((void *)ev + sz1, (void *)event + event->header.size - sz2, sz2);
+ ev->header.size = sz1 + sz2;
+ ((u64 *)((void *)ev + sz1))[-1] = 0;
+
+ return ev;
+}
+
typedef int (*inject_handler)(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
@@ -155,6 +178,9 @@ static int perf_event__repipe_sample(struct perf_tool *tool,
struct perf_evsel *evsel,
struct machine *machine)
{
+ struct perf_inject *inject = container_of(tool, struct perf_inject,
+ tool);
+
if (evsel->handler) {
inject_handler f = evsel->handler;
return f(tool, event, sample, evsel, machine);
@@ -162,6 +188,9 @@ static int perf_event__repipe_sample(struct perf_tool *tool,
build_id__mark_dso_hit(tool, event, sample, evsel, machine);
+ if (inject->itrace_synth_opts.set && sample->itrace_sample.size)
+ event = perf_inject__cut_itrace_sample(inject, event, sample);
+
return perf_event__repipe_synth(tool, event);
}
--
1.8.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists