blob: 8bd791cca008252300c33118effad8af7c0a2f7a [file] [log] [blame]
Tom Zanussi454c4072010-05-01 01:41:20 -05001/*
2 * builtin-inject.c
3 *
4 * Builtin inject command: Examine the live mode (stdin) event stream
5 * and repipe it to stdout while optionally injecting additional
6 * events into it.
7 */
8#include "builtin.h"
9
10#include "perf.h"
Andrew Vagin26a031e2012-08-07 16:56:04 +040011#include "util/color.h"
12#include "util/evlist.h"
13#include "util/evsel.h"
Tom Zanussi454c4072010-05-01 01:41:20 -050014#include "util/session.h"
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -020015#include "util/tool.h"
Tom Zanussi454c4072010-05-01 01:41:20 -050016#include "util/debug.h"
Andrew Vagin54a3cf52012-08-07 16:56:05 +040017#include "util/build-id.h"
Jiri Olsaf5fc14122013-10-15 16:27:32 +020018#include "util/data.h"
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +030019#include "util/auxtrace.h"
Stephane Eranian9b07e272015-11-30 10:02:21 +010020#include "util/jit.h"
Tom Zanussi454c4072010-05-01 01:41:20 -050021
Josh Poimboeuf4b6ab942015-12-15 09:39:39 -060022#include <subcmd/parse-options.h>
Tom Zanussi454c4072010-05-01 01:41:20 -050023
Andrew Vagin26a031e2012-08-07 16:56:04 +040024#include <linux/list.h>
Arnaldo Carvalho de Meloa43783a2017-04-18 10:46:11 -030025#include <errno.h>
Arnaldo Carvalho de Melo9607ad32017-04-19 15:49:18 -030026#include <signal.h>
Andrew Vagin26a031e2012-08-07 16:56:04 +040027
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -030028struct perf_inject {
Jiri Olsa34069122013-10-29 19:04:57 +010029 struct perf_tool tool;
Namhyung Kim1cb8bdc2014-08-12 15:40:37 +090030 struct perf_session *session;
Jiri Olsa34069122013-10-29 19:04:57 +010031 bool build_ids;
32 bool sched_stat;
Adrian Huntercd10b282015-04-30 17:37:26 +030033 bool have_auxtrace;
Adrian Hunterf56fb982015-09-25 16:15:55 +030034 bool strip;
Stephane Eranian9b07e272015-11-30 10:02:21 +010035 bool jit_mode;
Jiri Olsa34069122013-10-29 19:04:57 +010036 const char *input_name;
37 struct perf_data_file output;
38 u64 bytes_written;
Adrian Hunter73117302015-09-25 16:15:54 +030039 u64 aux_id;
Jiri Olsa34069122013-10-29 19:04:57 +010040 struct list_head samples;
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +030041 struct itrace_synth_opts itrace_synth_opts;
Andrew Vagin26a031e2012-08-07 16:56:04 +040042};
43
44struct event_entry {
45 struct list_head node;
46 u32 tid;
47 union perf_event event[0];
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -030048};
Tom Zanussi454c4072010-05-01 01:41:20 -050049
Adrian Huntercd17a9b2015-04-21 12:21:54 +030050static int output_bytes(struct perf_inject *inject, void *buf, size_t sz)
Tom Zanussi454c4072010-05-01 01:41:20 -050051{
Jiri Olsa34069122013-10-29 19:04:57 +010052 ssize_t size;
Tom Zanussi454c4072010-05-01 01:41:20 -050053
Adrian Huntercd17a9b2015-04-21 12:21:54 +030054 size = perf_data_file__write(&inject->output, buf, sz);
Jiri Olsa34069122013-10-29 19:04:57 +010055 if (size < 0)
56 return -errno;
Tom Zanussi454c4072010-05-01 01:41:20 -050057
Jiri Olsa34069122013-10-29 19:04:57 +010058 inject->bytes_written += size;
Tom Zanussi454c4072010-05-01 01:41:20 -050059 return 0;
60}
61
Adrian Huntercd17a9b2015-04-21 12:21:54 +030062static int perf_event__repipe_synth(struct perf_tool *tool,
63 union perf_event *event)
64{
65 struct perf_inject *inject = container_of(tool, struct perf_inject,
66 tool);
67
68 return output_bytes(inject, event, event->header.size);
69}
70
Arnaldo Carvalho de Melod704ebd2015-03-03 12:37:54 -030071static int perf_event__repipe_oe_synth(struct perf_tool *tool,
72 union perf_event *event,
73 struct ordered_events *oe __maybe_unused)
74{
75 return perf_event__repipe_synth(tool, event);
76}
77
Jiri Olsae12b2022016-03-10 17:41:13 +010078#ifdef HAVE_JITDUMP
Stephane Eranian9b07e272015-11-30 10:02:21 +010079static int perf_event__drop_oe(struct perf_tool *tool __maybe_unused,
80 union perf_event *event __maybe_unused,
81 struct ordered_events *oe __maybe_unused)
82{
83 return 0;
84}
85#endif
86
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -020087static int perf_event__repipe_op2_synth(struct perf_tool *tool,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020088 union perf_event *event,
Irina Tirdea1d037ca2012-09-11 01:15:03 +030089 struct perf_session *session
90 __maybe_unused)
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -020091{
Adrian Hunter63c2c9f2013-07-04 16:20:20 +030092 return perf_event__repipe_synth(tool, event);
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020093}
94
Adrian Hunter47c3d102013-07-04 16:20:21 +030095static int perf_event__repipe_attr(struct perf_tool *tool,
96 union perf_event *event,
97 struct perf_evlist **pevlist)
Arnaldo Carvalho de Melo10d0f082011-11-11 22:45:41 -020098{
Adrian Hunter89c97d92013-10-22 10:34:09 +030099 struct perf_inject *inject = container_of(tool, struct perf_inject,
100 tool);
Stephane Eranian1a1ed1b2012-05-15 13:28:11 +0200101 int ret;
Adrian Hunter47c3d102013-07-04 16:20:21 +0300102
103 ret = perf_event__process_attr(tool, event, pevlist);
Stephane Eranian1a1ed1b2012-05-15 13:28:11 +0200104 if (ret)
105 return ret;
106
Jiri Olsaa261e4a2014-06-05 18:51:44 +0200107 if (!inject->output.is_pipe)
Adrian Hunter89c97d92013-10-22 10:34:09 +0300108 return 0;
109
Adrian Hunter47c3d102013-07-04 16:20:21 +0300110 return perf_event__repipe_synth(tool, event);
Arnaldo Carvalho de Melo10d0f082011-11-11 22:45:41 -0200111}
112
Adrian Huntere31f0d02015-04-30 17:37:27 +0300113#ifdef HAVE_AUXTRACE_SUPPORT
114
115static int copy_bytes(struct perf_inject *inject, int fd, off_t size)
116{
117 char buf[4096];
118 ssize_t ssz;
119 int ret;
120
121 while (size > 0) {
122 ssz = read(fd, buf, min(size, (off_t)sizeof(buf)));
123 if (ssz < 0)
124 return -errno;
125 ret = output_bytes(inject, buf, ssz);
126 if (ret)
127 return ret;
128 size -= ssz;
129 }
130
131 return 0;
132}
133
Adrian Huntercd17a9b2015-04-21 12:21:54 +0300134static s64 perf_event__repipe_auxtrace(struct perf_tool *tool,
135 union perf_event *event,
Arnaldo Carvalho de Melob8f8eb82016-03-22 13:09:37 -0300136 struct perf_session *session)
Adrian Huntercd17a9b2015-04-21 12:21:54 +0300137{
138 struct perf_inject *inject = container_of(tool, struct perf_inject,
139 tool);
140 int ret;
141
Adrian Huntercd10b282015-04-30 17:37:26 +0300142 inject->have_auxtrace = true;
143
Adrian Hunter99fa2982015-04-30 17:37:25 +0300144 if (!inject->output.is_pipe) {
145 off_t offset;
146
147 offset = lseek(inject->output.fd, 0, SEEK_CUR);
148 if (offset == -1)
149 return -errno;
150 ret = auxtrace_index__auxtrace_event(&session->auxtrace_index,
151 event, offset);
152 if (ret < 0)
153 return ret;
154 }
155
Adrian Huntercd17a9b2015-04-21 12:21:54 +0300156 if (perf_data_file__is_pipe(session->file) || !session->one_mmap) {
157 ret = output_bytes(inject, event, event->header.size);
158 if (ret < 0)
159 return ret;
160 ret = copy_bytes(inject, perf_data_file__fd(session->file),
161 event->auxtrace.size);
162 } else {
163 ret = output_bytes(inject, event,
164 event->header.size + event->auxtrace.size);
165 }
166 if (ret < 0)
167 return ret;
168
169 return event->auxtrace.size;
170}
171
Adrian Huntere31f0d02015-04-30 17:37:27 +0300172#else
173
174static s64
175perf_event__repipe_auxtrace(struct perf_tool *tool __maybe_unused,
176 union perf_event *event __maybe_unused,
177 struct perf_session *session __maybe_unused)
178{
179 pr_err("AUX area tracing not supported\n");
180 return -EINVAL;
181}
182
183#endif
184
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200185static int perf_event__repipe(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200186 union perf_event *event,
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300187 struct perf_sample *sample __maybe_unused,
Adrian Hunter63c2c9f2013-07-04 16:20:20 +0300188 struct machine *machine __maybe_unused)
Arnaldo Carvalho de Melo640c03c2010-12-02 14:10:21 -0200189{
Adrian Hunter63c2c9f2013-07-04 16:20:20 +0300190 return perf_event__repipe_synth(tool, event);
Arnaldo Carvalho de Melo640c03c2010-12-02 14:10:21 -0200191}
192
Adrian Hunterf56fb982015-09-25 16:15:55 +0300193static int perf_event__drop(struct perf_tool *tool __maybe_unused,
194 union perf_event *event __maybe_unused,
195 struct perf_sample *sample __maybe_unused,
196 struct machine *machine __maybe_unused)
197{
198 return 0;
199}
200
Adrian Hunter73117302015-09-25 16:15:54 +0300201static int perf_event__drop_aux(struct perf_tool *tool,
202 union perf_event *event __maybe_unused,
203 struct perf_sample *sample,
204 struct machine *machine __maybe_unused)
205{
206 struct perf_inject *inject = container_of(tool, struct perf_inject, tool);
207
208 if (!inject->aux_id)
209 inject->aux_id = sample->id;
210
211 return 0;
212}
213
Andrew Vagin26a031e2012-08-07 16:56:04 +0400214typedef int (*inject_handler)(struct perf_tool *tool,
215 union perf_event *event,
216 struct perf_sample *sample,
217 struct perf_evsel *evsel,
218 struct machine *machine);
219
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200220static int perf_event__repipe_sample(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200221 union perf_event *event,
Andrew Vagin26a031e2012-08-07 16:56:04 +0400222 struct perf_sample *sample,
223 struct perf_evsel *evsel,
224 struct machine *machine)
Arnaldo Carvalho de Melo9e69c212011-03-15 15:44:01 -0300225{
Arnaldo Carvalho de Melo744a9712013-11-06 10:17:38 -0300226 if (evsel->handler) {
227 inject_handler f = evsel->handler;
Andrew Vagin26a031e2012-08-07 16:56:04 +0400228 return f(tool, event, sample, evsel, machine);
229 }
230
Andrew Vagin54a3cf52012-08-07 16:56:05 +0400231 build_id__mark_dso_hit(tool, event, sample, evsel, machine);
232
Adrian Hunter63c2c9f2013-07-04 16:20:20 +0300233 return perf_event__repipe_synth(tool, event);
Arnaldo Carvalho de Melo9e69c212011-03-15 15:44:01 -0300234}
235
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200236static int perf_event__repipe_mmap(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200237 union perf_event *event,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200238 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200239 struct machine *machine)
Tom Zanussi454c4072010-05-01 01:41:20 -0500240{
241 int err;
242
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200243 err = perf_event__process_mmap(tool, event, sample, machine);
244 perf_event__repipe(tool, event, sample, machine);
Tom Zanussi454c4072010-05-01 01:41:20 -0500245
246 return err;
247}
248
Jiri Olsae12b2022016-03-10 17:41:13 +0100249#ifdef HAVE_JITDUMP
Stephane Eranian9b07e272015-11-30 10:02:21 +0100250static int perf_event__jit_repipe_mmap(struct perf_tool *tool,
251 union perf_event *event,
252 struct perf_sample *sample,
253 struct machine *machine)
254{
255 struct perf_inject *inject = container_of(tool, struct perf_inject, tool);
256 u64 n = 0;
Adrian Hunter570735b2016-03-07 16:44:40 -0300257 int ret;
Stephane Eranian9b07e272015-11-30 10:02:21 +0100258
259 /*
260 * if jit marker, then inject jit mmaps and generate ELF images
261 */
Adrian Hunter570735b2016-03-07 16:44:40 -0300262 ret = jit_process(inject->session, &inject->output, machine,
263 event->mmap.filename, sample->pid, &n);
264 if (ret < 0)
265 return ret;
266 if (ret) {
Stephane Eranian9b07e272015-11-30 10:02:21 +0100267 inject->bytes_written += n;
268 return 0;
269 }
270 return perf_event__repipe_mmap(tool, event, sample, machine);
271}
272#endif
273
Stephane Eranian5c5e8542013-08-21 12:10:25 +0200274static int perf_event__repipe_mmap2(struct perf_tool *tool,
275 union perf_event *event,
276 struct perf_sample *sample,
277 struct machine *machine)
278{
279 int err;
280
281 err = perf_event__process_mmap2(tool, event, sample, machine);
282 perf_event__repipe(tool, event, sample, machine);
283
284 return err;
285}
286
Jiri Olsae12b2022016-03-10 17:41:13 +0100287#ifdef HAVE_JITDUMP
Stephane Eranian9b07e272015-11-30 10:02:21 +0100288static int perf_event__jit_repipe_mmap2(struct perf_tool *tool,
289 union perf_event *event,
290 struct perf_sample *sample,
291 struct machine *machine)
292{
293 struct perf_inject *inject = container_of(tool, struct perf_inject, tool);
294 u64 n = 0;
Adrian Hunter570735b2016-03-07 16:44:40 -0300295 int ret;
Stephane Eranian9b07e272015-11-30 10:02:21 +0100296
297 /*
298 * if jit marker, then inject jit mmaps and generate ELF images
299 */
Adrian Hunter570735b2016-03-07 16:44:40 -0300300 ret = jit_process(inject->session, &inject->output, machine,
301 event->mmap2.filename, sample->pid, &n);
302 if (ret < 0)
303 return ret;
304 if (ret) {
Stephane Eranian9b07e272015-11-30 10:02:21 +0100305 inject->bytes_written += n;
306 return 0;
307 }
308 return perf_event__repipe_mmap2(tool, event, sample, machine);
309}
310#endif
311
Arnaldo Carvalho de Melof62d3f02012-10-06 15:44:59 -0300312static int perf_event__repipe_fork(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200313 union perf_event *event,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200314 struct perf_sample *sample,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200315 struct machine *machine)
Tom Zanussi454c4072010-05-01 01:41:20 -0500316{
317 int err;
318
Arnaldo Carvalho de Melof62d3f02012-10-06 15:44:59 -0300319 err = perf_event__process_fork(tool, event, sample, machine);
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200320 perf_event__repipe(tool, event, sample, machine);
Tom Zanussi454c4072010-05-01 01:41:20 -0500321
322 return err;
323}
324
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300325static int perf_event__repipe_comm(struct perf_tool *tool,
326 union perf_event *event,
327 struct perf_sample *sample,
328 struct machine *machine)
329{
330 int err;
331
332 err = perf_event__process_comm(tool, event, sample, machine);
333 perf_event__repipe(tool, event, sample, machine);
334
335 return err;
336}
337
Hari Bathinif3b36142017-03-08 02:11:43 +0530338static int perf_event__repipe_namespaces(struct perf_tool *tool,
339 union perf_event *event,
340 struct perf_sample *sample,
341 struct machine *machine)
342{
343 int err = perf_event__process_namespaces(tool, event, sample, machine);
344
345 perf_event__repipe(tool, event, sample, machine);
346
347 return err;
348}
349
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300350static int perf_event__repipe_exit(struct perf_tool *tool,
351 union perf_event *event,
352 struct perf_sample *sample,
353 struct machine *machine)
354{
355 int err;
356
357 err = perf_event__process_exit(tool, event, sample, machine);
358 perf_event__repipe(tool, event, sample, machine);
359
360 return err;
361}
362
Adrian Hunter47c3d102013-07-04 16:20:21 +0300363static int perf_event__repipe_tracing_data(struct perf_tool *tool,
364 union perf_event *event,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200365 struct perf_session *session)
Tom Zanussi454c4072010-05-01 01:41:20 -0500366{
367 int err;
368
Adrian Hunter47c3d102013-07-04 16:20:21 +0300369 perf_event__repipe_synth(tool, event);
370 err = perf_event__process_tracing_data(tool, event, session);
Tom Zanussi454c4072010-05-01 01:41:20 -0500371
372 return err;
373}
374
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300375static int perf_event__repipe_id_index(struct perf_tool *tool,
376 union perf_event *event,
377 struct perf_session *session)
378{
379 int err;
380
381 perf_event__repipe_synth(tool, event);
382 err = perf_event__process_id_index(tool, event, session);
383
384 return err;
385}
386
Arnaldo Carvalho de Meloc824c432013-10-22 19:01:31 -0300387static int dso__read_build_id(struct dso *dso)
Tom Zanussi454c4072010-05-01 01:41:20 -0500388{
Arnaldo Carvalho de Meloc824c432013-10-22 19:01:31 -0300389 if (dso->has_build_id)
Arnaldo Carvalho de Melo090f7202010-05-02 19:46:36 -0300390 return 0;
Tom Zanussi454c4072010-05-01 01:41:20 -0500391
Arnaldo Carvalho de Meloc824c432013-10-22 19:01:31 -0300392 if (filename__read_build_id(dso->long_name, dso->build_id,
393 sizeof(dso->build_id)) > 0) {
394 dso->has_build_id = true;
Arnaldo Carvalho de Melo090f7202010-05-02 19:46:36 -0300395 return 0;
Tom Zanussi454c4072010-05-01 01:41:20 -0500396 }
397
Arnaldo Carvalho de Melo090f7202010-05-02 19:46:36 -0300398 return -1;
399}
Tom Zanussi454c4072010-05-01 01:41:20 -0500400
Arnaldo Carvalho de Meloc824c432013-10-22 19:01:31 -0300401static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200402 struct machine *machine)
Arnaldo Carvalho de Melo090f7202010-05-02 19:46:36 -0300403{
404 u16 misc = PERF_RECORD_MISC_USER;
Arnaldo Carvalho de Melo090f7202010-05-02 19:46:36 -0300405 int err;
Tom Zanussi454c4072010-05-01 01:41:20 -0500406
Arnaldo Carvalho de Meloc824c432013-10-22 19:01:31 -0300407 if (dso__read_build_id(dso) < 0) {
408 pr_debug("no build_id found for %s\n", dso->long_name);
Arnaldo Carvalho de Melo090f7202010-05-02 19:46:36 -0300409 return -1;
410 }
Tom Zanussi454c4072010-05-01 01:41:20 -0500411
Arnaldo Carvalho de Meloc824c432013-10-22 19:01:31 -0300412 if (dso->kernel)
Arnaldo Carvalho de Melo090f7202010-05-02 19:46:36 -0300413 misc = PERF_RECORD_MISC_KERNEL;
414
Arnaldo Carvalho de Meloc824c432013-10-22 19:01:31 -0300415 err = perf_event__synthesize_build_id(tool, dso, misc, perf_event__repipe,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200416 machine);
Arnaldo Carvalho de Melo090f7202010-05-02 19:46:36 -0300417 if (err) {
Arnaldo Carvalho de Meloc824c432013-10-22 19:01:31 -0300418 pr_err("Can't synthesize build_id event for %s\n", dso->long_name);
Tom Zanussi454c4072010-05-01 01:41:20 -0500419 return -1;
420 }
421
422 return 0;
423}
424
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200425static int perf_event__inject_buildid(struct perf_tool *tool,
Arnaldo Carvalho de Melod20deb62011-11-25 08:19:45 -0200426 union perf_event *event,
Arnaldo Carvalho de Melo8115d602011-01-29 14:01:45 -0200427 struct perf_sample *sample,
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300428 struct perf_evsel *evsel __maybe_unused,
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -0200429 struct machine *machine)
Tom Zanussi454c4072010-05-01 01:41:20 -0500430{
431 struct addr_location al;
432 struct thread *thread;
Tom Zanussi454c4072010-05-01 01:41:20 -0500433
Namhyung Kim13ce34d2014-05-12 09:56:42 +0900434 thread = machine__findnew_thread(machine, sample->pid, sample->tid);
Tom Zanussi454c4072010-05-01 01:41:20 -0500435 if (thread == NULL) {
436 pr_err("problem processing %d event, skipping it.\n",
437 event->header.type);
Tom Zanussi454c4072010-05-01 01:41:20 -0500438 goto repipe;
439 }
440
Arnaldo Carvalho de Melo473398a2016-03-22 18:23:43 -0300441 thread__find_addr_map(thread, sample->cpumode, MAP__FUNCTION, sample->ip, &al);
Tom Zanussi454c4072010-05-01 01:41:20 -0500442
443 if (al.map != NULL) {
444 if (!al.map->dso->hit) {
445 al.map->dso->hit = 1;
Arnaldo Carvalho de Melobe39db92016-09-01 19:25:52 -0300446 if (map__load(al.map) >= 0) {
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200447 dso__inject_build_id(al.map->dso, tool, machine);
Arnaldo Carvalho de Melo090f7202010-05-02 19:46:36 -0300448 /*
449 * If this fails, too bad, let the other side
450 * account this as unresolved.
451 */
Namhyung Kim393be2e2012-08-06 13:41:21 +0900452 } else {
Ingo Molnar89fe8082013-09-30 12:07:11 +0200453#ifdef HAVE_LIBELF_SUPPORT
Tom Zanussi454c4072010-05-01 01:41:20 -0500454 pr_warning("no symbols found in %s, maybe "
455 "install a debug package?\n",
456 al.map->dso->long_name);
Namhyung Kim393be2e2012-08-06 13:41:21 +0900457#endif
458 }
Tom Zanussi454c4072010-05-01 01:41:20 -0500459 }
460 }
461
Arnaldo Carvalho de Melob91fc392015-04-06 20:43:22 -0300462 thread__put(thread);
Tom Zanussi454c4072010-05-01 01:41:20 -0500463repipe:
Arnaldo Carvalho de Melo45694aa2011-11-28 08:30:20 -0200464 perf_event__repipe(tool, event, sample, machine);
Arnaldo Carvalho de Melo090f7202010-05-02 19:46:36 -0300465 return 0;
Tom Zanussi454c4072010-05-01 01:41:20 -0500466}
467
Andrew Vagin26a031e2012-08-07 16:56:04 +0400468static int perf_inject__sched_process_exit(struct perf_tool *tool,
469 union perf_event *event __maybe_unused,
470 struct perf_sample *sample,
471 struct perf_evsel *evsel __maybe_unused,
472 struct machine *machine __maybe_unused)
473{
474 struct perf_inject *inject = container_of(tool, struct perf_inject, tool);
475 struct event_entry *ent;
476
477 list_for_each_entry(ent, &inject->samples, node) {
478 if (sample->tid == ent->tid) {
479 list_del_init(&ent->node);
480 free(ent);
481 break;
482 }
483 }
484
485 return 0;
486}
487
488static int perf_inject__sched_switch(struct perf_tool *tool,
489 union perf_event *event,
490 struct perf_sample *sample,
491 struct perf_evsel *evsel,
492 struct machine *machine)
493{
494 struct perf_inject *inject = container_of(tool, struct perf_inject, tool);
495 struct event_entry *ent;
496
497 perf_inject__sched_process_exit(tool, event, sample, evsel, machine);
498
499 ent = malloc(event->header.size + sizeof(struct event_entry));
500 if (ent == NULL) {
501 color_fprintf(stderr, PERF_COLOR_RED,
502 "Not enough memory to process sched switch event!");
503 return -1;
504 }
505
506 ent->tid = sample->tid;
507 memcpy(&ent->event, event, event->header.size);
508 list_add(&ent->node, &inject->samples);
509 return 0;
510}
511
512static int perf_inject__sched_stat(struct perf_tool *tool,
513 union perf_event *event __maybe_unused,
514 struct perf_sample *sample,
515 struct perf_evsel *evsel,
516 struct machine *machine)
517{
518 struct event_entry *ent;
519 union perf_event *event_sw;
520 struct perf_sample sample_sw;
521 struct perf_inject *inject = container_of(tool, struct perf_inject, tool);
522 u32 pid = perf_evsel__intval(evsel, sample, "pid");
523
524 list_for_each_entry(ent, &inject->samples, node) {
525 if (pid == ent->tid)
526 goto found;
527 }
528
529 return 0;
530found:
531 event_sw = &ent->event[0];
532 perf_evsel__parse_sample(evsel, event_sw, &sample_sw);
533
534 sample_sw.period = sample->period;
535 sample_sw.time = sample->time;
536 perf_event__synthesize_sample(event_sw, evsel->attr.sample_type,
Adrian Hunterd03f2172013-08-27 11:23:11 +0300537 evsel->attr.read_format, &sample_sw,
538 false);
Andrew Vagin54a3cf52012-08-07 16:56:05 +0400539 build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine);
Andrew Vagin26a031e2012-08-07 16:56:04 +0400540 return perf_event__repipe(tool, event_sw, &sample_sw, machine);
541}
542
Irina Tirdea1d037ca2012-09-11 01:15:03 +0300543static void sig_handler(int sig __maybe_unused)
Tom Zanussi454c4072010-05-01 01:41:20 -0500544{
545 session_done = 1;
546}
547
Andrew Vagin26a031e2012-08-07 16:56:04 +0400548static int perf_evsel__check_stype(struct perf_evsel *evsel,
549 u64 sample_type, const char *sample_msg)
550{
551 struct perf_event_attr *attr = &evsel->attr;
552 const char *name = perf_evsel__name(evsel);
553
554 if (!(attr->sample_type & sample_type)) {
555 pr_err("Samples for %s event do not have %s attribute set.",
556 name, sample_msg);
557 return -EINVAL;
558 }
559
560 return 0;
561}
562
Adrian Hunterf56fb982015-09-25 16:15:55 +0300563static int drop_sample(struct perf_tool *tool __maybe_unused,
564 union perf_event *event __maybe_unused,
565 struct perf_sample *sample __maybe_unused,
566 struct perf_evsel *evsel __maybe_unused,
567 struct machine *machine __maybe_unused)
568{
569 return 0;
570}
571
572static void strip_init(struct perf_inject *inject)
573{
574 struct perf_evlist *evlist = inject->session->evlist;
575 struct perf_evsel *evsel;
576
577 inject->tool.context_switch = perf_event__drop;
578
Arnaldo Carvalho de Meloe5cadb92016-06-23 11:26:15 -0300579 evlist__for_each_entry(evlist, evsel)
Adrian Hunterf56fb982015-09-25 16:15:55 +0300580 evsel->handler = drop_sample;
581}
582
583static bool has_tracking(struct perf_evsel *evsel)
584{
585 return evsel->attr.mmap || evsel->attr.mmap2 || evsel->attr.comm ||
586 evsel->attr.task;
587}
588
589#define COMPAT_MASK (PERF_SAMPLE_ID | PERF_SAMPLE_TID | PERF_SAMPLE_TIME | \
590 PERF_SAMPLE_ID | PERF_SAMPLE_CPU | PERF_SAMPLE_IDENTIFIER)
591
592/*
593 * In order that the perf.data file is parsable, tracking events like MMAP need
594 * their selected event to exist, except if there is only 1 selected event left
595 * and it has a compatible sample type.
596 */
597static bool ok_to_remove(struct perf_evlist *evlist,
598 struct perf_evsel *evsel_to_remove)
599{
600 struct perf_evsel *evsel;
601 int cnt = 0;
602 bool ok = false;
603
604 if (!has_tracking(evsel_to_remove))
605 return true;
606
Arnaldo Carvalho de Meloe5cadb92016-06-23 11:26:15 -0300607 evlist__for_each_entry(evlist, evsel) {
Adrian Hunterf56fb982015-09-25 16:15:55 +0300608 if (evsel->handler != drop_sample) {
609 cnt += 1;
610 if ((evsel->attr.sample_type & COMPAT_MASK) ==
611 (evsel_to_remove->attr.sample_type & COMPAT_MASK))
612 ok = true;
613 }
614 }
615
616 return ok && cnt == 1;
617}
618
619static void strip_fini(struct perf_inject *inject)
620{
621 struct perf_evlist *evlist = inject->session->evlist;
622 struct perf_evsel *evsel, *tmp;
623
624 /* Remove non-synthesized evsels if possible */
Arnaldo Carvalho de Meloe5cadb92016-06-23 11:26:15 -0300625 evlist__for_each_entry_safe(evlist, tmp, evsel) {
Adrian Hunterf56fb982015-09-25 16:15:55 +0300626 if (evsel->handler == drop_sample &&
627 ok_to_remove(evlist, evsel)) {
628 pr_debug("Deleting %s\n", perf_evsel__name(evsel));
629 perf_evlist__remove(evlist, evsel);
630 perf_evsel__delete(evsel);
631 }
632 }
633}
634
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300635static int __cmd_inject(struct perf_inject *inject)
Tom Zanussi454c4072010-05-01 01:41:20 -0500636{
Tom Zanussi454c4072010-05-01 01:41:20 -0500637 int ret = -EINVAL;
Namhyung Kim1cb8bdc2014-08-12 15:40:37 +0900638 struct perf_session *session = inject->session;
Jiri Olsa34069122013-10-29 19:04:57 +0100639 struct perf_data_file *file_out = &inject->output;
Namhyung Kim42aa2762015-01-29 17:06:48 +0900640 int fd = perf_data_file__fd(file_out);
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300641 u64 output_data_offset;
Tom Zanussi454c4072010-05-01 01:41:20 -0500642
643 signal(SIGINT, sig_handler);
644
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300645 if (inject->build_ids || inject->sched_stat ||
646 inject->itrace_synth_opts.set) {
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300647 inject->tool.mmap = perf_event__repipe_mmap;
Stephane Eranian5c5e8542013-08-21 12:10:25 +0200648 inject->tool.mmap2 = perf_event__repipe_mmap2;
Arnaldo Carvalho de Melof62d3f02012-10-06 15:44:59 -0300649 inject->tool.fork = perf_event__repipe_fork;
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300650 inject->tool.tracing_data = perf_event__repipe_tracing_data;
Tom Zanussi454c4072010-05-01 01:41:20 -0500651 }
652
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300653 output_data_offset = session->header.data_offset;
654
Andrew Vagin54a3cf52012-08-07 16:56:05 +0400655 if (inject->build_ids) {
656 inject->tool.sample = perf_event__inject_buildid;
657 } else if (inject->sched_stat) {
Andrew Vagin26a031e2012-08-07 16:56:04 +0400658 struct perf_evsel *evsel;
659
Arnaldo Carvalho de Meloe5cadb92016-06-23 11:26:15 -0300660 evlist__for_each_entry(session->evlist, evsel) {
Andrew Vagin26a031e2012-08-07 16:56:04 +0400661 const char *name = perf_evsel__name(evsel);
662
663 if (!strcmp(name, "sched:sched_switch")) {
664 if (perf_evsel__check_stype(evsel, PERF_SAMPLE_TID, "TID"))
665 return -EINVAL;
666
Arnaldo Carvalho de Melo744a9712013-11-06 10:17:38 -0300667 evsel->handler = perf_inject__sched_switch;
Andrew Vagin26a031e2012-08-07 16:56:04 +0400668 } else if (!strcmp(name, "sched:sched_process_exit"))
Arnaldo Carvalho de Melo744a9712013-11-06 10:17:38 -0300669 evsel->handler = perf_inject__sched_process_exit;
Andrew Vagin26a031e2012-08-07 16:56:04 +0400670 else if (!strncmp(name, "sched:sched_stat_", 17))
Arnaldo Carvalho de Melo744a9712013-11-06 10:17:38 -0300671 evsel->handler = perf_inject__sched_stat;
Andrew Vagin26a031e2012-08-07 16:56:04 +0400672 }
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300673 } else if (inject->itrace_synth_opts.set) {
674 session->itrace_synth_opts = &inject->itrace_synth_opts;
675 inject->itrace_synth_opts.inject = true;
676 inject->tool.comm = perf_event__repipe_comm;
Hari Bathinif3b36142017-03-08 02:11:43 +0530677 inject->tool.namespaces = perf_event__repipe_namespaces;
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300678 inject->tool.exit = perf_event__repipe_exit;
679 inject->tool.id_index = perf_event__repipe_id_index;
680 inject->tool.auxtrace_info = perf_event__process_auxtrace_info;
681 inject->tool.auxtrace = perf_event__process_auxtrace;
Adrian Hunter73117302015-09-25 16:15:54 +0300682 inject->tool.aux = perf_event__drop_aux;
683 inject->tool.itrace_start = perf_event__drop_aux,
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300684 inject->tool.ordered_events = true;
685 inject->tool.ordering_requires_timestamps = true;
686 /* Allow space in the header for new attributes */
687 output_data_offset = 4096;
Adrian Hunterf56fb982015-09-25 16:15:55 +0300688 if (inject->strip)
689 strip_init(inject);
Andrew Vagin26a031e2012-08-07 16:56:04 +0400690 }
691
Adrian Hunter99fa2982015-04-30 17:37:25 +0300692 if (!inject->itrace_synth_opts.set)
693 auxtrace_index__free(&session->auxtrace_index);
694
Jiri Olsa34069122013-10-29 19:04:57 +0100695 if (!file_out->is_pipe)
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300696 lseek(fd, output_data_offset, SEEK_SET);
Andrew Vagine558a5b2012-08-07 16:56:02 +0400697
Arnaldo Carvalho de Melob7b61cb2015-03-03 11:58:45 -0300698 ret = perf_session__process_events(session);
David Carrillo-Cisnerosbb8d5212017-04-10 13:14:26 -0700699 if (ret)
700 return ret;
Tom Zanussi454c4072010-05-01 01:41:20 -0500701
Jiri Olsa34069122013-10-29 19:04:57 +0100702 if (!file_out->is_pipe) {
Adrian Hunter640dad42016-03-07 16:44:38 -0300703 if (inject->build_ids)
Adrian Huntere38b43c2014-07-14 13:02:34 +0300704 perf_header__set_feat(&session->header,
705 HEADER_BUILD_ID);
Adrian Hunter640dad42016-03-07 16:44:38 -0300706 /*
707 * Keep all buildids when there is unprocessed AUX data because
708 * it is not known which ones the AUX trace hits.
709 */
710 if (perf_header__has_feat(&session->header, HEADER_BUILD_ID) &&
711 inject->have_auxtrace && !inject->itrace_synth_opts.set)
712 dsos__hit_all(session);
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300713 /*
714 * The AUX areas have been removed and replaced with
Adrian Hunter73117302015-09-25 16:15:54 +0300715 * synthesized hardware events, so clear the feature flag and
716 * remove the evsel.
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300717 */
Adrian Hunter051a01b2015-09-25 16:15:43 +0300718 if (inject->itrace_synth_opts.set) {
Adrian Hunter73117302015-09-25 16:15:54 +0300719 struct perf_evsel *evsel;
720
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300721 perf_header__clear_feat(&session->header,
722 HEADER_AUXTRACE);
Adrian Hunter051a01b2015-09-25 16:15:43 +0300723 if (inject->itrace_synth_opts.last_branch)
724 perf_header__set_feat(&session->header,
725 HEADER_BRANCH_STACK);
Adrian Hunter73117302015-09-25 16:15:54 +0300726 evsel = perf_evlist__id2evsel_strict(session->evlist,
727 inject->aux_id);
728 if (evsel) {
729 pr_debug("Deleting %s\n",
730 perf_evsel__name(evsel));
731 perf_evlist__remove(session->evlist, evsel);
732 perf_evsel__delete(evsel);
733 }
Adrian Hunterf56fb982015-09-25 16:15:55 +0300734 if (inject->strip)
735 strip_fini(inject);
Adrian Hunter051a01b2015-09-25 16:15:43 +0300736 }
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300737 session->header.data_offset = output_data_offset;
Andrew Vagine558a5b2012-08-07 16:56:02 +0400738 session->header.data_size = inject->bytes_written;
Namhyung Kim42aa2762015-01-29 17:06:48 +0900739 perf_session__write_header(session, session->evlist, fd, true);
Andrew Vagine558a5b2012-08-07 16:56:02 +0400740 }
741
Tom Zanussi454c4072010-05-01 01:41:20 -0500742 return ret;
743}
744
Arnaldo Carvalho de Melob0ad8ea2017-03-27 11:47:20 -0300745int cmd_inject(int argc, const char **argv)
Tom Zanussi454c4072010-05-01 01:41:20 -0500746{
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300747 struct perf_inject inject = {
748 .tool = {
749 .sample = perf_event__repipe_sample,
750 .mmap = perf_event__repipe,
Stephane Eranian5c5e8542013-08-21 12:10:25 +0200751 .mmap2 = perf_event__repipe,
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300752 .comm = perf_event__repipe,
753 .fork = perf_event__repipe,
754 .exit = perf_event__repipe,
755 .lost = perf_event__repipe,
Adrian Hunterd8145b32015-11-13 11:48:32 +0200756 .lost_samples = perf_event__repipe,
Adrian Hunter4a96f7a2015-04-30 17:37:29 +0300757 .aux = perf_event__repipe,
Adrian Hunter0ad21f62015-04-30 17:37:30 +0300758 .itrace_start = perf_event__repipe,
Adrian Hunter02860392015-07-21 12:44:03 +0300759 .context_switch = perf_event__repipe,
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300760 .read = perf_event__repipe_sample,
761 .throttle = perf_event__repipe,
762 .unthrottle = perf_event__repipe,
763 .attr = perf_event__repipe_attr,
Adrian Hunter47c3d102013-07-04 16:20:21 +0300764 .tracing_data = perf_event__repipe_op2_synth,
Adrian Huntercd17a9b2015-04-21 12:21:54 +0300765 .auxtrace_info = perf_event__repipe_op2_synth,
766 .auxtrace = perf_event__repipe_auxtrace,
767 .auxtrace_error = perf_event__repipe_op2_synth,
Adrian Hunter46bc29b2016-03-08 10:38:44 +0200768 .time_conv = perf_event__repipe_op2_synth,
Arnaldo Carvalho de Melod704ebd2015-03-03 12:37:54 -0300769 .finished_round = perf_event__repipe_oe_synth,
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300770 .build_id = perf_event__repipe_op2_synth,
Adrian Hunter3c659ee2014-10-27 15:49:22 +0200771 .id_index = perf_event__repipe_op2_synth,
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300772 },
Andrew Vagine558a5b2012-08-07 16:56:02 +0400773 .input_name = "-",
Andrew Vagin26a031e2012-08-07 16:56:04 +0400774 .samples = LIST_HEAD_INIT(inject.samples),
Jiri Olsa34069122013-10-29 19:04:57 +0100775 .output = {
776 .path = "-",
777 .mode = PERF_DATA_MODE_WRITE,
778 },
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300779 };
Namhyung Kim1cb8bdc2014-08-12 15:40:37 +0900780 struct perf_data_file file = {
781 .mode = PERF_DATA_MODE_READ,
782 };
783 int ret;
784
Stephane Eranian9b07e272015-11-30 10:02:21 +0100785 struct option options[] = {
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300786 OPT_BOOLEAN('b', "build-ids", &inject.build_ids,
787 "Inject build-ids into the output stream"),
Andrew Vagine558a5b2012-08-07 16:56:02 +0400788 OPT_STRING('i', "input", &inject.input_name, "file",
789 "input file name"),
Jiri Olsa34069122013-10-29 19:04:57 +0100790 OPT_STRING('o', "output", &inject.output.path, "file",
Andrew Vagine558a5b2012-08-07 16:56:02 +0400791 "output file name"),
Andrew Vagin26a031e2012-08-07 16:56:04 +0400792 OPT_BOOLEAN('s', "sched-stat", &inject.sched_stat,
793 "Merge sched-stat and sched-switch for getting events "
794 "where and how long tasks slept"),
Jiri Olsae12b2022016-03-10 17:41:13 +0100795#ifdef HAVE_JITDUMP
Stephane Eranian9b07e272015-11-30 10:02:21 +0100796 OPT_BOOLEAN('j', "jit", &inject.jit_mode, "merge jitdump files into perf.data file"),
Jiri Olsae12b2022016-03-10 17:41:13 +0100797#endif
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300798 OPT_INCR('v', "verbose", &verbose,
799 "be more verbose (show build ids, etc)"),
Adrian Huntera7a2b8b2014-07-22 16:17:38 +0300800 OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, "file",
801 "kallsyms pathname"),
Yunlong Songccaa4742015-04-02 21:47:11 +0800802 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
Adrian Hunter0f0aa5e2015-04-09 18:54:00 +0300803 OPT_CALLBACK_OPTARG(0, "itrace", &inject.itrace_synth_opts,
804 NULL, "opts", "Instruction Tracing options",
805 itrace_parse_synth_opts),
Adrian Hunterf56fb982015-09-25 16:15:55 +0300806 OPT_BOOLEAN(0, "strip", &inject.strip,
807 "strip non-synthesized events (use with --itrace)"),
Arnaldo Carvalho de Melo5ded57a2012-09-30 19:54:10 -0300808 OPT_END()
809 };
Arnaldo Carvalho de Melo002439e2012-10-01 15:20:58 -0300810 const char * const inject_usage[] = {
811 "perf inject [<options>]",
812 NULL
813 };
Jiri Olsae12b2022016-03-10 17:41:13 +0100814#ifndef HAVE_JITDUMP
Stephane Eranian9b07e272015-11-30 10:02:21 +0100815 set_option_nobuild(options, 'j', "jit", "NO_LIBELF=1", true);
816#endif
Arnaldo Carvalho de Melo002439e2012-10-01 15:20:58 -0300817 argc = parse_options(argc, argv, options, inject_usage, 0);
Tom Zanussi454c4072010-05-01 01:41:20 -0500818
819 /*
820 * Any (unrecognized) arguments left?
821 */
822 if (argc)
Arnaldo Carvalho de Melo002439e2012-10-01 15:20:58 -0300823 usage_with_options(inject_usage, options);
Tom Zanussi454c4072010-05-01 01:41:20 -0500824
Adrian Hunterf56fb982015-09-25 16:15:55 +0300825 if (inject.strip && !inject.itrace_synth_opts.set) {
826 pr_err("--strip option requires --itrace option\n");
827 return -1;
828 }
829
Jiri Olsa34069122013-10-29 19:04:57 +0100830 if (perf_data_file__open(&inject.output)) {
831 perror("failed to create output file");
832 return -1;
Andrew Vagine558a5b2012-08-07 16:56:02 +0400833 }
834
Arnaldo Carvalho de Melob7b61cb2015-03-03 11:58:45 -0300835 inject.tool.ordered_events = inject.sched_stat;
836
Namhyung Kim1cb8bdc2014-08-12 15:40:37 +0900837 file.path = inject.input_name;
838 inject.session = perf_session__new(&file, true, &inject.tool);
839 if (inject.session == NULL)
Taeung Song52e028342014-09-24 10:33:37 +0900840 return -1;
Namhyung Kim1cb8bdc2014-08-12 15:40:37 +0900841
Arnaldo Carvalho de Melo921f3fa2016-01-22 18:41:00 -0300842 if (inject.build_ids) {
843 /*
844 * to make sure the mmap records are ordered correctly
845 * and so that the correct especially due to jitted code
846 * mmaps. We cannot generate the buildid hit list and
847 * inject the jit mmaps at the same time for now.
848 */
849 inject.tool.ordered_events = true;
850 inject.tool.ordering_requires_timestamps = true;
851 }
Jiri Olsae12b2022016-03-10 17:41:13 +0100852#ifdef HAVE_JITDUMP
Stephane Eranian9b07e272015-11-30 10:02:21 +0100853 if (inject.jit_mode) {
Stephane Eranian9b07e272015-11-30 10:02:21 +0100854 inject.tool.mmap2 = perf_event__jit_repipe_mmap2;
855 inject.tool.mmap = perf_event__jit_repipe_mmap;
856 inject.tool.ordered_events = true;
857 inject.tool.ordering_requires_timestamps = true;
858 /*
859 * JIT MMAP injection injects all MMAP events in one go, so it
860 * does not obey finished_round semantics.
861 */
862 inject.tool.finished_round = perf_event__drop_oe;
863 }
864#endif
Taeung Song9fedfb02015-06-30 17:15:20 +0900865 ret = symbol__init(&inject.session->header.env);
866 if (ret < 0)
867 goto out_delete;
Tom Zanussi454c4072010-05-01 01:41:20 -0500868
Namhyung Kim1cb8bdc2014-08-12 15:40:37 +0900869 ret = __cmd_inject(&inject);
870
Taeung Song9fedfb02015-06-30 17:15:20 +0900871out_delete:
Namhyung Kim1cb8bdc2014-08-12 15:40:37 +0900872 perf_session__delete(inject.session);
Namhyung Kim1cb8bdc2014-08-12 15:40:37 +0900873 return ret;
Tom Zanussi454c4072010-05-01 01:41:20 -0500874}