lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200510150628.16610-15-changbin.du@gmail.com>
Date:   Sun, 10 May 2020 23:06:23 +0800
From:   Changbin Du <changbin.du@...il.com>
To:     Jiri Olsa <jolsa@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        linux-kernel@...r.kernel.org, Changbin Du <changbin.du@...il.com>
Subject: [PATCH 14/19] perf ftrace: add option -P/--no-pager to disable pager

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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ