linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4 v2] nmi: Provide the option to issue an NMI back trace to every cpu but current
  2014-04-04 20:47 [PATCH 0/4 V2] Print traces on softlockups Don Zickus
@ 2014-04-04 20:47 ` Don Zickus
  0 siblings, 0 replies; 3+ messages in thread
From: Don Zickus @ 2014-04-04 20:47 UTC (permalink / raw)
  To: LKML; +Cc: akpm, x86, davem, sparclinux, mguzik, Aaron Tomlin, Don Zickus

From: Aaron Tomlin <atomlin@redhat.com>

Some times it is preferred not to use the
trigger_all_cpu_backtrace() routine when one wants
to avoid capturing a back trace for current.
For instance if one was previously captured
recently.

This patch provides a new routine namely
trigger_allbutself_cpu_backtrace() which offers
the flexibility to issue an NMI to every cpu but
current and capture a back trace accordingly.

[Added stub in #else clause - dcz]

Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
Signed-off-by: Don Zickus <dzickus@redhat.com>
---
 include/linux/nmi.h |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index 6a45fb5..a17ab63 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -32,15 +32,24 @@ static inline void touch_nmi_watchdog(void)
 #ifdef arch_trigger_all_cpu_backtrace
 static inline bool trigger_all_cpu_backtrace(void)
 {
-	arch_trigger_all_cpu_backtrace();
+	arch_trigger_all_cpu_backtrace(true);
 
 	return true;
 }
+static inline bool trigger_allbutself_cpu_backtrace(void)
+{
+	arch_trigger_all_cpu_backtrace(false);
+	return true;
+}
 #else
 static inline bool trigger_all_cpu_backtrace(void)
 {
 	return false;
 }
+static inline bool trigger_allbutself_cpu_backtrace(void)
+{
+	return false;
+}
 #endif
 
 #ifdef CONFIG_LOCKUP_DETECTOR
-- 
1.7.1


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

* [PATCH 1/4 v2] nmi: Provide the option to issue an NMI back trace to every cpu but current
       [not found]     ` <20140421132100.GW8488@redhat.com>
@ 2014-04-21 13:41       ` Oleg Nesterov
  2014-04-21 15:47         ` Don Zickus
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2014-04-21 13:41 UTC (permalink / raw)
  To: Don Zickus; +Cc: Aaron Tomlin, mingo, mingo, linux-kernel

On 04/21, Don Zickus wrote:
>
> On Tue, Apr 15, 2014 at 07:26:49PM +0200, Oleg Nesterov wrote:
> > On 04/15, Oleg Nesterov wrote:
> > >
> > > Looking at https://lkml.org/lkml/2014/4/4/469... It seems that 2/4 can be
> > > simplified, you can simply remove smp_processor_id() from backtrace_mask
> > > if !include_self and use apic->send_IPI_mask(backtrace_mask). But this is
> > > minor, I won't insist.
> >
> > And in fact, I do not understand why arch_trigger_all_cpu_backtrace() doesn't
> > disable preemption. OK, probably we can simply ignore the race with cpu hotplug.
> >
> > But it seems that your patch makes the things worse. Lets look at, say,
> > numachip_send_IPI_mask_allbutself(). The usage of smp_processor_id() is
> > obviously racy but perhaps we do not care again. But we do not want a warning
> > from debug_smp_processor_id().
>
> Good point.  I forgot that going from all cpus down to allbutself,
> preemption now matters.

I am not sure it actually matters wrt "show other CPU's traces". If the preemption
is possible then the caller can be preempted even before it sends ipi.

OTOH I think it does matter anyway, even without your patch, otherwise the usage
of cpu_online_mask is racy and we can hit the "Wait for up to 10 seconds" case.

Btw...

	/* Wait for up to 10 seconds for all CPUs to do the backtrace */
	for (i = 0; i < 10 * 1000; i++) {
		if (cpumask_empty(to_cpumask(backtrace_mask)))
			break;
		mdelay(1);
	}

OK, but perhaps we should clear backtrace_mask if we return due to timeout.

> does disabling preemption help in the cpu
> hotplug case?

Yes. But I'd suggest to change your patch to use get_cpu() instead of
preempt_disable/smp_processor_id.

And I think it would be better to not discuss this off-list, I added lkml.

Oleg.


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

* Re: [PATCH 1/4 v2] nmi: Provide the option to issue an NMI back trace to every cpu but current
  2014-04-21 13:41       ` [PATCH 1/4 v2] nmi: Provide the option to issue an NMI back trace to every cpu but current Oleg Nesterov
@ 2014-04-21 15:47         ` Don Zickus
  0 siblings, 0 replies; 3+ messages in thread
From: Don Zickus @ 2014-04-21 15:47 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Aaron Tomlin, mingo, mingo, linux-kernel

On Mon, Apr 21, 2014 at 03:41:54PM +0200, Oleg Nesterov wrote:
> On 04/21, Don Zickus wrote:
> >
> > On Tue, Apr 15, 2014 at 07:26:49PM +0200, Oleg Nesterov wrote:
> > > On 04/15, Oleg Nesterov wrote:
> > > >
> > > > Looking at https://lkml.org/lkml/2014/4/4/469... It seems that 2/4 can be
> > > > simplified, you can simply remove smp_processor_id() from backtrace_mask
> > > > if !include_self and use apic->send_IPI_mask(backtrace_mask). But this is
> > > > minor, I won't insist.
> > >
> > > And in fact, I do not understand why arch_trigger_all_cpu_backtrace() doesn't
> > > disable preemption. OK, probably we can simply ignore the race with cpu hotplug.
> > >
> > > But it seems that your patch makes the things worse. Lets look at, say,
> > > numachip_send_IPI_mask_allbutself(). The usage of smp_processor_id() is
> > > obviously racy but perhaps we do not care again. But we do not want a warning
> > > from debug_smp_processor_id().
> >
> > Good point.  I forgot that going from all cpus down to allbutself,
> > preemption now matters.
> 
> I am not sure it actually matters wrt "show other CPU's traces". If the preemption
> is possible then the caller can be preempted even before it sends ipi.
> 
> OTOH I think it does matter anyway, even without your patch, otherwise the usage
> of cpu_online_mask is racy and we can hit the "Wait for up to 10 seconds" case.

Hmm,  I understand what you are saying now.

> 
> Btw...
> 
> 	/* Wait for up to 10 seconds for all CPUs to do the backtrace */
> 	for (i = 0; i < 10 * 1000; i++) {
> 		if (cpumask_empty(to_cpumask(backtrace_mask)))
> 			break;
> 		mdelay(1);
> 	}
> 
> OK, but perhaps we should clear backtrace_mask if we return due to timeout.

I can look at that.

> 
> > does disabling preemption help in the cpu
> > hotplug case?
> 
> Yes. But I'd suggest to change your patch to use get_cpu() instead of
> preempt_disable/smp_processor_id.

ok.  Originally I was thinking of the remote hotplug cpu case, which
pre-emption won't block.  But forgot about the local cpu hotplug case.


> 
> And I think it would be better to not discuss this off-list, I added lkml.
> 
> Oleg.
> 

Thanks!

Cheers,
Don


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

end of thread, other threads:[~2014-04-21 15:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20140415075650.GG2195@atomlin.usersys.redhat.com>
     [not found] ` <20140415170202.GA7948@redhat.com>
     [not found]   ` <20140415172649.GA10152@redhat.com>
     [not found]     ` <20140421132100.GW8488@redhat.com>
2014-04-21 13:41       ` [PATCH 1/4 v2] nmi: Provide the option to issue an NMI back trace to every cpu but current Oleg Nesterov
2014-04-21 15:47         ` Don Zickus
2014-04-04 20:47 [PATCH 0/4 V2] Print traces on softlockups Don Zickus
2014-04-04 20:47 ` [PATCH 1/4 v2] nmi: Provide the option to issue an NMI back trace to every cpu but current Don Zickus

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).