* [PATCH] trace: disable preemption before taking raw spinlocks
@ 2009-05-26 15:28 Heiko Carstens
2009-05-26 21:51 ` Peter Zijlstra
0 siblings, 1 reply; 4+ messages in thread
From: Heiko Carstens @ 2009-05-26 15:28 UTC (permalink / raw)
To: Steven Rostedt, Ingo Molnar; +Cc: linux-kernel
From: Heiko Carstens <heiko.carstens@de.ibm.com>
s390 code uses smp_processor_id() in __raw_spin_lock() code which
reveals that a (raw) spinlock is taken without preemption disabled.
This can potentially deadlock.
To fix this explicitly disable and enable preemption.
BUG: using smp_processor_id() in preemptible [00000000] code: cat/2278
caller is trace_find_cmdline+0x40/0xfc
CPU: 0 Not tainted 2.6.30-rc7-dirty #39
Process cat (pid: 2278, task: 000000003faedb68, ksp: 000000003b33b988)
000000003b33b988 000000003b33bae0 0000000000000002 0000000000000000
000000003b33bb80 000000003b33baf8 000000003b33baf8 00000000000175d6
0000000000000001 000000003b33b988 000000003f9b0000 000000000000000b
000000000000000c 000000003b33bb40 000000003b33bae0 0000000000000000
0000000000000000 00000000000175d6 000000003b33bae0 000000003b33bb28
Call Trace:
([<00000000000174b2>] show_trace+0x112/0x170)
[<0000000000017582>] show_stack+0x72/0x100
[<0000000000441538>] dump_stack+0xc8/0xd8
[<000000000025c350>] debug_smp_processor_id+0x114/0x130
[<00000000000bf0e4>] trace_find_cmdline+0x40/0xfc
[<00000000000c35d4>] trace_print_context+0x58/0xac
[<00000000000bb676>] print_trace_line+0x416/0x470
[<00000000000bc8fe>] s_show+0x4e/0x428
[<000000000013834e>] seq_read+0x36a/0x5d4
[<0000000000112a78>] vfs_read+0xc8/0x174
[<0000000000112c58>] SyS_read+0x74/0xc4
[<000000000002c7ae>] sysc_noemu+0x10/0x16
[<000002000012436c>] 0x2000012436c
1 lock held by cat/2278:
#0: (&p->lock){+.+.+.}, at: [<0000000000138056>] seq_read+0x72/0x5d4
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
kernel/trace/trace.c | 2 ++
1 file changed, 2 insertions(+)
Index: linux-2.6/kernel/trace/trace.c
===================================================================
--- linux-2.6.orig/kernel/trace/trace.c
+++ linux-2.6/kernel/trace/trace.c
@@ -800,6 +800,7 @@ void trace_find_cmdline(int pid, char co
return;
}
+ preempt_disable();
__raw_spin_lock(&trace_cmdline_lock);
map = map_pid_to_cmdline[pid];
if (map != NO_CMDLINE_MAP)
@@ -808,6 +809,7 @@ void trace_find_cmdline(int pid, char co
strcpy(comm, "<...>");
__raw_spin_unlock(&trace_cmdline_lock);
+ preempt_enable();
}
void tracing_record_cmdline(struct task_struct *tsk)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] trace: disable preemption before taking raw spinlocks
2009-05-26 15:28 [PATCH] trace: disable preemption before taking raw spinlocks Heiko Carstens
@ 2009-05-26 21:51 ` Peter Zijlstra
2009-05-26 21:55 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2009-05-26 21:51 UTC (permalink / raw)
To: Heiko Carstens; +Cc: Steven Rostedt, Ingo Molnar, linux-kernel
On Tue, 2009-05-26 at 17:28 +0200, Heiko Carstens wrote:
> From: Heiko Carstens <heiko.carstens@de.ibm.com>
>
> s390 code uses smp_processor_id() in __raw_spin_lock() code which
> reveals that a (raw) spinlock is taken without preemption disabled.
> This can potentially deadlock.
>
> To fix this explicitly disable and enable preemption.
>
> BUG: using smp_processor_id() in preemptible [00000000] code: cat/2278
> caller is trace_find_cmdline+0x40/0xfc
> CPU: 0 Not tainted 2.6.30-rc7-dirty #39
> Process cat (pid: 2278, task: 000000003faedb68, ksp: 000000003b33b988)
> 000000003b33b988 000000003b33bae0 0000000000000002 0000000000000000
> 000000003b33bb80 000000003b33baf8 000000003b33baf8 00000000000175d6
> 0000000000000001 000000003b33b988 000000003f9b0000 000000000000000b
> 000000000000000c 000000003b33bb40 000000003b33bae0 0000000000000000
> 0000000000000000 00000000000175d6 000000003b33bae0 000000003b33bb28
> Call Trace:
> ([<00000000000174b2>] show_trace+0x112/0x170)
> [<0000000000017582>] show_stack+0x72/0x100
> [<0000000000441538>] dump_stack+0xc8/0xd8
> [<000000000025c350>] debug_smp_processor_id+0x114/0x130
> [<00000000000bf0e4>] trace_find_cmdline+0x40/0xfc
> [<00000000000c35d4>] trace_print_context+0x58/0xac
> [<00000000000bb676>] print_trace_line+0x416/0x470
> [<00000000000bc8fe>] s_show+0x4e/0x428
> [<000000000013834e>] seq_read+0x36a/0x5d4
> [<0000000000112a78>] vfs_read+0xc8/0x174
> [<0000000000112c58>] SyS_read+0x74/0xc4
> [<000000000002c7ae>] sysc_noemu+0x10/0x16
> [<000002000012436c>] 0x2000012436c
> 1 lock held by cat/2278:
> #0: (&p->lock){+.+.+.}, at: [<0000000000138056>] seq_read+0x72/0x5d4
Shouldn't that be preempt_disable_notrace() and co to avoid tracer
recursion?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] trace: disable preemption before taking raw spinlocks
2009-05-26 21:51 ` Peter Zijlstra
@ 2009-05-26 21:55 ` Steven Rostedt
2009-05-26 21:58 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2009-05-26 21:55 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Heiko Carstens, Ingo Molnar, linux-kernel
On Tue, 26 May 2009, Peter Zijlstra wrote:
> On Tue, 2009-05-26 at 17:28 +0200, Heiko Carstens wrote:
> > From: Heiko Carstens <heiko.carstens@de.ibm.com>
> >
> > s390 code uses smp_processor_id() in __raw_spin_lock() code which
> > reveals that a (raw) spinlock is taken without preemption disabled.
> > This can potentially deadlock.
> >
> > To fix this explicitly disable and enable preemption.
> >
> > BUG: using smp_processor_id() in preemptible [00000000] code: cat/2278
> > caller is trace_find_cmdline+0x40/0xfc
> > CPU: 0 Not tainted 2.6.30-rc7-dirty #39
> > Process cat (pid: 2278, task: 000000003faedb68, ksp: 000000003b33b988)
> > 000000003b33b988 000000003b33bae0 0000000000000002 0000000000000000
> > 000000003b33bb80 000000003b33baf8 000000003b33baf8 00000000000175d6
> > 0000000000000001 000000003b33b988 000000003f9b0000 000000000000000b
> > 000000000000000c 000000003b33bb40 000000003b33bae0 0000000000000000
> > 0000000000000000 00000000000175d6 000000003b33bae0 000000003b33bb28
> > Call Trace:
> > ([<00000000000174b2>] show_trace+0x112/0x170)
> > [<0000000000017582>] show_stack+0x72/0x100
> > [<0000000000441538>] dump_stack+0xc8/0xd8
> > [<000000000025c350>] debug_smp_processor_id+0x114/0x130
> > [<00000000000bf0e4>] trace_find_cmdline+0x40/0xfc
> > [<00000000000c35d4>] trace_print_context+0x58/0xac
> > [<00000000000bb676>] print_trace_line+0x416/0x470
> > [<00000000000bc8fe>] s_show+0x4e/0x428
> > [<000000000013834e>] seq_read+0x36a/0x5d4
> > [<0000000000112a78>] vfs_read+0xc8/0x174
> > [<0000000000112c58>] SyS_read+0x74/0xc4
> > [<000000000002c7ae>] sysc_noemu+0x10/0x16
> > [<000002000012436c>] 0x2000012436c
> > 1 lock held by cat/2278:
> > #0: (&p->lock){+.+.+.}, at: [<0000000000138056>] seq_read+0x72/0x5d4
>
> Shouldn't that be preempt_disable_notrace() and co to avoid tracer
> recursion?
Doesn't need to be. That function is done in the output (slow path), not
during an actual trace.
-- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] trace: disable preemption before taking raw spinlocks
2009-05-26 21:55 ` Steven Rostedt
@ 2009-05-26 21:58 ` Steven Rostedt
0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2009-05-26 21:58 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Heiko Carstens, Ingo Molnar, linux-kernel
On Tue, 26 May 2009, Steven Rostedt wrote:
>
> On Tue, 26 May 2009, Peter Zijlstra wrote:
>
> > On Tue, 2009-05-26 at 17:28 +0200, Heiko Carstens wrote:
> > > From: Heiko Carstens <heiko.carstens@de.ibm.com>
> > >
> > > s390 code uses smp_processor_id() in __raw_spin_lock() code which
> > > reveals that a (raw) spinlock is taken without preemption disabled.
> > > This can potentially deadlock.
> > >
> > > To fix this explicitly disable and enable preemption.
> > >
> > > BUG: using smp_processor_id() in preemptible [00000000] code: cat/2278
> > > caller is trace_find_cmdline+0x40/0xfc
> > > CPU: 0 Not tainted 2.6.30-rc7-dirty #39
> > > Process cat (pid: 2278, task: 000000003faedb68, ksp: 000000003b33b988)
> > > 000000003b33b988 000000003b33bae0 0000000000000002 0000000000000000
> > > 000000003b33bb80 000000003b33baf8 000000003b33baf8 00000000000175d6
> > > 0000000000000001 000000003b33b988 000000003f9b0000 000000000000000b
> > > 000000000000000c 000000003b33bb40 000000003b33bae0 0000000000000000
> > > 0000000000000000 00000000000175d6 000000003b33bae0 000000003b33bb28
> > > Call Trace:
> > > ([<00000000000174b2>] show_trace+0x112/0x170)
> > > [<0000000000017582>] show_stack+0x72/0x100
> > > [<0000000000441538>] dump_stack+0xc8/0xd8
> > > [<000000000025c350>] debug_smp_processor_id+0x114/0x130
> > > [<00000000000bf0e4>] trace_find_cmdline+0x40/0xfc
> > > [<00000000000c35d4>] trace_print_context+0x58/0xac
> > > [<00000000000bb676>] print_trace_line+0x416/0x470
> > > [<00000000000bc8fe>] s_show+0x4e/0x428
> > > [<000000000013834e>] seq_read+0x36a/0x5d4
> > > [<0000000000112a78>] vfs_read+0xc8/0x174
> > > [<0000000000112c58>] SyS_read+0x74/0xc4
> > > [<000000000002c7ae>] sysc_noemu+0x10/0x16
> > > [<000002000012436c>] 0x2000012436c
> > > 1 lock held by cat/2278:
> > > #0: (&p->lock){+.+.+.}, at: [<0000000000138056>] seq_read+0x72/0x5d4
> >
> > Shouldn't that be preempt_disable_notrace() and co to avoid tracer
> > recursion?
>
> Doesn't need to be. That function is done in the output (slow path), not
> during an actual trace.
Oh, and I should also include:
Acked-by: Steven Rostedt <rostedt@goodmis.org>
-- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-05-26 21:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-26 15:28 [PATCH] trace: disable preemption before taking raw spinlocks Heiko Carstens
2009-05-26 21:51 ` Peter Zijlstra
2009-05-26 21:55 ` Steven Rostedt
2009-05-26 21:58 ` Steven Rostedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.