As for extract, -a means all instances except the top one.
Use -t to get the top one too.

Signed-off-by: Howard Cochran <hcoch...@kernelspring.com>
---
 Documentation/trace-cmd-reset.1.txt | 57 +++++++++++++++++++++++++++++++++----
 Documentation/trace-cmd-stop.1.txt  | 13 ++++++---
 trace-record.c                      | 57 ++++++++++++++++++++++++++++++-------
 trace-usage.c                       | 21 ++++++++------
 4 files changed, 119 insertions(+), 29 deletions(-)

diff --git a/Documentation/trace-cmd-reset.1.txt 
b/Documentation/trace-cmd-reset.1.txt
index 06a60af..bff4530 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 c3f8b33..9d4093e 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 4a78fff..7c6b7e9 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -311,7 +311,7 @@ struct buffer_instance *create_instance(const char *name)
  *
  * Returns whether the operation succeeded
  */
-int add_all_instances(const char *tracing_dir)
+int __add_all_instances(const char *tracing_dir)
 {
        struct dirent *dent;
        char *instances_dir;
@@ -3844,7 +3844,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) {
@@ -3855,6 +3855,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;
@@ -3872,7 +3875,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) {
@@ -3883,6 +3886,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;
@@ -3897,16 +3903,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 */
@@ -3914,13 +3937,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 39de386..c56661b 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",
-- 
1.9.1

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

Reply via email to