diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-03-10 17:16:35 -0400 |
---|---|---|
committer | Steven Rostedt <srostedt@redhat.com> | 2009-03-10 17:16:35 -0400 |
commit | 80370cb758e7ca2692cd9fb5e413d970b1f4b2b2 (patch) | |
tree | 2c1451f4a374d8b7a515fe39b4bb24bb6a323db9 /kernel/trace/trace.c | |
parent | ef18012b248b47ec9a12c3a83ca5e99782d39c5d (diff) |
tracing: use raw spinlocks for trace_vprintk
Impact: prevent locking up by lockdep tracer
The lockdep tracer uses trace_vprintk and thus trace_vprintk can not
call back into lockdep without locking up.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8c6a902db40a..4c97947650ae 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -1176,7 +1176,8 @@ void trace_graph_return(struct ftrace_graph_ret *trace) | |||
1176 | */ | 1176 | */ |
1177 | int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args) | 1177 | int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args) |
1178 | { | 1178 | { |
1179 | static DEFINE_SPINLOCK(trace_buf_lock); | 1179 | static raw_spinlock_t trace_buf_lock = |
1180 | (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; | ||
1180 | static u32 trace_buf[TRACE_BUF_SIZE]; | 1181 | static u32 trace_buf[TRACE_BUF_SIZE]; |
1181 | 1182 | ||
1182 | struct ring_buffer_event *event; | 1183 | struct ring_buffer_event *event; |
@@ -1201,7 +1202,9 @@ int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args) | |||
1201 | if (unlikely(atomic_read(&data->disabled))) | 1202 | if (unlikely(atomic_read(&data->disabled))) |
1202 | goto out; | 1203 | goto out; |
1203 | 1204 | ||
1204 | spin_lock_irqsave(&trace_buf_lock, flags); | 1205 | /* Lockdep uses trace_printk for lock tracing */ |
1206 | local_irq_save(flags); | ||
1207 | __raw_spin_lock(&trace_buf_lock); | ||
1205 | len = vbin_printf(trace_buf, TRACE_BUF_SIZE, fmt, args); | 1208 | len = vbin_printf(trace_buf, TRACE_BUF_SIZE, fmt, args); |
1206 | 1209 | ||
1207 | if (len > TRACE_BUF_SIZE || len < 0) | 1210 | if (len > TRACE_BUF_SIZE || len < 0) |
@@ -1220,7 +1223,8 @@ int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args) | |||
1220 | ring_buffer_unlock_commit(tr->buffer, event); | 1223 | ring_buffer_unlock_commit(tr->buffer, event); |
1221 | 1224 | ||
1222 | out_unlock: | 1225 | out_unlock: |
1223 | spin_unlock_irqrestore(&trace_buf_lock, flags); | 1226 | __raw_spin_unlock(&trace_buf_lock); |
1227 | local_irq_restore(flags); | ||
1224 | 1228 | ||
1225 | out: | 1229 | out: |
1226 | ftrace_preempt_enable(resched); | 1230 | ftrace_preempt_enable(resched); |