All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: 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: Thu, 5 Feb 2009 23:12:15 -0800	[thread overview]
Message-ID: <20090205231215.412def47.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090206065437.986292747@goodmis.org>

On Fri, 06 Feb 2009 01:53:54 -0500 Steven Rostedt <rostedt@goodmis.org> wrote:

> From: Steven Rostedt <srostedt@redhat.com>
> 
> This code adds an in_nmi() macro that uses the current tasks preempt count
> to track when it is in NMI context. Other parts of the kernel can
> use this to determine if the context is in NMI context or not.
> 
> This code was inspired by the -rt patch in_nmi version that was
> written by Peter Zijlstra.
> 
> Reported-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Steven Rostedt <srostedt@redhat.com>
> ---
>  include/linux/hardirq.h |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
> index f832883..f3cf86e 100644
> --- a/include/linux/hardirq.h
> +++ b/include/linux/hardirq.h
> @@ -61,6 +61,12 @@
>  #error PREEMPT_ACTIVE is too low!
>  #endif
>  
> +#define NMI_OFFSET	(PREEMPT_ACTIVE << 1)
> +
> +#if NMI_OFFSET >= 0x80000000
> +#error PREEMPT_ACTIVE too high!
> +#endif
> +
>  #define hardirq_count()	(preempt_count() & HARDIRQ_MASK)
>  #define softirq_count()	(preempt_count() & SOFTIRQ_MASK)
>  #define irq_count()	(preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK))
> @@ -73,6 +79,11 @@
>  #define in_softirq()		(softirq_count())
>  #define in_interrupt()		(irq_count())
>  
> +/*
> + * 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?


  reply	other threads:[~2009-02-06  7:18 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 [this message]
2009-02-06 13:25     ` Steven Rostedt
2009-02-06 17:10       ` Andrew Morton
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=20090205231215.412def47.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 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.