perf: ftrace: flush output after each writing

Message ID 20230513074000.733550-1-changbin.du@huawei.com
State New
Headers
Series perf: ftrace: flush output after each writing |

Commit Message

Changbin Du May 13, 2023, 7:40 a.m. UTC
  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>
---
 tools/perf/builtin-ftrace.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Arnaldo Carvalho de Melo May 15, 2023, 9:30 p.m. UTC | #1
Em Sat, May 13, 2023 at 03:40:00PM +0800, Changbin Du escreveu:
> The pager will result stdout in full buffering mode instead of line
> buffering. We need to make the trace visible timely.

Thanks, applied.

- Arnaldo

 
> Signed-off-by: Changbin Du <changbin.du@huawei.com>
> ---
>  tools/perf/builtin-ftrace.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> index 810e3376c7d6..ad2a9ae041f6 100644
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -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);
>  		}
>  	}
>  
> -- 
> 2.25.1
>
  

Patch

diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 810e3376c7d6..ad2a9ae041f6 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -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);
 		}
 	}