@@ -261,43 +261,23 @@ void ftrace_arch_code_modify_post_process(void)
261261}
262262
263263#ifdef CONFIG_FUNCTION_GRAPH_TRACER
264- /*
265- * Hook the return address and push it in the stack of return addresses
266- * in current thread info.
267- */
268- unsigned long prepare_ftrace_return (unsigned long ra , unsigned long sp ,
269- unsigned long ip )
270- {
271- if (unlikely (ftrace_graph_is_dead ()))
272- goto out ;
273- if (unlikely (atomic_read (& current -> tracing_graph_pause )))
274- goto out ;
275- ip -= MCOUNT_INSN_SIZE ;
276- if (!function_graph_enter (ra , ip , 0 , (void * ) sp ))
277- ra = (unsigned long ) return_to_handler ;
278- out :
279- return ra ;
280- }
281- NOKPROBE_SYMBOL (prepare_ftrace_return );
282264
283- /*
284- * Patch the kernel code at ftrace_graph_caller location. The instruction
285- * there is branch relative on condition. To enable the ftrace graph code
286- * block, we simply patch the mask field of the instruction to zero and
287- * turn the instruction into a nop.
288- * To disable the ftrace graph code the mask field will be patched to
289- * all ones, which turns the instruction into an unconditional branch.
290- */
291- int ftrace_enable_ftrace_graph_caller (void )
265+ void ftrace_graph_func (unsigned long ip , unsigned long parent_ip ,
266+ struct ftrace_ops * op , struct ftrace_regs * fregs )
292267{
293- /* Expect brc 0xf,... */
294- return ftrace_patch_branch_mask (ftrace_graph_caller , 0xa7f4 , false);
295- }
268+ unsigned long * parent = & arch_ftrace_regs (fregs )-> regs .gprs [14 ];
269+ int bit ;
296270
297- int ftrace_disable_ftrace_graph_caller (void )
298- {
299- /* Expect brc 0x0,... */
300- return ftrace_patch_branch_mask (ftrace_graph_caller , 0xa704 , true);
271+ if (unlikely (ftrace_graph_is_dead ()))
272+ return ;
273+ if (unlikely (atomic_read (& current -> tracing_graph_pause )))
274+ return ;
275+ bit = ftrace_test_recursion_trylock (ip , * parent );
276+ if (bit < 0 )
277+ return ;
278+ if (!function_graph_enter_regs (* parent , ip , 0 , parent , fregs ))
279+ * parent = (unsigned long )& return_to_handler ;
280+ ftrace_test_recursion_unlock (bit );
301281}
302282
303283#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
0 commit comments