Author: GeunSik Lim <leemgs1@gmail.com>
Date:   Mon Apr 6 17:15:09 2009 +0900

    Support wakeup tracing and misc bugfix.
    
    This is patch to support wakeup & wakeup_rt tracing at the argument of cyclictest additionally.
    Currently, cyclictest(ver 0.34) support three tracing like PREEMPTOFF, IRQSOFF, PREEMPTIRQSOFF.
    I want you to append WAKEUP & WAKEUP_RT tracing at the current cyclictest version.
    
    and, cyclictest ver 0.34 have a misc bug about context switching and event option.
    for example,
    we can not use  "-C" option without --context option.
    we can not use  "-E" option without --event option.
    
    Signed-off-by: GeunSik Lim <leemgs1@gmail.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Clark Williams <williams@redhat.com>

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index cedc36f..746b44f 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -93,6 +93,8 @@ enum {
        IRQSOFF,
        PREEMPTOFF,
        IRQPREEMPTOFF,
+       WAKEUP,
+       WAKEUPRT,
 };
 
 #define HIST_MAX               1000000
@@ -415,6 +417,12 @@ static void setup_tracer(void)
                case CTXTSWITCH:
                        ret = settracer("sched_switch");
                        break;
+               case WAKEUP:
+                       ret = settracer("wakeup");
+                       break;
+               case WAKEUPRT:
+                       ret = settracer("wakeup_rt");
+                       break;
                default:
                        printf("cyclictest: unknown tracer!\n");
                        ret = 0;
@@ -686,6 +694,9 @@ static void display_help(void)
               "                           1 = CLOCK_REALTIME\n"
               "-C       --context         context switch tracing (used with -b)\n"
               "-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
+              "-D       --duration=t      specify a length for the test run\n"
+              "                           default is in seconds, but 'm', 'h', or 'd' maybe added\n"
+              "                           to modify value to minutes, hours or days\n"
               "-E       --event           event tracing (used with -b)\n"
               "-f       --ftrace          function trace (when -b is active)\n"
               "-h       --histogram=US    dump a latency histogram to stdout after the run\n"
@@ -708,9 +719,8 @@ static void display_help(void)
               "                           without -t default = 1\n"
               "-v       --verbose         output values on stdout for statistics\n"
               "                           format: n:c:v n=tasknum c=count v=value in us\n"
-              "-D       --duration=t      specify a length for the test run\n"
-              "                           default is in seconds, but 'm', 'h', or 'd' maybe added\n"
-              "                           to modify value to minutes, hours or days\n"
+              "-w       --wakeup          rt task wakeup tracing (used with -b)\n"
+              "-W       --wakeuprt        non_rt task wakeup_rt tracing (used with -b)\n"
                );
        exit(0);
 }
@@ -755,6 +765,7 @@ static void process_options (int argc, char *argv[])
                        {"clock", required_argument, NULL, 'c'},
                        {"context", no_argument, NULL, 'C'},
                        {"distance", required_argument, NULL, 'd'},
+                       {"duration",required_argument, NULL, 'D'},
                        {"event", no_argument, NULL, 'E'},
                        {"ftrace", no_argument, NULL, 'f'},
                        {"histogram", required_argument, NULL, 'h'},
@@ -772,11 +783,12 @@ static void process_options (int argc, char *argv[])
                        {"system", no_argument, NULL, 's'},
                        {"threads", optional_argument, NULL, 't'},
                        {"verbose", no_argument, NULL, 'v'},
-                       {"duration",required_argument, NULL, 'D'},
+                       {"wakeup", no_argument, NULL, 'w'},
+                       {"wakeuprt", no_argument, NULL, 'W'},
                        {"help", no_argument, NULL, '?'},
                        {NULL, 0, NULL, 0}
                };
-               int c = getopt_long (argc, argv, "a::b:Bc:d:fh:i:Il:nNo:p:Pmqrst::vD:",
+               int c = getopt_long (argc, argv, "a::b:BcC:dD:Efh:i:Il:mnNo:p:Pqrst::v:wW:",
                        long_options, &option_index);
                if (c == -1)
                        break;
@@ -797,12 +809,14 @@ static void process_options (int argc, char *argv[])
                case 'c': clocksel = atoi(optarg); break;
                case 'C': tracetype = CTXTSWITCH; break;
                case 'd': distance = atoi(optarg); break;
+               case 'D': duration = parse_time_string(optarg); break;
                case 'E': tracetype = EVENTS; break;
                case 'f': ftrace = 1; break;
                case 'h': histogram = atoi(optarg); break;
                case 'i': interval = atoi(optarg); break;
                case 'I': tracetype = IRQSOFF; break;
                case 'l': max_cycles = atoi(optarg); break;
+               case 'm': lockall = 1; break;
                case 'n': use_nanosleep = MODE_CLOCK_NANOSLEEP; break;
                case 'N': use_nsecs = 1; break;
                case 'o': oscope_reduction = atoi(optarg); break;
@@ -820,9 +834,8 @@ static void process_options (int argc, char *argv[])
                                num_threads = max_cpus;
                        break;
                case 'v': verbose = 1; break;
-               case 'm': lockall = 1; break;
-               case 'D': duration = parse_time_string(optarg);
-                       break;
+               case 'w': tracetype = WAKEUP; break;
+               case 'W': tracetype = WAKEUPRT; break;
                case '?': error = 1; break;
                }
        }

