Skip to content

Commit 96b3d28

Browse files
Fernando Luis Vazquez CaoIngo Molnar
authored andcommitted
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 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>
1 parent 177c53d commit 96b3d28

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/sched/clock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ u64 sched_clock_cpu(int cpu)
301301
if (unlikely(!sched_clock_running))
302302
return 0ull;
303303

304-
preempt_disable();
304+
preempt_disable_notrace();
305305
scd = cpu_sdc(cpu);
306306

307307
if (cpu != smp_processor_id())
308308
clock = sched_clock_remote(scd);
309309
else
310310
clock = sched_clock_local(scd);
311-
preempt_enable();
311+
preempt_enable_notrace();
312312

313313
return clock;
314314
}

0 commit comments

Comments
 (0)