2009-06-10 04:45:29 -04:00
|
|
|
/*
|
|
|
|
* ftrace graph code
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Analog Devices Inc.
|
|
|
|
* Licensed under the GPL-2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/ftrace.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <asm/atomic.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hook the return address and push it in the stack of return addrs
|
|
|
|
* in current thread info.
|
|
|
|
*/
|
2010-01-22 07:59:32 -05:00
|
|
|
void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
|
|
|
|
unsigned long frame_pointer)
|
2009-06-10 04:45:29 -04:00
|
|
|
{
|
|
|
|
struct ftrace_graph_ent trace;
|
|
|
|
unsigned long return_hooker = (unsigned long)&return_to_handler;
|
|
|
|
|
|
|
|
if (unlikely(atomic_read(¤t->tracing_graph_pause)))
|
|
|
|
return;
|
|
|
|
|
2010-01-22 07:59:32 -05:00
|
|
|
if (ftrace_push_return_trace(*parent, self_addr, &trace.depth,
|
|
|
|
frame_pointer) == -EBUSY)
|
2009-06-10 04:45:29 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
trace.func = self_addr;
|
|
|
|
|
|
|
|
/* Only trace if the calling function expects to */
|
|
|
|
if (!ftrace_graph_entry(&trace)) {
|
|
|
|
current->curr_ret_stack--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all is well in the world ! hijack RETS ... */
|
|
|
|
*parent = return_hooker;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|