aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/ftrace.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2008-12-03 15:36:58 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-04 03:09:35 -0500
commit0ef8cde56ab92ab3f65221246dc1622c6b5068b3 (patch)
tree47bbb117a76146a5f5b949f00cf743dd3b31f873 /kernel/trace/ftrace.c
parentea4e2bc4d9f7370e57a343ccb5e7c0ad3222ec3c (diff)
ftrace: use task struct trace flag to filter on pid
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>
Diffstat (limited to 'kernel/trace/ftrace.c')
-rw-r--r--kernel/trace/ftrace.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index b17a30350f06..c5049f54a275 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -47,7 +47,7 @@
47int ftrace_enabled __read_mostly; 47int ftrace_enabled __read_mostly;
48static int last_ftrace_enabled; 48static int last_ftrace_enabled;
49 49
50/* ftrace_pid_trace >= 0 will only trace threads with this pid */ 50/* set when tracing only a pid */
51static int ftrace_pid_trace = -1; 51static int ftrace_pid_trace = -1;
52 52
53/* Quick disabling of function tracer. */ 53/* Quick disabling of function tracer. */
@@ -90,7 +90,7 @@ static void ftrace_list_func(unsigned long ip, unsigned long parent_ip)
90 90
91static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip) 91static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip)
92{ 92{
93 if (current->pid != ftrace_pid_trace) 93 if (!test_tsk_trace_trace(current))
94 return; 94 return;
95 95
96 ftrace_pid_function(ip, parent_ip); 96 ftrace_pid_function(ip, parent_ip);
@@ -1714,11 +1714,33 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
1714 ftrace_pid_trace = -1; 1714 ftrace_pid_trace = -1;
1715 1715
1716 } else { 1716 } else {
1717 struct task_struct *p;
1718 int found = 0;
1717 1719
1718 if (ftrace_pid_trace == val) 1720 if (ftrace_pid_trace == val)
1719 goto out; 1721 goto out;
1720 1722
1721 ftrace_pid_trace = val; 1723 /*
1724 * Find the task that matches this pid.
1725 * TODO: use pid namespaces instead.
1726 */
1727 rcu_read_lock();
1728 for_each_process(p) {
1729 if (p->pid == val) {
1730 found = 1;
1731 set_tsk_trace_trace(p);
1732 } else if (test_tsk_trace_trace(p))
1733 clear_tsk_trace_trace(p);
1734 }
1735 rcu_read_unlock();
1736
1737 if (found)
1738 ftrace_pid_trace = val;
1739 else {
1740 if (ftrace_pid_trace < 0)
1741 goto out;
1742 ftrace_pid_trace = -1;
1743 }
1722 } 1744 }
1723 1745
1724 /* update the function call */ 1746 /* update the function call */