Merge branch 'tip/tracing/ftrace' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6.git] / kernel / trace / trace.c
index ae32d3b99b4b07b55509f7145598bc783b8ace41..1ce6208fd727205f25850e2ed13aa63265da76f0 100644 (file)
@@ -770,30 +770,34 @@ static void trace_save_cmdline(struct task_struct *tsk)
        __raw_spin_unlock(&trace_cmdline_lock);
 }
 
-char *trace_find_cmdline(int pid)
+void trace_find_cmdline(int pid, char comm[])
 {
-       char *cmdline = "<...>";
        unsigned map;
 
-       if (!pid)
-               return "<idle>";
+       if (!pid) {
+               strcpy(comm, "<idle>");
+               return;
+       }
 
-       if (pid > PID_MAX_DEFAULT)
-               goto out;
+       if (pid > PID_MAX_DEFAULT) {
+               strcpy(comm, "<...>");
+               return;
+       }
 
+       __raw_spin_lock(&trace_cmdline_lock);
        map = map_pid_to_cmdline[pid];
        if (map >= SAVED_CMDLINES)
                goto out;
 
-       cmdline = saved_cmdlines[map];
+       strcpy(comm, saved_cmdlines[map]);
 
  out:
-       return cmdline;
+       __raw_spin_unlock(&trace_cmdline_lock);
 }
 
 void tracing_record_cmdline(struct task_struct *tsk)
 {
-       if (atomic_read(&trace_record_cmdline_disabled))
+       if (atomic_read(&trace_record_cmdline_disabled) || !tracing_is_on())
                return;
 
        trace_save_cmdline(tsk);