diff options
author | Howard Cochran <hcochran@kernelspring.com> | 2015-04-22 00:55:12 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-06-10 15:11:03 -0400 |
commit | 5c731d51ae340eacb77ff6c28d0b7019a6f5d64a (patch) | |
tree | 3eccba90b9e4d97f980ad474a36db83e3be46b18 | |
parent | 1ccedcd4333a789f34d476ce74571ccb8d4f68d3 (diff) | |
download | trace-cmd-5c731d51ae340eacb77ff6c28d0b7019a6f5d64a.tar.gz |
trace-cmd stop, reset, restart: Add -a for all instances
As for extract, -a means all instances except the top one.
Use -t to get the top one too.
Link: http://lkml.kernel.org/r/d6cdd535ae170d4ba0f580434a51286861c75c07.1429677461.git.hcochran@kernelspring.com
Signed-off-by: Howard Cochran <hcochran@kernelspring.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | Documentation/trace-cmd-reset.1.txt | 57 | ||||
-rw-r--r-- | Documentation/trace-cmd-stop.1.txt | 13 | ||||
-rw-r--r-- | trace-record.c | 55 | ||||
-rw-r--r-- | trace-usage.c | 21 |
4 files changed, 118 insertions, 28 deletions
diff --git a/Documentation/trace-cmd-reset.1.txt b/Documentation/trace-cmd-reset.1.txt index 06a60afe..bff45300 100644 --- a/Documentation/trace-cmd-reset.1.txt +++ b/Documentation/trace-cmd-reset.1.txt @@ -22,6 +22,9 @@ the data in the ring buffer, and the options that were used are all lost. OPTIONS ------- +Please note that the order that options are specified on the command line is +significant. See EXAMPLES. + *-b* 'buffer_size':: When the kernel boots, the Ftrace ring buffer is of a minimal size (3 pages per CPU). The first time the tracer is used, the ring buffer size @@ -32,6 +35,17 @@ OPTIONS trace-cmd reset -b 1 + The buffer instance affected is the one (or ones) specified by the most + recently preceding *-B*, *-t*, or *-a* option: + + When used after *-B*, resizes the buffer instance that precedes it on + the command line. + + When used after *-a*, resizes all buffer instances except the top one. + + When used after *-t* or before any *-B* or *-a*, resizes the top + instance. + *-B* 'buffer-name':: If the kernel supports multiple buffers, this will reset the trace for only the given buffer. It does not affect any other buffer. This may be @@ -39,15 +53,46 @@ OPTIONS will not be reset if this option is given (unless the *-t* option is also supplied). +*-a*:: + Reset the trace for all existing buffer instances. When this option + is used, the top level instance will not be reset unless *-t* is given. + *-d*:: - Delete the previously specified buffer instance that was specified by - the *-B* option. It is invalid to use with *-t* as the top level instance - can not be deleted. + This option deletes the instance buffer(s) specified by the most recently + preceding *-B* or *-a* option. Because the top-level instance buffer + cannot be deleted, it is invalid to use this immediatly following *-t* or + prior to any *-B* or *-a* option on the command line. *-t*:: - Resets the top level instance buffer. Without the *-B* option this is the - same as the default. But if *-B* is used, this is required if the top - level instance buffer should also be reset. + Resets the top level instance buffer. Without the *-B* or *-a* option + this is the same as the default. But if *-B* or *-a* is used, this is + required if the top level instance buffer should also be reset. + +EXAMPLES +-------- + +Reset tracing for instance-one and set its per-cpu buffer size to 4096kb. +Also deletes instance-two. The top level instance and any other instances +remain unaffected: + + trace-cmd reset -B instance-one -b 4096 -B instance-two -d + +Delete all instance buffers. Top level instance remains unaffected: + + trace-cmd reset -a -d + +Delete all instance buffers and also reset the top instance: + + trace-cmd reset -t -a -d + +Invalid. This command implies an attempt to delete the top instance: + + trace-cmd reset -a -t -d + +Reset the top instance and set its per-cpu buffer size to 1024kb. If any +instance buffers exist, they will be unaffected: + + trace-cmd reset -b 1024 SEE ALSO diff --git a/Documentation/trace-cmd-stop.1.txt b/Documentation/trace-cmd-stop.1.txt index c3f8b330..9d4093ee 100644 --- a/Documentation/trace-cmd-stop.1.txt +++ b/Documentation/trace-cmd-stop.1.txt @@ -30,12 +30,17 @@ OPTIONS *-B* 'buffer-name':: If the kernel supports multiple buffers, this will stop the trace for only the given buffer. It does not affect any other buffer. This may be - used multiple times to specify different buffers. + used multiple times to specify different buffers. When this option is + used, the top level instance will not be stopped unless *-t* is given. + +*-a*:: + Stop the trace for all existing buffer instances. When this option + is used, the top level instance will not be stopped unless *-t* is given. *-t*:: - Stops the top level instance buffer. Without the *-B* option this is the - same as the default. But if *-B* is used, this is required if the top - level instance buffer should also be stopped. + Stops the top level instance buffer. Without the *-B* or *-a* option this + is the same as the default. But if *-B* or *-a* is used, this is + required if the top level instance buffer should also be stopped. SEE ALSO -------- diff --git a/trace-record.c b/trace-record.c index ebfa520a..8f929b18 100644 --- a/trace-record.c +++ b/trace-record.c @@ -3846,7 +3846,7 @@ void trace_record (int argc, char **argv) for (;;) { int c; - c = getopt(argc-1, argv+1, "tB:"); + c = getopt(argc-1, argv+1, "hatB:"); if (c == -1) break; switch (c) { @@ -3857,6 +3857,9 @@ void trace_record (int argc, char **argv) instance = create_instance(optarg); add_instance(instance); break; + case 'a': + add_all_instances(); + break; case 't': /* Force to use top instance */ topt = 1; @@ -3874,7 +3877,7 @@ void trace_record (int argc, char **argv) for (;;) { int c; - c = getopt(argc-1, argv+1, "tB:"); + c = getopt(argc-1, argv+1, "hatB:"); if (c == -1) break; switch (c) { @@ -3885,6 +3888,9 @@ void trace_record (int argc, char **argv) instance = create_instance(optarg); add_instance(instance); break; + case 'a': + add_all_instances(); + break; case 't': /* Force to use top instance */ topt = 1; @@ -3899,16 +3905,33 @@ void trace_record (int argc, char **argv) enable_tracing(); exit(0); } else if (strcmp(argv[1], "reset") == 0) { + /* if last arg is -a, then -b and -d apply to all instances */ + int last_specified_all = 0; + struct buffer_instance *inst; /* iterator */ + + while ((c = getopt(argc-1, argv+1, "hab:B:td")) >= 0) { - while ((c = getopt(argc-1, argv+1, "b:B:td")) >= 0) { switch (c) { + case 'h': + usage(argv); + break; case 'b': - instance->buffer_size = atoi(optarg); + { + int size = atoi(optarg); /* Min buffer size is 1 */ - if (strcmp(optarg, "0") == 0) - instance->buffer_size = 1; + if (size <= 1) + size = 1; + if (last_specified_all) { + for_each_instance(inst) { + inst->buffer_size = size; + } + } else { + instance->buffer_size = size; + } break; + } case 'B': + last_specified_all = 0; instance = create_instance(optarg); add_instance(instance); /* -d will remove keep */ @@ -3916,13 +3939,27 @@ void trace_record (int argc, char **argv) break; case 't': /* Force to use top instance */ + last_specified_all = 0; topt = 1; instance = &top_instance; break; + case 'a': + last_specified_all = 1; + add_all_instances(); + for_each_instance(instance) { + instance->keep = 1; + } + break; case 'd': - if (is_top_instance(instance)) - die("Can not delete top level buffer"); - instance->keep = 0; + if (last_specified_all) { + for_each_instance(inst) { + inst->keep = 0; + } + } else { + if (is_top_instance(instance)) + die("Can not delete top level buffer"); + instance->keep = 0; + } break; } } diff --git a/trace-usage.c b/trace-usage.c index 39de3862..c56661b1 100644 --- a/trace-usage.c +++ b/trace-usage.c @@ -72,20 +72,22 @@ static struct usage_help usage_help[] = { { "stop", "stop the kernel from recording trace data", - " %s stop [-B buf [-B buf]..] [-t]\n" + " %s stop [-B buf [-B buf]..] [-a] [-t]\n" " Stops the tracer from recording more data.\n" " Used in conjunction with start\n" - " -B stop a given buffer (more than one may be specified)\n " - " -t stop the top level buffer (needed if -B is specified)\n" + " -B stop a given buffer (more than one may be specified)\n" + " -a stop all buffers (except top one)\n" + " -t stop the top level buffer (useful with -B or -a)\n" }, { "restart", "restart the kernel trace data recording", - " %s restart [-B buf [-B buf]..] [-t]\n" + " %s restart [-B buf [-B buf]..] [-a] [-t]\n" " Restarts recording after a trace-cmd stop.\n" " Used in conjunction with stop\n" - " -B restart a given buffer (more than one may be specified)\n " - " -t restart the top level buffer (needed if -B is specified)\n" + " -B restart a given buffer (more than one may be specified)\n" + " -a restart all buffers (except top one)\n" + " -t restart the top level buffer (useful with -B or -a)\n" }, { "show", @@ -114,13 +116,14 @@ static struct usage_help usage_help[] = { { "reset", "disable all kernel tracing and clear the trace buffers", - " %s reset [-b size][-B buf][-d][-t]\n" + " %s reset [-b size][-B buf][-a][-d][-t]\n" " Disables the tracer (may reset trace file)\n" " Used in conjunction with start\n" " -b change the kernel buffer size (in kilobytes per CPU)\n" - " -B reset the given buffer instance (top instance ignored)\n" " -d delete the previous specified instance\n" - " -t still reset the top instance if -B option is given\n" + " -B reset the given buffer instance (may specify multiple -B)\n" + " -a reset all instances (except top one)\n" + " -t reset the top level instance (useful with -B or -a)\n" }, { "report", |