]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf data: Allow to use given fd in data->file.fd
authorWeilin Wang <weilin.wang@intel.com>
Sat, 20 Jul 2024 06:20:55 +0000 (02:20 -0400)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 12 Aug 2024 21:15:39 +0000 (18:15 -0300)
When in PIPE mode, allow to use fd dynamically opened and asigned to
data->file.fd instead of STDIN_FILENO or STDOUT_FILENO.

Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Weilin Wang <weilin.wang@intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Samantha Alt <samantha.alt@intel.com>
Link: https://lore.kernel.org/r/20240720062102.444578-3-weilin.wang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/data.c

index 08c4bfbd817f2b0b18c8b8d3d37193e671ce69d5..98661ede2a736320c690b3160cc350beefde368a 100644 (file)
@@ -204,7 +204,12 @@ static bool check_pipe(struct perf_data *data)
                                data->file.fd = fd;
                                data->use_stdio = false;
                        }
-               } else {
+
+               /*
+                * When is_pipe and data->file.fd is given, use given fd
+                * instead of STDIN_FILENO or STDOUT_FILENO
+                */
+               } else if (data->file.fd <= 0) {
                        data->file.fd = fd;
                }
        }