All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andi Kleen <andi@firstfloor.org>,
	"H. Peter Anvin" <hpa@linux.intel.com>,
	Paul Turner <pjt@google.com>
Subject: Re: [RFC][PATCH 5/5 v2] x86: Allow NMIs to hit breakpoints in i386
Date: Wed, 14 Dec 2011 08:30:25 -0500	[thread overview]
Message-ID: <20111214133025.GA2882@Krystal> (raw)
In-Reply-To: <20111214025253.519573056@goodmis.org>

* Steven Rostedt (rostedt@goodmis.org) wrote:
[...]> From: Steven Rostedt <srostedt@redhat.com>
> +#define nmi_preprocess(regs)						\
> +	do {								\
> +		if (__get_cpu_var(nmi_state) != NMI_NOT_RUNNING) {	\
> +			__get_cpu_var(nmi_state) = NMI_LATCHED;		\
> +			return;						\
> +		}							\
> +	nmi_restart:							\
> +		__get_cpu_var(nmi_state) = NMI_EXECUTING;		\
> +	} while (0)
> +
> +#define nmi_postprocess()						\
> +	do {								\
> +		if (cmpxchg(&__get_cpu_var(nmi_state),			\
> +		    NMI_EXECUTING, NMI_NOT_RUNNING) != NMI_EXECUTING)	\
> +			goto nmi_restart;				\
> +	} while (0)
> +
[...]
> +dotraplinkage notrace __kprobes void
> +do_nmi(struct pt_regs *regs, long error_code)
> +{
> +	nmi_preprocess(regs);
> +
>  	nmi_enter();
>  
>  	inc_irq_stat(__nmi_count);
> @@ -428,8 +515,7 @@ do_nmi(struct pt_regs *regs, long error_code)
>  
>  	nmi_exit();
>  
> -	if (unlikely(update_debug_stack))
> -		reset_debug_stack();
> +	nmi_postprocess();

Just to make sure I understand: if an NMI nests over do_nmi between
nmi_postprocess() and the following iret (in which case the CPU is in
state NMI_NOT_RUNNING), we will end up with two NMI handlers nested on
the stack, right ? Given that there is no upper-bound on the nesting
level of this situation (although nesting like this more than once is
extremely unlikely), is this side-effect something we should care about
in terms of stack space usage ? Also, is the stack dump OOPS handler
aware of this stack layout that was until now impossible ?

Thanks,

Mathieu

>  }
>  
>  void stop_nmi(void)
> -- 
> 1.7.7.3
> 
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

  reply	other threads:[~2011-12-14 13:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-14  2:52 [RFC][PATCH 0/5 v2] x86: Find a way to allow breakpoints in NMIs Steven Rostedt
2011-12-14  2:52 ` [RFC][PATCH 1/5 v2] x86: Do not schedule while still in NMI context Steven Rostedt
2011-12-14  2:52 ` [RFC][PATCH 2/5 v2] x86: Document the NMI handler about not using paranoid_exit Steven Rostedt
2011-12-14  2:52 ` [RFC][PATCH 3/5 v2] x86: Add workaround to NMI iret woes Steven Rostedt
2011-12-14  2:52 ` [RFC][PATCH 4/5 v2] x86: Keep current stack in NMI breakpoints Steven Rostedt
2011-12-14 13:43   ` Mathieu Desnoyers
2011-12-14 16:19     ` Steven Rostedt
2011-12-15 19:15     ` Steven Rostedt
2012-01-08  8:59       ` [tip:perf/core] x86: Add counter when debug stack is used with interrupts enabled tip-bot for Steven Rostedt
2011-12-14  2:52 ` [RFC][PATCH 5/5 v2] x86: Allow NMIs to hit breakpoints in i386 Steven Rostedt
2011-12-14 13:30   ` Mathieu Desnoyers [this message]
2011-12-14 13:40     ` Steven Rostedt
2011-12-14 13:44       ` Mathieu Desnoyers
2011-12-14 18:26   ` H. Peter Anvin
2011-12-14 19:33     ` 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=20111214133025.GA2882@Krystal \
    --to=mathieu.desnoyers@efficios.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=fweisbec@gmail.com \
    --cc=hpa@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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.