* [PATCH] x86: Use preempt_disable_notrace() in cycles_2_ns()
@ 2014-02-04 19:13 Steven Rostedt
2014-02-04 19:45 ` Peter Zijlstra
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2014-02-04 19:13 UTC (permalink / raw)
To: LKML
Cc: Linus Torvalds, Peter Zijlstra, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin
When debug preempt is enabled, preempt_disable() can be traced by
function and function graph tracing.
There's a place in the function graph tracer that calls trace_clock()
which eventually calls cycles_2_ns() outside of the recursion
protection. When cycles_2_ns() calls preempt_disable() it gets traced
and the graph tracer will go into a recursive loop causing a crash or
worse, a triple fault.
Simple fix is to use preempt_disable_notrace() in cycles_2_ns, which
makes sense because the preempt_disable() tracing may use that code
too, and it tracing it, even with recursion protection is rather
pointless.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 19e5adb..acb3b60 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -209,7 +209,7 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc)
* dance when its actually needed.
*/
- preempt_disable();
+ preempt_disable_notrace();
data = this_cpu_read(cyc2ns.head);
tail = this_cpu_read(cyc2ns.tail);
@@ -229,7 +229,7 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc)
if (!--data->__count)
this_cpu_write(cyc2ns.tail, data);
}
- preempt_enable();
+ preempt_enable_notrace();
return ns;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] x86: Use preempt_disable_notrace() in cycles_2_ns()
2014-02-04 19:13 [PATCH] x86: Use preempt_disable_notrace() in cycles_2_ns() Steven Rostedt
@ 2014-02-04 19:45 ` Peter Zijlstra
2014-02-04 20:22 ` Thomas Gleixner
2014-02-10 13:28 ` [tip:x86/urgent] " tip-bot for Steven Rostedt
2 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2014-02-04 19:45 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Linus Torvalds, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin
On Tue, Feb 04, 2014 at 02:13:15PM -0500, Steven Rostedt wrote:
> When debug preempt is enabled, preempt_disable() can be traced by
> function and function graph tracing.
>
> There's a place in the function graph tracer that calls trace_clock()
> which eventually calls cycles_2_ns() outside of the recursion
> protection. When cycles_2_ns() calls preempt_disable() it gets traced
> and the graph tracer will go into a recursive loop causing a crash or
> worse, a triple fault.
>
> Simple fix is to use preempt_disable_notrace() in cycles_2_ns, which
> makes sense because the preempt_disable() tracing may use that code
> too, and it tracing it, even with recursion protection is rather
> pointless.
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Indeed, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86: Use preempt_disable_notrace() in cycles_2_ns()
2014-02-04 19:13 [PATCH] x86: Use preempt_disable_notrace() in cycles_2_ns() Steven Rostedt
2014-02-04 19:45 ` Peter Zijlstra
@ 2014-02-04 20:22 ` Thomas Gleixner
2014-02-10 13:28 ` [tip:x86/urgent] " tip-bot for Steven Rostedt
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2014-02-04 20:22 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Linus Torvalds, Peter Zijlstra, Ingo Molnar, H. Peter Anvin
On Tue, 4 Feb 2014, Steven Rostedt wrote:
> When debug preempt is enabled, preempt_disable() can be traced by
> function and function graph tracing.
>
> There's a place in the function graph tracer that calls trace_clock()
> which eventually calls cycles_2_ns() outside of the recursion
> protection. When cycles_2_ns() calls preempt_disable() it gets traced
> and the graph tracer will go into a recursive loop causing a crash or
> worse, a triple fault.
>
> Simple fix is to use preempt_disable_notrace() in cycles_2_ns, which
> makes sense because the preempt_disable() tracing may use that code
> too, and it tracing it, even with recursion protection is rather
> pointless.
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by-me
> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index 19e5adb..acb3b60 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -209,7 +209,7 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc)
> * dance when its actually needed.
> */
>
> - preempt_disable();
> + preempt_disable_notrace();
> data = this_cpu_read(cyc2ns.head);
> tail = this_cpu_read(cyc2ns.tail);
>
> @@ -229,7 +229,7 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc)
> if (!--data->__count)
> this_cpu_write(cyc2ns.tail, data);
> }
> - preempt_enable();
> + preempt_enable_notrace();
>
> return ns;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:x86/urgent] x86: Use preempt_disable_notrace() in cycles_2_ns()
2014-02-04 19:13 [PATCH] x86: Use preempt_disable_notrace() in cycles_2_ns() Steven Rostedt
2014-02-04 19:45 ` Peter Zijlstra
2014-02-04 20:22 ` Thomas Gleixner
@ 2014-02-10 13:28 ` tip-bot for Steven Rostedt
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Steven Rostedt @ 2014-02-10 13:28 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, torvalds, rostedt, peterz, tglx
Commit-ID: 569d6557ab957d6ae7e97a46ae669174be4189e6
Gitweb: http://git.kernel.org/tip/569d6557ab957d6ae7e97a46ae669174be4189e6
Author: Steven Rostedt <rostedt@goodmis.org>
AuthorDate: Tue, 4 Feb 2014 14:13:15 -0500
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 9 Feb 2014 13:09:08 +0100
x86: Use preempt_disable_notrace() in cycles_2_ns()
When debug preempt is enabled, preempt_disable() can be traced by
function and function graph tracing.
There's a place in the function graph tracer that calls trace_clock()
which eventually calls cycles_2_ns() outside of the recursion
protection. When cycles_2_ns() calls preempt_disable() it gets traced
and the graph tracer will go into a recursive loop causing a crash or
worse, a triple fault.
Simple fix is to use preempt_disable_notrace() in cycles_2_ns, which
makes sense because the preempt_disable() tracing may use that code
too, and it tracing it, even with recursion protection is rather
pointless.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20140204141315.2a968a72@gandalf.local.home
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/tsc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 19e5adb..acb3b60 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -209,7 +209,7 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc)
* dance when its actually needed.
*/
- preempt_disable();
+ preempt_disable_notrace();
data = this_cpu_read(cyc2ns.head);
tail = this_cpu_read(cyc2ns.tail);
@@ -229,7 +229,7 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc)
if (!--data->__count)
this_cpu_write(cyc2ns.tail, data);
}
- preempt_enable();
+ preempt_enable_notrace();
return ns;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-02-10 13:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-04 19:13 [PATCH] x86: Use preempt_disable_notrace() in cycles_2_ns() Steven Rostedt
2014-02-04 19:45 ` Peter Zijlstra
2014-02-04 20:22 ` Thomas Gleixner
2014-02-10 13:28 ` [tip:x86/urgent] " tip-bot for Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox