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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20120124221453.26831.9039.stgit@linux-mp.laurelwood.net>
Date:	Tue, 24 Jan 2012 17:15:22 -0500
From:	Gregory Haskins <gregory.haskins@...il.com>
To:	rostedt@...dmis.org
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] FTRACE: Add a "-D usec" switch to limit execution time of
 "trace-cmd record"

[Applies to trace-cmd.git:699f544895]

It is sometimes useful to have a fairly precise timelimit on the capture
rather than relying on a human to hit Cntrl-C in a timely manner.  This
patch simply adds an optional timeout parameter which will automatically
terminate the capture after the specified duration.

Signed-off-by: Gregory Haskins <gregory.haskins@...il.com>
CC: Steven Rostedt <rostedt@...dmis.org>
---

 trace-record.c |   12 +++++++++++-
 trace-usage.c  |    3 ++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/trace-record.c b/trace-record.c
index fcec28b..444745e 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -77,6 +77,7 @@ static int buffer_size;
 static const char *output_file = "trace.dat";
 
 static int latency;
+static int timeout = -1;
 static int sleep_time = 1000;
 static int cpu_count;
 static int *pids;
@@ -1953,7 +1954,7 @@ void trace_record (int argc, char **argv)
 			{NULL, 0, NULL, 0}
 		};
 
-		c = getopt_long (argc-1, argv+1, "+hae:f:Fp:cdo:O:s:r:vg:l:n:P:N:tb:kiT",
+		c = getopt_long (argc-1, argv+1, "+hae:f:Fp:cdo:O:s:r:vg:l:n:D:P:N:tb:kiT",
 				 long_options, &option_index);
 		if (c == -1)
 			break;
@@ -2051,6 +2052,9 @@ void trace_record (int argc, char **argv)
 			optarg++;
 			optarg[0] = '\0';
 			break;
+		case 'D':
+		        timeout = atoi(optarg);
+		        break;
 		case 'd':
 			if (extract)
 				usage(argv);
@@ -2189,8 +2193,14 @@ void trace_record (int argc, char **argv)
 
 	if (record) {
 		signal(SIGINT, finish);
+		signal(SIGALRM, finish);
 		if (!latency)
 			start_threads();
+
+		if (timeout > 0) {
+		        struct itimerval tv = { {0, 0}, {0, timeout}};
+		        setitimer(ITIMER_REAL, &tv, NULL);
+		}
 	}
 
 	if (extract) {
diff --git a/trace-usage.c b/trace-usage.c
index 0e2194e..df41f76 100644
--- a/trace-usage.c
+++ b/trace-usage.c
@@ -17,7 +17,7 @@ static struct usage_help usage_help[] = {
 		"record",
 		"record a trace into a trace.dat file",
 		" %s record [-v][-e event [-f filter]][-p plugin][-F][-d][-o file] \\\n"
-		"           [-s usecs][-O option ][-l func][-g func][-n func] \\\n"
+		"           [-s usecs][-D usecs][-O option ][-l func][-g func][-n func] \\\n"
 		"           [-P pid][-N host:port][-t][-r prio][-b size][command ...]\n"
 		"          -e run command with event enabled\n"
 		"          -f filter for previous -e event\n"
@@ -35,6 +35,7 @@ static struct usage_help usage_help[] = {
 		"          -O option to enable (or disable)\n"
 		"          -r real time priority to run the capture threads\n"
 		"          -s sleep interval between recording (in usecs) [default: 1000]\n"
+		"          -D run-time duration (in usecs) [default: disabled]\n"
 		"          -N host:port to connect to (see listen)\n"
 		"          -t used with -N, forces use of tcp in live trace\n"
 		"          -b change kernel buffersize (in kilobytes per CPU)\n"

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ