diff options
author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2008-05-12 15:20:42 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2008-05-23 14:31:58 -0400 |
commit | 16444a8a40d4c7b4f6de34af0cae1f76a4f6c901 (patch) | |
tree | 9c290bcdbdc1ecf8f578c30b3b36914e14fdaacc /include/linux/ftrace.h | |
parent | 6e766410c4babd37bc7cd5e25009c179781742c8 (diff) |
ftrace: add basic support for gcc profiler instrumentation
If CONFIG_FTRACE is selected and /proc/sys/kernel/ftrace_enabled is
set to a non-zero value the ftrace routine will be called everytime
we enter a kernel function that is not marked with the "notrace"
attribute.
The ftrace routine will then call a registered function if a function
happens to be registered.
[ This code has been highly hacked by Steven Rostedt and Ingo Molnar,
so don't blame Arnaldo for all of this ;-) ]
Update:
It is now possible to register more than one ftrace function.
If only one ftrace function is registered, that will be the
function that ftrace calls directly. If more than one function
is registered, then ftrace will call a function that will loop
through the functions to call.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux/ftrace.h')
-rw-r--r-- | include/linux/ftrace.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h new file mode 100644 index 000000000000..b96ef14c249a --- /dev/null +++ b/include/linux/ftrace.h | |||
@@ -0,0 +1,38 @@ | |||
1 | #ifndef _LINUX_FTRACE_H | ||
2 | #define _LINUX_FTRACE_H | ||
3 | |||
4 | #ifdef CONFIG_FTRACE | ||
5 | |||
6 | #include <linux/linkage.h> | ||
7 | |||
8 | #define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) | ||
9 | #define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1)) | ||
10 | #define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2)) | ||
11 | |||
12 | typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip); | ||
13 | |||
14 | struct ftrace_ops { | ||
15 | ftrace_func_t func; | ||
16 | struct ftrace_ops *next; | ||
17 | }; | ||
18 | |||
19 | /* | ||
20 | * The ftrace_ops must be a static and should also | ||
21 | * be read_mostly. These functions do modify read_mostly variables | ||
22 | * so use them sparely. Never free an ftrace_op or modify the | ||
23 | * next pointer after it has been registered. Even after unregistering | ||
24 | * it, the next pointer may still be used internally. | ||
25 | */ | ||
26 | int register_ftrace_function(struct ftrace_ops *ops); | ||
27 | int unregister_ftrace_function(struct ftrace_ops *ops); | ||
28 | void clear_ftrace_function(void); | ||
29 | |||
30 | extern void ftrace_stub(unsigned long a0, unsigned long a1); | ||
31 | extern void mcount(void); | ||
32 | |||
33 | #else /* !CONFIG_FTRACE */ | ||
34 | # define register_ftrace_function(ops) do { } while (0) | ||
35 | # define unregister_ftrace_function(ops) do { } while (0) | ||
36 | # define clear_ftrace_function(ops) do { } while (0) | ||
37 | #endif /* CONFIG_FTRACE */ | ||
38 | #endif /* _LINUX_FTRACE_H */ | ||