public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Steven Rostedt <srostedt@redhat.com>
Subject: Re: [PATCH 2/4] nmi: add generic nmi tracking state
Date: Fri, 6 Feb 2009 09:10:39 -0800	[thread overview]
Message-ID: <20090206091039.d0acb680.akpm@linux-foundation.org> (raw)
In-Reply-To: <alpine.DEB.1.10.0902060822440.10059@gandalf.stny.rr.com>

On Fri, 6 Feb 2009 08:25:52 -0500 (EST) Steven Rostedt <rostedt@goodmis.org> wrote:

> 
> On Thu, 5 Feb 2009, Andrew Morton wrote:
> > >  
> > > +/*
> > > + * Are we in NMI context?
> > > + */
> > > +#define in_nmi()	(preempt_count() & NMI_OFFSET)
> > > +
> > >  #if defined(CONFIG_PREEMPT)
> > >  # define PREEMPT_INATOMIC_BASE kernel_locked()
> > >  # define PREEMPT_CHECK_OFFSET 1
> > > @@ -167,6 +178,8 @@ extern void irq_exit(void);
> > >  #define nmi_enter()				\
> > >  	do {					\
> > >  		ftrace_nmi_enter();		\
> > > +		BUG_ON(in_nmi());		\
> > > +		add_preempt_count(NMI_OFFSET);	\
> > >  		lockdep_off();			\
> > >  		rcu_nmi_enter();		\
> > >  		__irq_enter();			\
> > > @@ -177,6 +190,8 @@ extern void irq_exit(void);
> > >  		__irq_exit();			\
> > >  		rcu_nmi_exit();			\
> > >  		lockdep_on();			\
> > > +		BUG_ON(!in_nmi());		\
> > > +		sub_preempt_count(NMI_OFFSET);	\
> > >  		ftrace_nmi_exit();		\
> > >  	} while (0)
> > >  
> > 
> > Well that was tidy.
> > 
> > We're sure that no present or future architecture will for some weird
> > reason nest NMIs?
> 
> That would be fun to implement. Not the in_nmi code, but the handling of 
> nested NMIs. How would you be able to save the state when the NMI occurred 
> without being preempted by another NMI?

Like with normal interrupts?

As long as the number of sources is finite, nested NMIs could work OK.

> I think the arch that has nested NMIs will have many more issues to solve 
> in the kernel than this one.

I have a vague memory that x86 can do this.

<googles a bit>

What's all this about?
https://www.x86-64.org/pipermail/discuss/2005-October/007010.html
http://kerneltrap.org/index.php?q=mailarchive/linux-kernel/2008/2/12/830704/thread

I expect that even if it is possible, we can live without it.

And if I'm wrong, it'll be easy to accommodate by adding a new counter
into the task_struct or thread_struct.

Does your above implementation make in_interrupt() return true if
in_nmi()?  I think it doesn't, but should?


  reply	other threads:[~2009-02-06 17:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-06  6:53 [PATCH 0/4] ftrace: updates for tip Steven Rostedt
2009-02-06  6:53 ` [PATCH 1/4] ftrace, x86: rename in_nmi variable Steven Rostedt
2009-02-06  6:53 ` [PATCH 2/4] nmi: add generic nmi tracking state Steven Rostedt
2009-02-06  7:12   ` Andrew Morton
2009-02-06 13:25     ` Steven Rostedt
2009-02-06 17:10       ` Andrew Morton [this message]
2009-02-06 17:22         ` Steven Rostedt
2009-02-06  9:34   ` Peter Zijlstra
2009-02-06 14:46     ` Ingo Molnar
2009-02-06 14:50       ` Steven Rostedt
2009-02-06 14:54         ` Ingo Molnar
2009-02-06 14:59           ` Steven Rostedt
2009-02-06 15:16             ` Ingo Molnar
2009-02-06 15:33           ` Frederic Weisbecker
2009-02-06 15:43             ` Ingo Molnar
2009-02-06  6:53 ` [PATCH 3/4] ftrace: change function graph tracer to use new in_nmi Steven Rostedt
2009-02-06  6:53 ` [PATCH 4/4] ring-buffer: use generic version of in_nmi Steven Rostedt

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=20090206091039.d0acb680.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=srostedt@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox