]> err.no Git - linux-2.6/blobdiff - kernel/trace/trace_sched_switch.c
ftrace: trace faster
[linux-2.6] / kernel / trace / trace_sched_switch.c
index bddf676914ed85b292b5c45109e4384e3b767269..a3376478fc2cfab0170a5d09d85c454ef39227fe 100644 (file)
@@ -29,18 +29,13 @@ ctx_switch_func(void *__rq, struct task_struct *prev, struct task_struct *next)
        if (!tracer_enabled)
                return;
 
-       tracing_record_cmdline(prev);
-
        local_irq_save(flags);
        cpu = raw_smp_processor_id();
        data = tr->data[cpu];
        disabled = atomic_inc_return(&data->disabled);
 
-       if (likely(disabled == 1)) {
+       if (likely(disabled == 1))
                tracing_sched_switch_trace(tr, data, prev, next, flags);
-               if (trace_flags & TRACE_ITER_SCHED_TREE)
-                       ftrace_all_fair_tasks(__rq, tr, data);
-       }
 
        atomic_dec(&data->disabled);
        local_irq_restore(flags);
@@ -65,11 +60,8 @@ wakeup_func(void *__rq, struct task_struct *wakee, struct task_struct *curr)
        data = tr->data[cpu];
        disabled = atomic_inc_return(&data->disabled);
 
-       if (likely(disabled == 1)) {
+       if (likely(disabled == 1))
                tracing_sched_wakeup_trace(tr, data, wakee, curr, flags);
-               if (trace_flags & TRACE_ITER_SCHED_TREE)
-                       ftrace_all_fair_tasks(__rq, tr, data);
-       }
 
        atomic_dec(&data->disabled);
        local_irq_restore(flags);
@@ -79,6 +71,9 @@ void
 ftrace_ctx_switch(void *__rq, struct task_struct *prev,
                  struct task_struct *next)
 {
+       if (unlikely(atomic_read(&trace_record_cmdline_enabled)))
+               tracing_record_cmdline(prev);
+
        /*
         * If tracer_switch_func only points to the local
         * switch func, it still needs the ptr passed to it.
@@ -140,11 +135,13 @@ static void sched_switch_reset(struct trace_array *tr)
 static void start_sched_trace(struct trace_array *tr)
 {
        sched_switch_reset(tr);
+       atomic_inc(&trace_record_cmdline_enabled);
        tracer_enabled = 1;
 }
 
 static void stop_sched_trace(struct trace_array *tr)
 {
+       atomic_dec(&trace_record_cmdline_enabled);
        tracer_enabled = 0;
 }