linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] [PATCH] printk: Don't emit console_cpu_notify() for CPU_DYING
@ 2011-11-18  2:19 Yong Zhang
  2011-11-18 19:01 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Yong Zhang @ 2011-11-18  2:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Ingo Molnar, James Morris, Peter Zijlstra,
	Kevin Cernekee, Thomas Gleixner, Steven Rostedt

When running -rt, I got some warning when doing cpu hotplug,
for details please check:
http://marc.info/?l=linux-kernel&m=132143661616297&w=2

But seems the problem also exists in mainline, a typical
scenario is:

        CPU A                           CPU B

doing printk with console_sem held
                                take_cpu_down();
                                  cpu_notify(CPU_DYING);
                                    console_cpu_notify();
                                      console_lock();
                                        down(&console_sem);
                                          *BANG*
  up(&console_sem);


Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: James Morris <jmorris@namei.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Kevin Cernekee <cernekee@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/printk.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index 535bc3b..ba0393e 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1223,7 +1223,6 @@ static int __cpuinit console_cpu_notify(struct notifier_block *self,
 	switch (action) {
 	case CPU_ONLINE:
 	case CPU_DEAD:
-	case CPU_DYING:
 	case CPU_DOWN_FAILED:
 	case CPU_UP_CANCELED:
 		console_lock();
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC] [PATCH] printk: Don't emit console_cpu_notify() for CPU_DYING
  2011-11-18  2:19 [RFC] [PATCH] printk: Don't emit console_cpu_notify() for CPU_DYING Yong Zhang
@ 2011-11-18 19:01 ` Andrew Morton
  2011-11-19  5:15   ` Yong Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2011-11-18 19:01 UTC (permalink / raw)
  To: Yong Zhang
  Cc: linux-kernel, Ingo Molnar, James Morris, Peter Zijlstra,
	Kevin Cernekee, Thomas Gleixner, Steven Rostedt

On Fri, 18 Nov 2011 10:19:24 +0800
Yong Zhang <yong.zhang0@gmail.com> wrote:

> When running -rt, I got some warning when doing cpu hotplug,
> for details please check:
> http://marc.info/?l=linux-kernel&m=132143661616297&w=2
> 
> But seems the problem also exists in mainline, a typical
> scenario is:
> 
>         CPU A                           CPU B
> 
> doing printk with console_sem held
>                                 take_cpu_down();
>                                   cpu_notify(CPU_DYING);
>                                     console_cpu_notify();
>                                       console_lock();
>                                         down(&console_sem);
>                                           *BANG*
>   up(&console_sem);

This doesn't describe a deadlock.  For a deadlock to occur, something
must prevent CPU A from proceeding to the up().

Are you able to more fully describe this?  I'm suspecting that CPU A
got shut down by CPU B?  If so, shutting down a CPU while it holds
locks seems rather bad.  Or perhaps it's something else...



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC] [PATCH] printk: Don't emit console_cpu_notify() for CPU_DYING
  2011-11-18 19:01 ` Andrew Morton
@ 2011-11-19  5:15   ` Yong Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Yong Zhang @ 2011-11-19  5:15 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, Ingo Molnar, James Morris, Peter Zijlstra,
	Kevin Cernekee, Thomas Gleixner, Steven Rostedt

On Fri, Nov 18, 2011 at 11:01:00AM -0800, Andrew Morton wrote:
> On Fri, 18 Nov 2011 10:19:24 +0800
> Yong Zhang <yong.zhang0@gmail.com> wrote:
> 
> > When running -rt, I got some warning when doing cpu hotplug,
> > for details please check:
> > http://marc.info/?l=linux-kernel&m=132143661616297&w=2
> > 
> > But seems the problem also exists in mainline, a typical
> > scenario is:
> > 
> >         CPU A                           CPU B
> > 
> > doing printk with console_sem held
> >                                 take_cpu_down();
> >                                   cpu_notify(CPU_DYING);
> >                                     console_cpu_notify();
> >                                       console_lock();
> >                                         down(&console_sem);
> >                                           *BANG*
> >   up(&console_sem);
> 
> This doesn't describe a deadlock.  For a deadlock to occur, something
> must prevent CPU A from proceeding to the up().

Hmm, after revisting the code, seems console_unlock() can't be
preempted when helding console_sem. IOW, stop_machine() can't
run if someone loops in printing something.

So the problem only affect -rt, sorry for the noise.

Thanks,
Yong

> 
> Are you able to more fully describe this?  I'm suspecting that CPU A
> got shut down by CPU B?  If so, shutting down a CPU while it holds
> locks seems rather bad.  Or perhaps it's something else...

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-19  5:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-18  2:19 [RFC] [PATCH] printk: Don't emit console_cpu_notify() for CPU_DYING Yong Zhang
2011-11-18 19:01 ` Andrew Morton
2011-11-19  5:15   ` Yong Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).