Lai Jiangshan 4f48f8b7fd tracing: Fix circular dead lock in stack trace
When we cat <debugfs>/tracing/stack_trace, we may cause circular lock:
sys_read()
  t_start()
     arch_spin_lock(&max_stack_lock);

  t_show()
     seq_printf(), vsnprintf() .... /* they are all trace-able,
       when they are traced, max_stack_lock may be required again. */

The following script can trigger this circular dead lock very easy:
#!/bin/bash

echo 1 > /proc/sys/kernel/stack_tracer_enabled

mount -t debugfs xxx /mnt > /dev/null 2>&1

(
# make check_stack() zealous to require max_stack_lock
for ((; ;))
{
	echo 1 > /mnt/tracing/stack_max_size
}
) &

for ((; ;))
{
	cat /mnt/tracing/stack_trace > /dev/null
}

To fix this bug, we increase the percpu trace_active before
require the lock.

Reported-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
LKML-Reference: <4B67D4F9.9080905@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2010-02-02 10:20:18 -05:00
..
2009-09-21 14:29:21 +02:00
2009-12-15 08:53:10 -08:00
2009-12-22 12:27:34 -05:00
2009-12-06 21:10:56 +01:00
2009-09-18 09:48:52 -07:00
2009-12-14 23:55:34 +01:00
2009-12-28 10:25:31 +01:00
2009-12-31 19:45:04 +00:00
2009-12-09 10:03:07 +01:00
2009-12-20 19:05:02 +01:00
2009-10-26 09:40:30 +01:00
2009-12-22 14:10:37 -08:00
2009-09-23 18:13:10 -07:00
2009-11-02 16:02:39 +01:00