Skip to contentSkip to conversation

arm64: Don't trace __switch_to if function graph tracer is enabled

PATCH In review Joel Fernandes 2 participants 2 messages Dec 21, 2016 – Jan 4, 2017 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: Don't trace __switch_to if function graph tracer is enabled

Function graph tracer shows negative time (wrap around) when tracing __switch_to if the nosleep-time trace option is enabled.

Time compensation for nosleep-time is done by an ftrace probe on sched_switch. This doesn't work well for the following events (with letters representing timestamps):
A - sched switch probe called for task T switch out
B - __switch_to calltime is recorded
C - sched_switch probe called for task T switch in
D - __switch_to rettime is recorded

If C - A > D - B, then we end up over compensating for the time spent in __switch_to giving rise to negative times in the trace output.

On x86, __switch_to is not traced if function graph tracer is enabled. Do the same for arm64 as well.

Cc Todd Kjos <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Will Deacon <[email protected]>
Cc Mark Rutland <[email protected]>
---
 arch/arm64/kernel/process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/process.c +1 -1
index 01753cd..e84ee27 100644
@@ -324,7 +324,7 @@ void uao_thread_switch(struct task_struct *next)
 /*
  * Thread switching.
  */
-struct task_struct *__switch_to(struct task_struct *prev,
+__notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
 				struct task_struct *next)
 {
 	struct task_struct *last;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw
Quoted 17 lines · Joel Fernandes

Function graph tracer shows negative time (wrap around) when tracing __switch_to if the nosleep-time trace option is enabled.

Time compensation for nosleep-time is done by an ftrace probe on sched_switch. This doesn't work well for the following events (with letters representing timestamps):
A - sched switch probe called for task T switch out
B - __switch_to calltime is recorded
C - sched_switch probe called for task T switch in
D - __switch_to rettime is recorded

If C - A > D - B, then we end up over compensating for the time spent in __switch_to giving rise to negative times in the trace output.

On x86, __switch_to is not traced if function graph tracer is enabled. Do the same for arm64 as well.

Quoted 8 lines
Cc Todd Kjos <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Will Deacon <[email protected]>
Cc Mark Rutland <[email protected]>
---
 arch/arm64/kernel/process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, queued for 4.11.

Will