Commit 6112a300 authored by Soumya PN's avatar Soumya PN Committed by Steven Rostedt

ftrace: Don't disable irqs when taking the tasklist_lock read_lock

In ftrace.c inside the function alloc_retstack_tasklist() (which will be
invoked when function_graph tracing is on) the tasklist_lock is being
held as reader while iterating through a list of threads. Here the lock
is being held as reader with irqs disabled. The tasklist_lock is never
write_locked in interrupt context so it is safe to not disable interrupts
for the duration of read_lock in this block which, can be significant,
given the block of code iterates through all threads. Hence changing the
code to call read_lock() and read_unlock() instead of read_lock_irqsave()
and read_unlock_irqrestore().

A similar change was made in commits: 8063e41d ("tracing: Change
syscall_*regfunc() to check PF_KTHREAD and use for_each_process_thread()")'
and 3472eaa1 ("sched: normalize_rt_tasks(): Don't use _irqsave for
tasklist_lock, use task_rq_lock()")'

Link: http://lkml.kernel.org/r/1463500874-77480-1-git-send-email-soumya.p.n@hpe.comSigned-off-by: default avatarSoumya PN <soumya.p.n@hpe.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 91e6f1ce
...@@ -5713,7 +5713,6 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) ...@@ -5713,7 +5713,6 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list)
{ {
int i; int i;
int ret = 0; int ret = 0;
unsigned long flags;
int start = 0, end = FTRACE_RETSTACK_ALLOC_SIZE; int start = 0, end = FTRACE_RETSTACK_ALLOC_SIZE;
struct task_struct *g, *t; struct task_struct *g, *t;
...@@ -5729,7 +5728,7 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) ...@@ -5729,7 +5728,7 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list)
} }
} }
read_lock_irqsave(&tasklist_lock, flags); read_lock(&tasklist_lock);
do_each_thread(g, t) { do_each_thread(g, t) {
if (start == end) { if (start == end) {
ret = -EAGAIN; ret = -EAGAIN;
...@@ -5747,7 +5746,7 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) ...@@ -5747,7 +5746,7 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list)
} while_each_thread(g, t); } while_each_thread(g, t);
unlock: unlock:
read_unlock_irqrestore(&tasklist_lock, flags); read_unlock(&tasklist_lock);
free: free:
for (i = start; i < end; i++) for (i = start; i < end; i++)
kfree(ret_stack_list[i]); kfree(ret_stack_list[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment