summaryrefslogtreecommitdiff
path: root/kernel/sched_clock.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-05-12 21:21:14 +0200
committerIngo Molnar <mingo@elte.hu>2009-02-26 18:44:05 +0100
commit6409c4da289d6905f7ae2bd0630438368439bda2 (patch)
treea89ab72b160acabe7e83200f73ba3a2cb3b2a0be /kernel/sched_clock.c
parentaf39241b90a345556b8884adff87096afe71b050 (diff)
sched: sched_clock() improvement: use in_nmi()
make sure we dont execute more complex sched_clock() code in NMI context. Acked-by: Peter Zijlstra <peterz@infradead.org> Acked-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched_clock.c')
-rw-r--r--kernel/sched_clock.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/sched_clock.c b/kernel/sched_clock.c
index a0b0852414cc..db69174b1178 100644
--- a/kernel/sched_clock.c
+++ b/kernel/sched_clock.c
@@ -29,6 +29,7 @@
#include <linux/spinlock.h>
#include <linux/ktime.h>
#include <linux/module.h>
+#include <linux/hardirq.h>
/*
* Scheduler clock - returns current time in nanosec units.
@@ -151,6 +152,13 @@ u64 sched_clock_cpu(int cpu)
struct sched_clock_data *scd = cpu_sdc(cpu);
u64 now, clock, this_clock, remote_clock;
+ /*
+ * Normally this is not called in NMI context - but if it is,
+ * trying to do any locking here is totally lethal.
+ */
+ if (unlikely(in_nmi()))
+ return scd->clock;
+
if (unlikely(!sched_clock_running))
return 0ull;