All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@mellanox.com>
To: Peter Zijlstra <peterz@infradead.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Petr Mladek <pmladek@suse.com>,
	Russell King <linux@arm.linux.org.uk>,
	Thomas Gleixner <tglx@linutronix.de>,
	Aaron Tomlin <atomlin@redhat.com>, Ingo Molnar <mingo@redhat.com>,
	Andrew Morton <akpm@osdl.org>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Subject: [PATCH v4 2/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI
Date: Wed, 30 Mar 2016 13:16:08 -0400	[thread overview]
Message-ID: <1459358170-27745-3-git-send-email-cmetcalf@mellanox.com> (raw)
In-Reply-To: <1459358170-27745-1-git-send-email-cmetcalf@mellanox.com>

Currently on arm there is code that checks whether it should call
dump_stack() explicitly, to avoid trying to raise an NMI when the
current context is not preemptible by the backtrace IPI.  Similarly,
the forthcoming arch/tile support uses an IPI mechanism that does
not support generating an NMI to self.

Accordingly, move the code that guards this case into the generic
mechanism, and invoke it unconditionally whenever we want a
backtrace of the current cpu.  It seems plausible that in all cases,
dump_stack() will generate better information than generating a
stack from the NMI handler.  The register state will be missing,
but that state is likely not particularly helpful in any case.

Or, if we think it is helpful, we should be capturing and emitting
the current register state in all cases when regs == NULL is passed
to nmi_cpu_backtrace().

Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
---
 arch/arm/kernel/smp.c | 9 ---------
 lib/nmi_backtrace.c   | 9 +++++++++
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 72ad8485993a..07223f2a3ee0 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -746,15 +746,6 @@ core_initcall(register_cpufreq_notifier);
 
 static void raise_nmi(cpumask_t *mask)
 {
-	/*
-	 * Generate the backtrace directly if we are running in a calling
-	 * context that is not preemptible by the backtrace IPI. Note
-	 * that nmi_cpu_backtrace() automatically removes the current cpu
-	 * from mask.
-	 */
-	if (cpumask_test_cpu(smp_processor_id(), mask) && irqs_disabled())
-		nmi_cpu_backtrace(NULL);
-
 	smp_cross_call(mask, IPI_CPU_BACKTRACE);
 }
 
diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c
index db63ac75eba0..9375c0279b73 100644
--- a/lib/nmi_backtrace.c
+++ b/lib/nmi_backtrace.c
@@ -76,6 +76,15 @@ void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
 		seq_buf_init(&s->seq, s->buffer, NMI_BUF_SIZE);
 	}
 
+	/*
+	 * Don't try to send an NMI to this cpu; it may work on some
+	 * architectures, but on others it may not, and we'll get
+	 * information at least as useful just by doing a dump_stack() here.
+	 * Note that nmi_cpu_backtrace(NULL) will clear the cpu bit.
+	 */
+	if (cpumask_test_cpu(this_cpu, to_cpumask(backtrace_mask)))
+		nmi_cpu_backtrace(NULL);
+
 	if (!cpumask_empty(to_cpumask(backtrace_mask))) {
 		pr_info("Sending NMI from CPU %d to CPUs %*pbl:\n",
 			this_cpu, nr_cpumask_bits, to_cpumask(backtrace_mask));
-- 
2.7.2

WARNING: multiple messages have this Message-ID (diff)
From: cmetcalf@mellanox.com (Chris Metcalf)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 2/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI
Date: Wed, 30 Mar 2016 13:16:08 -0400	[thread overview]
Message-ID: <1459358170-27745-3-git-send-email-cmetcalf@mellanox.com> (raw)
In-Reply-To: <1459358170-27745-1-git-send-email-cmetcalf@mellanox.com>

Currently on arm there is code that checks whether it should call
dump_stack() explicitly, to avoid trying to raise an NMI when the
current context is not preemptible by the backtrace IPI.  Similarly,
the forthcoming arch/tile support uses an IPI mechanism that does
not support generating an NMI to self.

Accordingly, move the code that guards this case into the generic
mechanism, and invoke it unconditionally whenever we want a
backtrace of the current cpu.  It seems plausible that in all cases,
dump_stack() will generate better information than generating a
stack from the NMI handler.  The register state will be missing,
but that state is likely not particularly helpful in any case.

Or, if we think it is helpful, we should be capturing and emitting
the current register state in all cases when regs == NULL is passed
to nmi_cpu_backtrace().

Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
---
 arch/arm/kernel/smp.c | 9 ---------
 lib/nmi_backtrace.c   | 9 +++++++++
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 72ad8485993a..07223f2a3ee0 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -746,15 +746,6 @@ core_initcall(register_cpufreq_notifier);
 
 static void raise_nmi(cpumask_t *mask)
 {
-	/*
-	 * Generate the backtrace directly if we are running in a calling
-	 * context that is not preemptible by the backtrace IPI. Note
-	 * that nmi_cpu_backtrace() automatically removes the current cpu
-	 * from mask.
-	 */
-	if (cpumask_test_cpu(smp_processor_id(), mask) && irqs_disabled())
-		nmi_cpu_backtrace(NULL);
-
 	smp_cross_call(mask, IPI_CPU_BACKTRACE);
 }
 
diff --git a/lib/nmi_backtrace.c b/lib/nmi_backtrace.c
index db63ac75eba0..9375c0279b73 100644
--- a/lib/nmi_backtrace.c
+++ b/lib/nmi_backtrace.c
@@ -76,6 +76,15 @@ void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
 		seq_buf_init(&s->seq, s->buffer, NMI_BUF_SIZE);
 	}
 
+	/*
+	 * Don't try to send an NMI to this cpu; it may work on some
+	 * architectures, but on others it may not, and we'll get
+	 * information at least as useful just by doing a dump_stack() here.
+	 * Note that nmi_cpu_backtrace(NULL) will clear the cpu bit.
+	 */
+	if (cpumask_test_cpu(this_cpu, to_cpumask(backtrace_mask)))
+		nmi_cpu_backtrace(NULL);
+
 	if (!cpumask_empty(to_cpumask(backtrace_mask))) {
 		pr_info("Sending NMI from CPU %d to CPUs %*pbl:\n",
 			this_cpu, nr_cpumask_bits, to_cpumask(backtrace_mask));
-- 
2.7.2

  parent reply	other threads:[~2016-03-30 17:16 UTC|newest]

Thread overview: 121+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29 21:40 [PATCH 0/4] improvements to the nmi_backtrace code Chris Metcalf
2016-02-29 21:40 ` Chris Metcalf
2016-02-29 21:40 ` [PATCH 1/4] nmi_backtrace: add more trigger_*_cpu_backtrace() methods Chris Metcalf
2016-02-29 21:40   ` Chris Metcalf
2016-02-29 21:40 ` [PATCH 2/4] nmi_backtrace: generate one-line reports for idle cpus Chris Metcalf
2016-03-01 14:23   ` Daniel Thompson
2016-03-01 16:01     ` Chris Metcalf
2016-03-07  8:26       ` Daniel Thompson
2016-03-07 17:05         ` Chris Metcalf
2016-03-07  9:48       ` Peter Zijlstra
2016-03-07 17:38         ` Chris Metcalf
2016-03-07 20:43           ` Peter Zijlstra
2016-03-16 17:02             ` [PATCH v2 0/4] improvements to the nmi_backtrace code Chris Metcalf
2016-03-16 17:02               ` Chris Metcalf
2016-03-16 17:02               ` Chris Metcalf
2016-03-16 17:02               ` Chris Metcalf
2016-03-16 17:02               ` [PATCH v2 1/4] nmi_backtrace: add more trigger_*_cpu_backtrace() methods Chris Metcalf
2016-03-16 17:02                 ` Chris Metcalf
2016-03-17 19:36                 ` Peter Zijlstra
2016-03-17 19:36                   ` Peter Zijlstra
2016-03-17 22:31                   ` Chris Metcalf
2016-03-17 22:31                     ` Chris Metcalf
2016-03-17 22:38                     ` Peter Zijlstra
2016-03-17 22:38                       ` Peter Zijlstra
2016-03-17 22:41                       ` Chris Metcalf
2016-03-17 22:41                         ` Chris Metcalf
2016-03-17 23:14                         ` Peter Zijlstra
2016-03-17 23:14                           ` Peter Zijlstra
2016-03-17 22:55                   ` Paul E. McKenney
2016-03-17 22:55                     ` Paul E. McKenney
2016-03-17 23:09                     ` Peter Zijlstra
2016-03-17 23:09                       ` Peter Zijlstra
2016-03-17 23:11                     ` Peter Zijlstra
2016-03-17 23:11                       ` Peter Zijlstra
2016-03-18  0:28                       ` Paul E. McKenney
2016-03-18  0:28                         ` Paul E. McKenney
2016-03-18  0:17                     ` Chris Metcalf
2016-03-18  0:17                       ` Chris Metcalf
2016-03-18  0:33                       ` Paul E. McKenney
2016-03-18  0:33                         ` Paul E. McKenney
2016-03-18  9:40                         ` Daniel Thompson
2016-03-18  9:40                           ` Daniel Thompson
2016-03-18 23:54                           ` Paul E. McKenney
2016-03-18 23:54                             ` Paul E. McKenney
2016-03-16 17:02               ` [PATCH v2 2/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI Chris Metcalf
2016-03-16 17:02                 ` Chris Metcalf
2016-03-16 17:02               ` [PATCH v2 3/4] arch/tile: adopt the new nmi_backtrace framework Chris Metcalf
2016-03-16 17:02               ` [PATCH v2 4/4] nmi_backtrace: generate one-line reports for idle cpus Chris Metcalf
2016-03-16 17:02                 ` Chris Metcalf
2016-03-16 17:02                 ` Chris Metcalf
2016-03-16 18:46                 ` kbuild test robot
2016-03-16 18:46                   ` kbuild test robot
2016-03-16 18:46                   ` kbuild test robot
2016-03-16 18:46                   ` kbuild test robot
2016-03-21 15:38                 ` Peter Zijlstra
2016-03-21 15:38                   ` Peter Zijlstra
2016-03-21 15:38                   ` Peter Zijlstra
2016-03-21 15:46                   ` Chris Metcalf
2016-03-21 15:46                     ` Chris Metcalf
2016-03-21 15:46                     ` Chris Metcalf
2016-03-21 15:46                     ` Chris Metcalf
2016-03-21 15:42                 ` Peter Zijlstra
2016-03-21 15:42                   ` Peter Zijlstra
2016-03-21 16:15                   ` Chris Metcalf
2016-03-21 16:15                     ` Chris Metcalf
2016-03-21 16:15                     ` Chris Metcalf
2016-03-21 16:32                     ` Peter Zijlstra
2016-03-21 16:32                       ` Peter Zijlstra
2016-03-21 17:12                       ` Chris Metcalf
2016-03-21 17:12                         ` Chris Metcalf
2016-03-21 17:12                         ` Chris Metcalf
2016-03-21 17:12                         ` Chris Metcalf
2016-03-21 17:17                         ` Peter Zijlstra
2016-03-21 17:17                           ` Peter Zijlstra
2016-03-21 16:48                 ` Peter Zijlstra
2016-03-21 16:48                   ` Peter Zijlstra
2016-03-21 21:49                 ` Peter Zijlstra
2016-03-21 21:49                   ` Peter Zijlstra
2016-03-22 17:19                   ` [PATCH v3 0/4] improvements to the nmi_backtrace code Chris Metcalf
2016-03-22 17:19                     ` Chris Metcalf
2016-03-22 17:19                     ` Chris Metcalf
2016-03-22 17:19                     ` Chris Metcalf
2016-03-22 17:19                     ` [PATCH v3 1/4] nmi_backtrace: add more trigger_*_cpu_backtrace() methods Chris Metcalf
2016-03-22 17:19                       ` Chris Metcalf
2016-03-22 17:19                     ` [PATCH v3 2/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI Chris Metcalf
2016-03-22 17:19                       ` Chris Metcalf
2016-03-22 17:19                     ` [PATCH v3 3/4] arch/tile: adopt the new nmi_backtrace framework Chris Metcalf
2016-03-22 17:19                     ` [PATCH v3 4/4] nmi_backtrace: generate one-line reports for idle cpus Chris Metcalf
2016-03-22 17:19                       ` Chris Metcalf
2016-03-22 17:19                       ` Chris Metcalf
2016-03-22 17:30                       ` Peter Zijlstra
2016-03-22 17:30                         ` Peter Zijlstra
2016-03-22 22:28                         ` Rafael J. Wysocki
2016-03-22 22:28                           ` Rafael J. Wysocki
2016-03-22 22:31                       ` Rafael J. Wysocki
2016-03-22 22:31                         ` Rafael J. Wysocki
2016-03-22 22:45                         ` Peter Zijlstra
2016-03-22 22:45                           ` Peter Zijlstra
2016-03-23  0:50                           ` Rafael J. Wysocki
2016-03-23  0:50                             ` Rafael J. Wysocki
2016-03-23  7:53                             ` Peter Zijlstra
2016-03-23  7:53                               ` Peter Zijlstra
2016-03-30 17:16                             ` [PATCH v4 0/4] improvements to the nmi_backtrace code Chris Metcalf
2016-03-30 17:16                               ` Chris Metcalf
2016-03-30 17:16                               ` Chris Metcalf
2016-03-30 17:16                               ` Chris Metcalf
2016-03-30 17:16                               ` [PATCH v4 1/4] nmi_backtrace: add more trigger_*_cpu_backtrace() methods Chris Metcalf
2016-03-30 17:16                                 ` Chris Metcalf
2016-03-30 17:16                               ` Chris Metcalf [this message]
2016-03-30 17:16                                 ` [PATCH v4 2/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI Chris Metcalf
2016-03-30 17:16                               ` [PATCH v4 3/4] arch/tile: adopt the new nmi_backtrace framework Chris Metcalf
2016-03-30 17:16                               ` [PATCH v4 4/4] nmi_backtrace: generate one-line reports for idle cpus Chris Metcalf
2016-03-30 17:16                                 ` Chris Metcalf
2016-03-30 17:16                                 ` Chris Metcalf
2016-02-29 21:40 ` [PATCH 3/4] nmi_backtrace: do a local dump_stack() instead of a self-NMI Chris Metcalf
2016-02-29 21:40   ` Chris Metcalf
2016-02-29 21:40 ` [PATCH 4/4] arch/tile: adopt the new nmi_backtrace framework Chris Metcalf
2016-03-01  0:49 ` [PATCH 0/4] improvements to the nmi_backtrace code Andrew Morton
2016-03-01  0:49   ` Andrew Morton
2016-03-01 10:01   ` Petr Mladek
2016-03-01 10:01     ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1459358170-27745-3-git-send-email-cmetcalf@mellanox.com \
    --to=cmetcalf@mellanox.com \
    --cc=akpm@osdl.org \
    --cc=atomlin@redhat.com \
    --cc=daniel.thompson@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.