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

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