Skip to content

Commit

Permalink
sched/clock: Prevent tracing recursion in sched_clock_cpu()
Browse files Browse the repository at this point in the history
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 95ef1e5
("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>
  • Loading branch information
Fernando Luis Vazquez Cao authored and Ingo Molnar committed Mar 11, 2014
1 parent 177c53d commit 96b3d28
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/sched/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 96b3d28

Please sign in to comment.