perf ftrace: Flush output after each writing
authorChangbin Du <changbin.du@huawei.com>
Sat, 13 May 2023 07:40:00 +0000 (15:40 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 15 May 2023 21:27:33 +0000 (18:27 -0300)
The pager will result stdout in full buffering mode instead of line
buffering. We need to make the trace visible timely.

Signed-off-by: Changbin Du <changbin.du@huawei.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230513074000.733550-1-changbin.du@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-ftrace.c

index 810e337..ad2a9ae 100644 (file)
@@ -650,6 +650,8 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace)
                                break;
                        if (fwrite(buf, n, 1, stdout) != 1)
                                break;
+                       /* flush output since stdout is in full buffering mode due to pager */
+                       fflush(stdout);
                }
        }