Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6409c4da authored by Ingo Molnar's avatar Ingo Molnar
Browse files

sched: sched_clock() improvement: use in_nmi()



make sure we dont execute more complex sched_clock() code in NMI context.

Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent af39241b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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;