Files
Seiji Aguchi 68412b1718 pstore: Avoid deadlock in panic and emergency-restart path
commit 9f244e9cfd upstream.

[Issue]

When pstore is in panic and emergency-restart paths, it may be blocked
in those paths because it simply takes spin_lock.

This is an example scenario which pstore may hang up in a panic path:

 - cpuA grabs psinfo->buf_lock
 - cpuB panics and calls smp_send_stop
 - smp_send_stop sends IRQ to cpuA
 - after 1 second, cpuB gives up on cpuA and sends an NMI instead
 - cpuA is now in an NMI handler while still holding buf_lock
 - cpuB is deadlocked

This case may happen if a firmware has a bug and
cpuA is stuck talking with it more than one second.

Also, this is a similar scenario in an emergency-restart path:

 - cpuA grabs psinfo->buf_lock and stucks in a firmware
 - cpuB kicks emergency-restart via either sysrq-b or hangcheck timer.
   And then, cpuB is deadlocked by taking psinfo->buf_lock again.

[Solution]

This patch avoids the deadlocking issues in both panic and emergency_restart
paths by introducing a function, is_non_blocking_path(), to check if a cpu
can be blocked in current path.

With this patch, pstore is not blocked even if another cpu has
taken a spin_lock, in those paths by changing from spin_lock_irqsave
to spin_trylock_irqsave.

In addition, according to a comment of emergency_restart() in kernel/sys.c,
spin_lock shouldn't be taken in an emergency_restart path to avoid
deadlock. This patch fits the comment below.

<snip>
/**
 *      emergency_restart - reboot the system
 *
 *      Without shutting down any hardware or taking any locks
 *      reboot the system.  This is called when we know we are in
 *      trouble so this is our best effort to reboot.  This is
 *      safe to call in interrupt context.
 */
void emergency_restart(void)
<snip>

Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Cc: CAI Qian <caiqian@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-03-04 06:06:43 +08:00
..
2013-01-17 08:51:20 -08:00
2012-11-26 11:38:03 -08:00
2012-04-23 14:23:32 +03:00
2012-11-17 13:16:12 -08:00
2009-04-01 08:59:23 -07:00
2011-03-22 17:43:59 -07:00
2008-10-20 08:52:42 -07:00
2011-03-11 14:25:50 +00:00
2011-08-03 11:30:42 -04:00
2008-06-06 11:29:10 -07:00
2005-04-16 15:20:36 -07:00
2011-07-26 16:49:47 -07:00
2011-03-31 11:26:23 -03:00
2010-10-25 08:02:40 -07:00
2005-04-16 15:20:36 -07:00
2012-02-28 16:02:54 +01:00
2005-04-16 15:20:36 -07:00
2011-03-31 11:26:23 -03:00
2011-12-13 09:26:45 +00:00
2012-03-20 21:29:53 -04:00
2010-08-04 11:00:45 +02:00
2007-02-09 17:39:36 -05:00
2009-11-04 09:50:58 -08:00
2011-05-24 10:21:29 +02:00
2009-01-30 23:46:40 +05:30
2008-01-28 23:21:18 +01:00
2011-12-11 18:25:16 -05:00
2011-09-14 15:24:51 -04:00
2011-03-31 11:26:23 -03:00
2011-01-12 20:16:43 -05:00
2005-04-16 15:20:36 -07:00
2011-01-10 08:51:44 -08:00
2005-04-16 15:20:36 -07:00
2012-04-12 12:57:08 +02:00
2009-06-18 13:04:05 -07:00
2012-03-26 21:47:19 +02:00
2008-08-02 18:36:10 +01:00
2012-10-02 10:30:35 -07:00
2012-01-03 22:55:17 -05:00
2009-04-21 13:41:48 -07:00
2012-08-15 08:10:29 -07:00
2012-07-19 08:59:00 -07:00
2012-01-17 15:40:51 -08:00
2011-09-16 19:20:20 -04:00
2007-07-17 10:23:03 -07:00
2012-03-15 21:41:34 +01:00
2007-05-09 12:30:49 -07:00
2012-10-02 10:30:05 -07:00
2012-12-17 10:37:42 -08:00
2009-09-22 07:17:35 -07:00
2006-11-30 04:40:22 +01:00
2008-06-06 11:29:12 -07:00
2011-07-26 16:49:47 -07:00
2012-08-09 08:31:30 -07:00
2012-03-21 17:54:58 -07:00
2011-01-16 13:47:07 -05:00
2005-04-16 15:20:36 -07:00
2011-05-26 17:12:37 -07:00
2012-03-16 21:49:24 +01:00
2011-01-13 08:03:21 -08:00
2011-03-31 11:26:23 -03:00
2012-08-15 08:10:29 -07:00
2010-09-08 18:16:55 -07:00
2011-06-07 10:02:35 +02:00
2008-02-07 08:42:34 -08:00
2012-03-08 11:38:50 -08:00
2012-07-16 09:03:48 -07:00
2013-01-11 09:07:15 -08:00
2012-07-16 09:04:42 -07:00
2010-08-09 16:48:44 -04:00
2011-10-31 17:30:47 -07:00
2012-01-03 22:54:56 -05:00
2008-10-13 09:51:40 -07:00
2010-11-29 08:55:25 +11:00
2012-03-28 18:30:03 +01:00
2012-04-10 22:39:17 -06:00
2005-04-16 15:20:36 -07:00
2011-11-02 16:07:02 -07:00
2011-07-26 16:49:47 -07:00
2012-03-28 18:30:03 +01:00