[PATCH 1/8] clocksource/drivers/arm_global_timer: Prevent ftrace recursion

Daniel Lezcano daniel.lezcano at linaro.org
Wed Oct 28 06:11:26 PDT 2015

From: Jisheng Zhang <jszhang at marvell.com>

Currently arm_global_timer can be used as a scheduler clock. We properly
marked gt_sched_clock_read() as notrace but we then call another function
gt_counter_read() that _wasn't_ notrace.

Having a traceable function in the sched_clock() path leads to a recursion
within ftrace and a kernel crash.

Fix this by adding an extra notrace function to keep other users of
gt_counter_read() traceable.

Signed-off-by: Jisheng Zhang <jszhang at marvell.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano at linaro.org>
 drivers/clocksource/arm_global_timer.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c
index 29ea50a..a2cb6fa 100644
--- a/drivers/clocksource/arm_global_timer.c
+++ b/drivers/clocksource/arm_global_timer.c
@@ -60,7 +60,7 @@ static struct clock_event_device __percpu *gt_evt;
  *  different to the 32-bit upper value read previously, go back to step 2.
  *  Otherwise the 64-bit timer counter value is correct.
-static u64 gt_counter_read(void)
+static u64 notrace _gt_counter_read(void)
 	u64 counter;
 	u32 lower;
@@ -79,6 +79,11 @@ static u64 gt_counter_read(void)
 	return counter;
+static u64 gt_counter_read(void)
+	return _gt_counter_read();
  * To ensure that updates to comparator value register do not set the
  * Interrupt Status Register proceed as follows:
@@ -201,7 +206,7 @@ static struct clocksource gt_clocksource = {
 static u64 notrace gt_sched_clock_read(void)
-	return gt_counter_read();
+	return _gt_counter_read();

More information about the linux-arm-kernel mailing list