Skip to contentSkip to conversation

perf inject: Fix repipe usage

PATCH Applied Adrian Hunter 3 participants 3 messages Apr 1, 2021 – Apr 2, 2021 perf events

lore
Share & tools
lore

Adrian Hunter

author reviewer
#0 lore raw

PATCH 1/1 perf inject: Fix repipe usage

Since commit 14d3d5405253 ("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 e558a5bd8b74 ("perf inject: Work with files")
---
 tools/perf/builtin-inject.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-inject.c +1 -1
index 6fe44d97fde5..ddccc0eb7390 100644
@@ -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);
 
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Adrian Hunter

Since commit 14d3d5405253 ("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.

Quoted 4 lines

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

Fixes e558a5bd8b74 ("perf inject: Work with files")

thanks,
jirka

Quoted 20 lines
---
 tools/perf/builtin-inject.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-inject.c +1 -1
index 6fe44d97fde5..ddccc0eb7390 100644
@@ -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);
 
Signature · 1 line
2.17.1
maintainer Applied
#2 lore raw

Em Thu, Apr 01, 2021 at 04:05:13PM +0200, Jiri Olsa escreveu:

Quoted 14 lines · Adrian Hunter
Quoted 13 lines

Since commit 14d3d5405253 ("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.

Quoted 6 lines
Quoted 4 lines

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

Fixes e558a5bd8b74 ("perf inject: Work with files")

Thanks, applied.

- Arnaldo