function-graph: add option for include sleep times
authorSteven Rostedt <srostedt@redhat.com>
Tue, 24 Mar 2009 15:06:24 +0000 (11:06 -0400)
committerSteven Rostedt <srostedt@redhat.com>
Tue, 24 Mar 2009 15:06:24 +0000 (11:06 -0400)
Impact: give user a choice to show times spent while sleeping

The user may want to see the time a function spent sleeping.
This patch adds the trace option "sleep-time" to allow that.
The "sleep-time" option is default on.

 echo sleep-time > /debug/tracing/trace_options

produces:

 ------------------------------------------
 2)  avahi-d-3428  =>    <idle>-0
 ------------------------------------------

 2)               |      finish_task_switch() {
 2)   0.621 us    |        _spin_unlock_irq();
 2)   2.202 us    |      }
 2) ! 1002.197 us |    }
 2) ! 1003.521 us |  }

where as,

 echo nosleep-time > /debug/tracing/trace_options

produces:

 0)    <idle>-0    =>  yum-upd-3416
 ------------------------------------------

 0)               |              finish_task_switch() {
 0)   0.643 us    |                _spin_unlock_irq();
 0)   2.342 us    |              }
 0) + 41.302 us   |            }
 0) + 42.453 us   |          }

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
kernel/trace/ftrace.c
kernel/trace/trace.c
kernel/trace/trace.h

index 0b90364d1a2cefce0c6fefd621acc73250a5522f..02d2de9d08baf6cc400a0b0a008cf69a46dbe404 100644 (file)
@@ -2599,6 +2599,13 @@ ftrace_graph_probe_sched_switch(struct rq *__rq, struct task_struct *prev,
        unsigned long long timestamp;
        int index;
 
+       /*
+        * Does the user want to count the time a function was asleep.
+        * If so, do not update the time stamps.
+        */
+       if (trace_flags & TRACE_ITER_SLEEP_TIME)
+               return;
+
        timestamp = trace_clock_local();
 
        prev->ftrace_timestamp = timestamp;
index f0e1337b1ebd5481dc2d6fdd4a1e1429f36de8d4..67c6a21dd4274f8b52816e968aac28348a08c4ee 100644 (file)
@@ -255,7 +255,7 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait);
 
 /* trace_flags holds trace_options default values */
 unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK |
-       TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO;
+       TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME;
 
 /**
  * trace_wake_up - wake up tasks waiting for trace input
@@ -316,6 +316,7 @@ static const char *trace_options[] = {
        "context-info",
        "latency-format",
        "global-clock",
+       "sleep-time",
        NULL
 };
 
index 7cfb741be2001862b3ddba9df6109f422b631bbd..d7410bbb9a803f2052ba8c1921354991194a0234 100644 (file)
@@ -683,6 +683,7 @@ enum trace_iterator_flags {
        TRACE_ITER_CONTEXT_INFO         = 0x20000, /* Print pid/cpu/time */
        TRACE_ITER_LATENCY_FMT          = 0x40000,
        TRACE_ITER_GLOBAL_CLK           = 0x80000,
+       TRACE_ITER_SLEEP_TIME           = 0x100000,
 };
 
 /*