Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1450788 > unrolled thread

[PATCH 0/1] (Was: introduce for_each_process_thread_{break,continue}() helpers)

Started byOleg Nesterov <oleg@redhat.com>
First post2016-07-26 21:00 +0200
Last post2016-07-27 12:50 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 0/1] (Was: introduce  for_each_process_thread_{break,continue}() helpers) Oleg Nesterov <oleg@redhat.com> - 2016-07-26 21:00 +0200
    [PATCH 1/1] stop_machine: touch_nmi_watchdog() after  MULTI_STOP_PREPARE Oleg Nesterov <oleg@redhat.com> - 2016-07-26 21:00 +0200
      Re: [PATCH 1/1] stop_machine: touch_nmi_watchdog() after  MULTI_STOP_PREPARE Thomas Gleixner <tglx@linutronix.de> - 2016-07-27 10:10 +0200
      [tip:core/urgent] stop_machine: Touch_nmi_watchdog() after  MULTI_STOP_PREPARE tip-bot for Oleg Nesterov <tipbot@zytor.com> - 2016-07-27 12:50 +0200

#1450788 — [PATCH 0/1] (Was: introduce for_each_process_thread_{break,continue}() helpers)

FromOleg Nesterov <oleg@redhat.com>
Date2016-07-26 21:00 +0200
Subject[PATCH 0/1] (Was: introduce for_each_process_thread_{break,continue}() helpers)
Message-ID<rZfK9-5Fs-9@gated-at.bofh.it>
On 07/25, Oleg Nesterov wrote:
>
> IMHO this makes sense in any case, but mostly this is preparation for
> another change: show_state_filter() should be preemptible. But this needs
> more discussion, I'll write another email/patch when I fully understand
> the hard-lockup caused by sysrq-t.

Yes, we need to do something with show_state_filter() anyway, I think.

OTOH, I believe this simple change in multi_cpu_stop() makes sense too
regardless.

Oleg.

[toc] | [next] | [standalone]


#1450791 — [PATCH 1/1] stop_machine: touch_nmi_watchdog() after MULTI_STOP_PREPARE

FromOleg Nesterov <oleg@redhat.com>
Date2016-07-26 21:00 +0200
Subject[PATCH 1/1] stop_machine: touch_nmi_watchdog() after MULTI_STOP_PREPARE
Message-ID<rZfKa-5Fs-13@gated-at.bofh.it>
In reply to#1450788
Suppose that stop_machine(fn) hangs because fn() hangs. In this case NMI
hard-lockup can be triggered on another CPU which does nothing wrong and
the trace from nmi_panic() won't help to investigate the problem.

And this change "fixes" the problem we (seem to) hit in practice.

- stop_two_cpus(0, 1) races with show_state_filter() running on CPU_0.

- CPU_1 already spins in MULTI_STOP_PREPARE state, it detects the soft
  lockup and tries to report the problem.

- show_state_filter() enables preemption, CPU_0 calls multi_cpu_stop()
  which goes to MULTI_STOP_DISABLE_IRQ state and disables interrupts.

- CPU_1 spends more than 10 seconds trying to flush the log buffer to
  the slow serial console.

- NMI interrupt on CPU_0 (which now waits for CPU_1) calls nmi_panic().

Reported-by: Wang Shu <shuwang@redhat.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/stop_machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index a467e6c..4a1ca5f 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -21,6 +21,7 @@
 #include <linux/smpboot.h>
 #include <linux/atomic.h>
 #include <linux/lglock.h>
+#include <linux/nmi.h>
 
 /*
  * Structure to determine completion condition and record errors.  May
@@ -209,6 +210,13 @@ static int multi_cpu_stop(void *data)
 				break;
 			}
 			ack_state(msdata);
+		} else if (curstate > MULTI_STOP_PREPARE) {
+			/*
+			 * At this stage all other CPUs we depend on must spin
+			 * in the same loop. Any reason for hard-lockup should
+			 * be detected and reported on their side.
+			 */
+			touch_nmi_watchdog();
 		}
 	} while (curstate != MULTI_STOP_EXIT);
 
-- 
2.5.0

[toc] | [prev] | [next] | [standalone]


#1451108 — Re: [PATCH 1/1] stop_machine: touch_nmi_watchdog() after MULTI_STOP_PREPARE

FromThomas Gleixner <tglx@linutronix.de>
Date2016-07-27 10:10 +0200
SubjectRe: [PATCH 1/1] stop_machine: touch_nmi_watchdog() after MULTI_STOP_PREPARE
Message-ID<rZs4G-5fF-13@gated-at.bofh.it>
In reply to#1450791
On Tue, 26 Jul 2016, Oleg Nesterov wrote:
> Suppose that stop_machine(fn) hangs because fn() hangs. In this case NMI
> hard-lockup can be triggered on another CPU which does nothing wrong and
> the trace from nmi_panic() won't help to investigate the problem.
> 
> And this change "fixes" the problem we (seem to) hit in practice.
> 
> - stop_two_cpus(0, 1) races with show_state_filter() running on CPU_0.
> 
> - CPU_1 already spins in MULTI_STOP_PREPARE state, it detects the soft
>   lockup and tries to report the problem.
> 
> - show_state_filter() enables preemption, CPU_0 calls multi_cpu_stop()
>   which goes to MULTI_STOP_DISABLE_IRQ state and disables interrupts.
> 
> - CPU_1 spends more than 10 seconds trying to flush the log buffer to
>   the slow serial console.
> 
> - NMI interrupt on CPU_0 (which now waits for CPU_1) calls nmi_panic().
> 
> Reported-by: Wang Shu <shuwang@redhat.com>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

> ---
>  kernel/stop_machine.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
> index a467e6c..4a1ca5f 100644
> --- a/kernel/stop_machine.c
> +++ b/kernel/stop_machine.c
> @@ -21,6 +21,7 @@
>  #include <linux/smpboot.h>
>  #include <linux/atomic.h>
>  #include <linux/lglock.h>
> +#include <linux/nmi.h>
>  
>  /*
>   * Structure to determine completion condition and record errors.  May
> @@ -209,6 +210,13 @@ static int multi_cpu_stop(void *data)
>  				break;
>  			}
>  			ack_state(msdata);
> +		} else if (curstate > MULTI_STOP_PREPARE) {
> +			/*
> +			 * At this stage all other CPUs we depend on must spin
> +			 * in the same loop. Any reason for hard-lockup should
> +			 * be detected and reported on their side.
> +			 */
> +			touch_nmi_watchdog();
>  		}
>  	} while (curstate != MULTI_STOP_EXIT);
>  
> -- 
> 2.5.0
> 
> 
> 

[toc] | [prev] | [next] | [standalone]


#1451223 — [tip:core/urgent] stop_machine: Touch_nmi_watchdog() after MULTI_STOP_PREPARE

Fromtip-bot for Oleg Nesterov <tipbot@zytor.com>
Date2016-07-27 12:50 +0200
Subject[tip:core/urgent] stop_machine: Touch_nmi_watchdog() after MULTI_STOP_PREPARE
Message-ID<rZuzw-6GJ-17@gated-at.bofh.it>
In reply to#1450791
Commit-ID:  ce4f06dcbb5d6d04d202f1b81ac72d5679dcdfc0
Gitweb:     http://git.kernel.org/tip/ce4f06dcbb5d6d04d202f1b81ac72d5679dcdfc0
Author:     Oleg Nesterov <oleg@redhat.com>
AuthorDate: Tue, 26 Jul 2016 20:57:36 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 27 Jul 2016 11:12:11 +0200

stop_machine: Touch_nmi_watchdog() after MULTI_STOP_PREPARE

Suppose that stop_machine(fn) hangs because fn() hangs. In this case NMI
hard-lockup can be triggered on another CPU which does nothing wrong and
the trace from nmi_panic() won't help to investigate the problem.

And this change "fixes" the problem we (seem to) hit in practice.

 - stop_two_cpus(0, 1) races with show_state_filter() running on CPU_0.

 - CPU_1 already spins in MULTI_STOP_PREPARE state, it detects the soft
   lockup and tries to report the problem.

 - show_state_filter() enables preemption, CPU_0 calls multi_cpu_stop()
   which goes to MULTI_STOP_DISABLE_IRQ state and disables interrupts.

 - CPU_1 spends more than 10 seconds trying to flush the log buffer to
   the slow serial console.

 - NMI interrupt on CPU_0 (which now waits for CPU_1) calls nmi_panic().

Reported-by: Wang Shu <shuwang@redhat.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dave Anderson <anderson@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/20160726185736.GB4088@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/stop_machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index a467e6c..4a1ca5f 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -21,6 +21,7 @@
 #include <linux/smpboot.h>
 #include <linux/atomic.h>
 #include <linux/lglock.h>
+#include <linux/nmi.h>
 
 /*
  * Structure to determine completion condition and record errors.  May
@@ -209,6 +210,13 @@ static int multi_cpu_stop(void *data)
 				break;
 			}
 			ack_state(msdata);
+		} else if (curstate > MULTI_STOP_PREPARE) {
+			/*
+			 * At this stage all other CPUs we depend on must spin
+			 * in the same loop. Any reason for hard-lockup should
+			 * be detected and reported on their side.
+			 */
+			touch_nmi_watchdog();
 		}
 	} while (curstate != MULTI_STOP_EXIT);
 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web