Re: [PATCH v1 3/5] mips function graph tracer support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 29 May 2009, wuzhangjin@xxxxxxxxx wrote:
> diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
> index ce8a0ba..bd58f16 100644
> --- a/arch/mips/kernel/mcount.S
> +++ b/arch/mips/kernel/mcount.S
> @@ -28,6 +28,10 @@
>  	PTR_SUBU	sp, PT_SIZE
>  	PTR_S	ra, PT_R31(sp)
>  	PTR_S	$1, PT_R1(sp)
> +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> +	PTR_S	v0, PT_R2(sp)
> +	PTR_S	v1, PT_R3(sp)
> +#endif
>  	PTR_S	a0, PT_R4(sp)
>  	PTR_S	a1, PT_R5(sp)
>  	PTR_S	a2, PT_R6(sp)
> @@ -43,6 +47,10 @@
>  	.macro MCOUNT_RESTORE_REGS
>  	PTR_L	ra, PT_R31(sp)
>  	PTR_L	$1, PT_R1(sp)
> +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> +	PTR_L	v0, PT_R2(sp)
> +	PTR_L	v1, PT_R3(sp)
> +#endif
>  	PTR_L	a0, PT_R4(sp)
>  	PTR_L	a1, PT_R5(sp)
>  	PTR_L	a2, PT_R6(sp)
> @@ -89,6 +97,14 @@ ftrace_call:
>  	nop
>  
>  	MCOUNT_RESTORE_REGS
> +
> +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> +	.globl ftrace_graph_call
> +ftrace_graph_call:
> +	j	ftrace_stub
> +	nop
> +#endif
> +
>  	.globl ftrace_stub
>  ftrace_stub:
>  	RETURN_BACK
> @@ -106,7 +122,15 @@ NESTED(_mcount, PT_SIZE, ra)
>  	PTR_L	t1, ftrace_trace_function /* please don't use t1 later, safe? */
>  	bne	t0, t1, static_trace
>  	nop
> -
> +#ifdef	CONFIG_FUNCTION_GRAPH_TRACER
> +	PTR_L	t2, ftrace_graph_return
> +	bne	t0,	t2, ftrace_graph_caller
> +	nop
> +	PTR_LA	t0, ftrace_graph_entry_stub
> +	PTR_L	t2, ftrace_graph_entry
> +	bne	t0,	t2, ftrace_graph_caller
> +	nop
> +#endif
>  	j	ftrace_stub
>  	nop
>  
> @@ -125,5 +149,37 @@ ftrace_stub:
>  
>  #endif	/* ! CONFIG_DYNAMIC_FTRACE */
>  
> +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> +
> +NESTED(ftrace_graph_caller, PT_SIZE, ra)
> +	MCOUNT_SAVE_REGS
> +
> +	MCOUNT_SET_ARGS
> +	jal	prepare_ftrace_return
> +	nop
> +
> +	/* overwrite the parent as &return_to_handler: v0 -> $1(at) */
> +	PTR_S	v0, PT_R1(sp)
> +
> +	MCOUNT_RESTORE_REGS
> +	RETURN_BACK
> +	END(ftrace_graph_caller)
> +
> +	.align	2
> +	.globl	return_to_handler
> +return_to_handler:
> +	MCOUNT_SAVE_REGS

I'm not sure which version of function_graph tracer you looked at, but I'm 
pretty sure you can just save the return code registers of the function.

return_to_handler is called on the return of a function. Thus, any callee 
saved registers have already been restored and would also be restored by 
ftrace_return_to_handler.  Any callee registers would have been saved by 
the function you are about to return to.

Thus the only things you need to save are the return code registers.

-- Steve


> +
> +	jal	ftrace_return_to_handler
> +	nop
> +
> +	/* restore the real parent address: v0 -> ra */
> +	PTR_S	v0, PT_R31(sp)
> +
> +	MCOUNT_RESTORE_REGS
> +	RETURN_BACK
> +
> +#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
> +
>  	.set at
>  	.set reorder
> diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
> index 58738c8..67435e5 100644
> --- a/arch/mips/kernel/vmlinux.lds.S
> +++ b/arch/mips/kernel/vmlinux.lds.S
> @@ -36,6 +36,7 @@ SECTIONS
>  		SCHED_TEXT
>  		LOCK_TEXT
>  		KPROBES_TEXT
> +		IRQENTRY_TEXT
>  		*(.text.*)
>  		*(.fixup)
>  		*(.gnu.warning)
> -- 
> 1.6.0.4
> 
> 


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux