linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: add unwind annotations to ftrace asm
@ 2013-03-23 22:10 Rabin Vincent
  2013-04-25 14:39 ` Jan Lübbe
  0 siblings, 1 reply; 2+ messages in thread
From: Rabin Vincent @ 2013-03-23 22:10 UTC (permalink / raw)
  To: linux-arm-kernel

Add unwind annotations to the ftrace assembly code so that the function
tracer's stacktracing options (func_stack_trace, etc.) work when
CONFIG_ARM_UNWIND is enabled.

Signed-off-by: Rabin Vincent <rabin@rab.in>
---
 arch/arm/kernel/entry-common.S |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 3248cde..fefd7f9 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -276,7 +276,13 @@ ENDPROC(ftrace_graph_caller_old)
  */
 
 .macro mcount_enter
+/*
+ * This pad compensates for the push {lr} at the call site.  Note that we are
+ * unable to unwind through a function which does not otherwise save its lr.
+ */
+ UNWIND(.pad	#4)
 	stmdb	sp!, {r0-r3, lr}
+ UNWIND(.save	{r0-r3, lr})
 .endm
 
 .macro mcount_get_lr reg
@@ -289,6 +295,7 @@ ENDPROC(ftrace_graph_caller_old)
 .endm
 
 ENTRY(__gnu_mcount_nc)
+UNWIND(.fnstart)
 #ifdef CONFIG_DYNAMIC_FTRACE
 	mov	ip, lr
 	ldmia	sp!, {lr}
@@ -296,17 +303,22 @@ ENTRY(__gnu_mcount_nc)
 #else
 	__mcount
 #endif
+UNWIND(.fnend)
 ENDPROC(__gnu_mcount_nc)
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 ENTRY(ftrace_caller)
+UNWIND(.fnstart)
 	__ftrace_caller
+UNWIND(.fnend)
 ENDPROC(ftrace_caller)
 #endif
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 ENTRY(ftrace_graph_caller)
+UNWIND(.fnstart)
 	__ftrace_graph_caller
+UNWIND(.fnend)
 ENDPROC(ftrace_graph_caller)
 #endif
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] ARM: add unwind annotations to ftrace asm
  2013-03-23 22:10 [PATCH] ARM: add unwind annotations to ftrace asm Rabin Vincent
@ 2013-04-25 14:39 ` Jan Lübbe
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Lübbe @ 2013-04-25 14:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 2013-03-23 at 23:10 +0100, Rabin Vincent wrote:
> Add unwind annotations to the ftrace assembly code so that the function
> tracer's stacktracing options (func_stack_trace, etc.) work when
> CONFIG_ARM_UNWIND is enabled.
> 
> Signed-off-by: Rabin Vincent <rabin@rab.in>

In my test this fixes func_stack_trace:

== without patch ==
# tracer: function
#
# entries-in-buffer/entries-written: 318/318   #P:1
#
#                              _-------=> irqs-off          
#                            /  _------=> need-resched      
#                            |/  _-----=> need-resched_lazy 
#                            ||/  _----=> hardirq/softirq   
#                            |||/  _---=> preempt-depth     
#                            ||||/  _--=> preempt-lazy-depth
#                            ||||| / _-=> migrate-disable   
#                            |||||| /     delay
#           TASK-PID   CPU#  |||||||    TIMESTAMP  FUNCTION
#              | |       |   |||||||       |         |
              sh-829   [000] d..h1..   838.966903: ktime_get <-tick_sched_timer
              sh-829   [000] d..h1..   838.966933: <stack trace>
 => ftrace_ops_no_ops
 => ftrace_graph_call
              sh-829   [000] d..h1..   838.966979: ktime_get <-clockevents_program_event
              sh-829   [000] d..h1..   838.966990: <stack trace>

== with patch ==
# tracer: function
#
# entries-in-buffer/entries-written: 678/678   #P:1
#
#                              _-------=> irqs-off          
#                            /  _------=> need-resched      
#                            |/  _-----=> need-resched_lazy 
#                            ||/  _----=> hardirq/softirq   
#                            |||/  _---=> preempt-depth     
#                            ||||/  _--=> preempt-lazy-depth
#                            ||||| / _-=> migrate-disable   
#                            |||||| /     delay
#           TASK-PID   CPU#  |||||||    TIMESTAMP  FUNCTION
#              | |       |   |||||||       |         |
              sh-828   [000] d..h2..   108.367156: ktime_get <-tick_sched_timer
              sh-828   [000] d..h2..   108.367224: <stack trace>
 => ftrace_ops_no_ops
 => ftrace_graph_call
 => ktime_get
 => tick_sched_timer
 => __run_hrtimer
 => hrtimer_interrupt
 => omap2_gp_timer_interrupt
 => handle_irq_event_percpu
 => handle_irq_event
 => handle_level_irq
 => generic_handle_irq
 => handle_IRQ
 => omap3_intc_handle_irq
 => __irq_svc
 => sub_preempt_count
 => cap_vm_enough_memory
 => security_vm_enough_memory_mm
 => mmap_region
 => do_mmap_pgoff
 => vm_mmap_pgoff
 => sys_mmap_pgoff
 => ret_fast_syscall

Thanks for this fix!

Regards,
Jan
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-25 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-23 22:10 [PATCH] ARM: add unwind annotations to ftrace asm Rabin Vincent
2013-04-25 14:39 ` Jan Lübbe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).