]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ftrace: use task struct trace flag to filter on pid
authorSteven Rostedt <srostedt@redhat.com>
Wed, 3 Dec 2008 20:36:58 +0000 (15:36 -0500)
committerIngo Molnar <mingo@elte.hu>
Thu, 4 Dec 2008 08:09:35 +0000 (09:09 +0100)
Impact: clean up

Use the new task struct trace flags to determine if a process should be
traced or not.

Note: this moves the searching of the pid to the slow path of setting
the pid field. This needs to be converted to the pid name space.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/ftrace.c

index b17a30350f06072fb307b03c7ba2d586e5d7f0bd..c5049f54a275fa823e774b998ba365f61cd8e4ad 100644 (file)
@@ -47,7 +47,7 @@
 int ftrace_enabled __read_mostly;
 static int last_ftrace_enabled;
 
-/* ftrace_pid_trace >= 0 will only trace threads with this pid */
+/* set when tracing only a pid */
 static int ftrace_pid_trace = -1;
 
 /* Quick disabling of function tracer. */
@@ -90,7 +90,7 @@ static void ftrace_list_func(unsigned long ip, unsigned long parent_ip)
 
 static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip)
 {
-       if (current->pid != ftrace_pid_trace)
+       if (!test_tsk_trace_trace(current))
                return;
 
        ftrace_pid_function(ip, parent_ip);
@@ -1714,11 +1714,33 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
                ftrace_pid_trace = -1;
 
        } else {
+               struct task_struct *p;
+               int found = 0;
 
                if (ftrace_pid_trace == val)
                        goto out;
 
-               ftrace_pid_trace = val;
+               /*
+                * Find the task that matches this pid.
+                * TODO: use pid namespaces instead.
+                */
+               rcu_read_lock();
+               for_each_process(p) {
+                       if (p->pid == val) {
+                               found = 1;
+                               set_tsk_trace_trace(p);
+                       } else if (test_tsk_trace_trace(p))
+                               clear_tsk_trace_trace(p);
+               }
+               rcu_read_unlock();
+
+               if (found)
+                       ftrace_pid_trace = val;
+               else {
+                       if (ftrace_pid_trace < 0)
+                               goto out;
+                       ftrace_pid_trace = -1;
+               }
        }
 
        /* update the function call */