Messages in this thread Patch in this message | | | From | Changbin Du <> | Subject | [PATCH 14/19] perf ftrace: add option -P/--no-pager to disable pager | Date | Sun, 10 May 2020 23:06:23 +0800 |
| |
Sometimes we want perf displays trace immediately. So this adds an option '-P/--no-pager' to disable pager if needed.
Signed-off-by: Changbin Du <changbin.du@gmail.com> --- tools/perf/builtin-ftrace.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index a93fbdac6aa4..64c22f367ba2 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -48,6 +48,7 @@ struct perf_ftrace { unsigned tracing_thresh; bool trace_children; unsigned buffer_size_kb; + bool no_pager; }; struct filter_entry { @@ -56,6 +57,7 @@ struct filter_entry { }; static volatile int workload_exec_errno; +static bool interrupted; static bool done; static void sig_handler(int sig __maybe_unused) @@ -63,6 +65,12 @@ static void sig_handler(int sig __maybe_unused) done = true; } +static void sig_handler_int(int sig __maybe_unused) +{ + sig_handler(sig); + interrupted = 1; +} + /* * perf_evlist__prepare_workload will send a SIGUSR1 if the fork fails, since * we asked by setting its exec_error to the function below, @@ -492,7 +500,7 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) return -1; } - signal(SIGINT, sig_handler); + signal(SIGINT, sig_handler_int); signal(SIGUSR1, sig_handler); signal(SIGCHLD, sig_handler); signal(SIGPIPE, sig_handler); @@ -585,7 +593,8 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) goto out_reset; } - setup_pager(); + if (!ftrace->no_pager) + setup_pager(); trace_file = get_tracing_file("trace_pipe"); if (!trace_file) { @@ -636,7 +645,7 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) } /* read remaining buffer contents */ - while (true) { + while (true && !interrupted) { int n = read(trace_fd, buf, sizeof(buf)); if (n <= 0) break; @@ -731,6 +740,8 @@ int cmd_ftrace(int argc, const char **argv) "Trace children processes"), OPT_UINTEGER('b', "buffer-size", &ftrace.buffer_size_kb, "size of per cpu buffer in kb"), + OPT_BOOLEAN('P', "no-pager", &ftrace.no_pager, + "Do not use pager"), OPT_END() }; -- 2.25.1
| |