Skip to content

Commit

Permalink
perf inject: Fix repipe usage
Browse files Browse the repository at this point in the history
Since commit 14d3d54 ("perf session: Try to read pipe data from
file") 'perf inject' has started printing "PERFILE2h" when not processing
pipes.

The commit exposed perf to the possiblity that the input is not a pipe
but the 'repipe' parameter gets used. That causes the printing because
perf inject sets 'repipe' to true always.

The 'repipe' parameter of perf_session__new() is used by 2 functions:

	- perf_file_header__read_pipe()
	- trace_report()

In both cases, the functions copy data to STDOUT_FILENO when 'repipe' is
true.

Fix by setting 'repipe' to true only if the output is a pipe.

Fixes: e558a5b ("perf inject: Work with files")
Signed-off-by: Adrian Hunter <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Andrew Vagin <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
ahunter6 authored and acmel committed Apr 5, 2021
1 parent e49d033 commit 026334a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/perf/builtin-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ int cmd_inject(int argc, const char **argv)
}

data.path = inject.input_name;
inject.session = perf_session__new(&data, true, &inject.tool);
inject.session = perf_session__new(&data, inject.output.is_pipe, &inject.tool);
if (IS_ERR(inject.session))
return PTR_ERR(inject.session);

Expand Down

0 comments on commit 026334a

Please sign in to comment.