aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-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 */