blob: a61d948ea92531de3bf1662a3ae981e8b3782f97 [file] [log] [blame]
Mike Frysinger1ee76d72009-06-10 04:45:29 -04001/*
2 * ftrace graph code
3 *
4 * Copyright (C) 2009 Analog Devices Inc.
5 * Licensed under the GPL-2 or later.
6 */
7
8#include <linux/ftrace.h>
9#include <linux/kernel.h>
10#include <linux/sched.h>
11#include <asm/atomic.h>
12
13#ifdef CONFIG_FUNCTION_GRAPH_TRACER
14
15/*
16 * Hook the return address and push it in the stack of return addrs
17 * in current thread info.
18 */
Mike Frysingerb73faf72010-01-22 07:59:32 -050019void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
20 unsigned long frame_pointer)
Mike Frysinger1ee76d72009-06-10 04:45:29 -040021{
22 struct ftrace_graph_ent trace;
23 unsigned long return_hooker = (unsigned long)&return_to_handler;
24
25 if (unlikely(atomic_read(&current->tracing_graph_pause)))
26 return;
27
Mike Frysingerb73faf72010-01-22 07:59:32 -050028 if (ftrace_push_return_trace(*parent, self_addr, &trace.depth,
29 frame_pointer) == -EBUSY)
Mike Frysinger1ee76d72009-06-10 04:45:29 -040030 return;
31
32 trace.func = self_addr;
33
34 /* Only trace if the calling function expects to */
35 if (!ftrace_graph_entry(&trace)) {
36 current->curr_ret_stack--;
37 return;
38 }
39
40 /* all is well in the world ! hijack RETS ... */
41 *parent = return_hooker;
42}
43
44#endif