public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/clock: prevent tracing recursion in sched_clock_cpu()
@ 2014-03-06  5:25 Fernando Luis Vázquez Cao
  2014-03-06 10:51 ` Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Fernando Luis Vázquez Cao @ 2014-03-06  5:25 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Linus Torvalds, Andrew Morton, Ingo Molnar, StevenRostedt,
	linux-kernel

From: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>

Prevent tracing of preempt_disable/enable() in sched_clock_cpu().
When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are
traced and this causes trace_clock() users (and probably others) to
go into an infinite recursion. Systems with a stable sched_clock()
are not affected.

This problem is similar to that fixed by upstream commit 95ef1e52922
("KVM guest: prevent tracing recursion with kvmclock").

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
---

diff -urNp linux-3.14-rc5-orig/kernel/sched/clock.c linux-3.14-rc5/kernel/sched/clock.c
--- linux-3.14-rc5-orig/kernel/sched/clock.c	2014-03-06 13:37:43.567720550 +0900
+++ linux-3.14-rc5/kernel/sched/clock.c	2014-03-06 13:41:56.937100949 +0900
@@ -301,14 +301,14 @@ u64 sched_clock_cpu(int cpu)
 	if (unlikely(!sched_clock_running))
 		return 0ull;
 
-	preempt_disable();
+	preempt_disable_notrace();
 	scd = cpu_sdc(cpu);
 
 	if (cpu != smp_processor_id())
 		clock = sched_clock_remote(scd);
 	else
 		clock = sched_clock_local(scd);
-	preempt_enable();
+	preempt_enable_notrace();
 
 	return clock;
 }



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

* Re: [PATCH] sched/clock: prevent tracing recursion in sched_clock_cpu()
  2014-03-06  5:25 [PATCH] sched/clock: prevent tracing recursion in sched_clock_cpu() Fernando Luis Vázquez Cao
@ 2014-03-06 10:51 ` Steven Rostedt
  2014-03-10  7:17   ` Fernando Luis Vázquez Cao
  2014-03-06 10:51 ` Peter Zijlstra
  2014-03-11 12:36 ` [tip:sched/core] sched/clock: Prevent " tip-bot for Fernando Luis Vazquez Cao
  2 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2014-03-06 10:51 UTC (permalink / raw)
  To: Fernando Luis Vázquez Cao
  Cc: Peter Zijlstra, Linus Torvalds, Andrew Morton, Ingo Molnar,
	linux-kernel

On Thu, 06 Mar 2014 14:25:28 +0900
Fernando Luis Vázquez Cao <fernando_b1@lab.ntt.co.jp> wrote:

> From: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
> 
> Prevent tracing of preempt_disable/enable() in sched_clock_cpu().
> When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are
> traced and this causes trace_clock() users (and probably others) to
> go into an infinite recursion. Systems with a stable sched_clock()
> are not affected.
> 
> This problem is similar to that fixed by upstream commit 95ef1e52922
> ("KVM guest: prevent tracing recursion with kvmclock").

Also similar to: 569d6557ab957.

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

> 
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
> ---
> 
> diff -urNp linux-3.14-rc5-orig/kernel/sched/clock.c linux-3.14-rc5/kernel/sched/clock.c
> --- linux-3.14-rc5-orig/kernel/sched/clock.c	2014-03-06 13:37:43.567720550 +0900
> +++ linux-3.14-rc5/kernel/sched/clock.c	2014-03-06 13:41:56.937100949 +0900
> @@ -301,14 +301,14 @@ u64 sched_clock_cpu(int cpu)
>  	if (unlikely(!sched_clock_running))
>  		return 0ull;
>  
> -	preempt_disable();
> +	preempt_disable_notrace();
>  	scd = cpu_sdc(cpu);
>  
>  	if (cpu != smp_processor_id())
>  		clock = sched_clock_remote(scd);
>  	else
>  		clock = sched_clock_local(scd);
> -	preempt_enable();
> +	preempt_enable_notrace();
>  
>  	return clock;
>  }
> 


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

* Re: [PATCH] sched/clock: prevent tracing recursion in sched_clock_cpu()
  2014-03-06  5:25 [PATCH] sched/clock: prevent tracing recursion in sched_clock_cpu() Fernando Luis Vázquez Cao
  2014-03-06 10:51 ` Steven Rostedt
@ 2014-03-06 10:51 ` Peter Zijlstra
  2014-03-11 12:36 ` [tip:sched/core] sched/clock: Prevent " tip-bot for Fernando Luis Vazquez Cao
  2 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2014-03-06 10:51 UTC (permalink / raw)
  To: Fernando Luis Vázquez Cao
  Cc: Linus Torvalds, Andrew Morton, Ingo Molnar, StevenRostedt,
	linux-kernel

On Thu, Mar 06, 2014 at 02:25:28PM +0900, Fernando Luis Vázquez Cao wrote:
> From: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
> 
> Prevent tracing of preempt_disable/enable() in sched_clock_cpu().
> When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are
> traced and this causes trace_clock() users (and probably others) to
> go into an infinite recursion. Systems with a stable sched_clock()
> are not affected.
> 
> This problem is similar to that fixed by upstream commit 95ef1e52922
> ("KVM guest: prevent tracing recursion with kvmclock").
> 
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>

Thanks!

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

* Re: [PATCH] sched/clock: prevent tracing recursion in sched_clock_cpu()
  2014-03-06 10:51 ` Steven Rostedt
@ 2014-03-10  7:17   ` Fernando Luis Vázquez Cao
  2014-03-11  3:47     ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: Fernando Luis Vázquez Cao @ 2014-03-10  7:17 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Peter Zijlstra, Linus Torvalds, Andrew Morton, Ingo Molnar,
	linux-kernel

On 03/06/2014 07:51 PM, Steven Rostedt wrote:
> On Thu, 06 Mar 2014 14:25:28 +0900
> Fernando Luis Vázquez Cao <fernando_b1@lab.ntt.co.jp> wrote:
>
>> From: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
>>
>> Prevent tracing of preempt_disable/enable() in sched_clock_cpu().
>> When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are
>> traced and this causes trace_clock() users (and probably others) to
>> go into an infinite recursion. Systems with a stable sched_clock()
>> are not affected.
>>
>> This problem is similar to that fixed by upstream commit 95ef1e52922
>> ("KVM guest: prevent tracing recursion with kvmclock").
> Also similar to: 569d6557ab957.
>
> Acked-by: Steven Rostedt <rostedt@goodmis.org>

Thank you four your review, Peter, Steven.

By the way, who is going to pick this patch? Do you want
me to resend with Steven's Acked-by added?

- Fernando

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

* Re: [PATCH] sched/clock: prevent tracing recursion in sched_clock_cpu()
  2014-03-10  7:17   ` Fernando Luis Vázquez Cao
@ 2014-03-11  3:47     ` Steven Rostedt
  2014-03-11  8:15       ` Peter Zijlstra
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2014-03-11  3:47 UTC (permalink / raw)
  To: Fernando Luis Vázquez Cao
  Cc: Peter Zijlstra, Linus Torvalds, Andrew Morton, Ingo Molnar,
	linux-kernel

On Mon, 10 Mar 2014 16:17:18 +0900
Fernando Luis Vázquez Cao <fernando_b1@lab.ntt.co.jp> wrote:


> Thank you four your review, Peter, Steven.
> 
> By the way, who is going to pick this patch? Do you want
> me to resend with Steven's Acked-by added?

I don't think you have to. I believe Peter got it. I know there's a
bunch of patches he's trying to get pushed forward.

-- Steve

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

* Re: [PATCH] sched/clock: prevent tracing recursion in sched_clock_cpu()
  2014-03-11  3:47     ` Steven Rostedt
@ 2014-03-11  8:15       ` Peter Zijlstra
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2014-03-11  8:15 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Fernando Luis Vázquez Cao, Linus Torvalds, Andrew Morton,
	Ingo Molnar, linux-kernel

On Mon, Mar 10, 2014 at 11:47:06PM -0400, Steven Rostedt wrote:
> On Mon, 10 Mar 2014 16:17:18 +0900
> Fernando Luis Vázquez Cao <fernando_b1@lab.ntt.co.jp> wrote:
> 
> 
> > Thank you four your review, Peter, Steven.
> > 
> > By the way, who is going to pick this patch? Do you want
> > me to resend with Steven's Acked-by added?
> 
> I don't think you have to. I believe Peter got it. I know there's a
> bunch of patches he's trying to get pushed forward.

Yeah, I do have it (and the scheduler patch you were after Steve), I
just need to trick Ingo into actually looking at his computer somehow.
He seems busy with real life stuff for a bit.

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

* [tip:sched/core] sched/clock: Prevent tracing recursion in sched_clock_cpu()
  2014-03-06  5:25 [PATCH] sched/clock: prevent tracing recursion in sched_clock_cpu() Fernando Luis Vázquez Cao
  2014-03-06 10:51 ` Steven Rostedt
  2014-03-06 10:51 ` Peter Zijlstra
@ 2014-03-11 12:36 ` tip-bot for Fernando Luis Vazquez Cao
  2 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Fernando Luis Vazquez Cao @ 2014-03-11 12:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, torvalds, peterz, rostedt, akpm,
	fernando, tglx

Commit-ID:  96b3d28bf4b00f62fc8386ff5d487d1830793a3d
Gitweb:     http://git.kernel.org/tip/96b3d28bf4b00f62fc8386ff5d487d1830793a3d
Author:     Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
AuthorDate: Thu, 6 Mar 2014 14:25:28 +0900
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 11 Mar 2014 11:33:48 +0100

sched/clock: Prevent tracing recursion in sched_clock_cpu()

Prevent tracing of preempt_disable/enable() in sched_clock_cpu().
When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are
traced and this causes trace_clock() users (and probably others) to
go into an infinite recursion. Systems with a stable sched_clock()
are not affected.

This problem is similar to that fixed by upstream commit 95ef1e52922
("KVM guest: prevent tracing recursion with kvmclock").

Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/1394083528.4524.3.camel@nexus
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/clock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
index 43c2bcc..b30a292 100644
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -301,14 +301,14 @@ u64 sched_clock_cpu(int cpu)
 	if (unlikely(!sched_clock_running))
 		return 0ull;
 
-	preempt_disable();
+	preempt_disable_notrace();
 	scd = cpu_sdc(cpu);
 
 	if (cpu != smp_processor_id())
 		clock = sched_clock_remote(scd);
 	else
 		clock = sched_clock_local(scd);
-	preempt_enable();
+	preempt_enable_notrace();
 
 	return clock;
 }

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

end of thread, other threads:[~2014-03-11 12:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-06  5:25 [PATCH] sched/clock: prevent tracing recursion in sched_clock_cpu() Fernando Luis Vázquez Cao
2014-03-06 10:51 ` Steven Rostedt
2014-03-10  7:17   ` Fernando Luis Vázquez Cao
2014-03-11  3:47     ` Steven Rostedt
2014-03-11  8:15       ` Peter Zijlstra
2014-03-06 10:51 ` Peter Zijlstra
2014-03-11 12:36 ` [tip:sched/core] sched/clock: Prevent " tip-bot for Fernando Luis Vazquez Cao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox