Commit | Line | Data |
---|---|---|
9f36eaed MJ |
1 | /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) |
2 | * | |
886d51a3 | 3 | * wrapper/ftrace.h |
5a9479dc MD |
4 | * |
5 | * wrapper around vmalloc_sync_all. Using KALLSYMS to get its address when | |
6 | * available, else we need to have a kernel that exports this function to GPL | |
7 | * modules. | |
8 | * | |
886d51a3 | 9 | * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
5a9479dc MD |
10 | */ |
11 | ||
9f36eaed MJ |
12 | #ifndef _LTTNG_WRAPPER_FTRACE_H |
13 | #define _LTTNG_WRAPPER_FTRACE_H | |
14 | ||
5a9479dc | 15 | #include <linux/ftrace.h> |
5d849667 MJ |
16 | #include <linux/version.h> |
17 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)) | |
18 | #include <../kernel/trace/trace.h> | |
19 | #endif | |
5a9479dc MD |
20 | |
21 | #ifdef CONFIG_KALLSYMS | |
22 | ||
23 | #include <linux/kallsyms.h> | |
5a2f5e92 | 24 | #include <wrapper/kallsyms.h> |
5a9479dc MD |
25 | |
26 | static inline | |
27 | int wrapper_register_ftrace_function_probe(char *glob, | |
28 | struct ftrace_probe_ops *ops, void *data) | |
29 | { | |
30 | int (*register_ftrace_function_probe_sym)(char *glob, | |
31 | struct ftrace_probe_ops *ops, void *data); | |
32 | ||
c539a324 | 33 | register_ftrace_function_probe_sym = (void *) kallsyms_lookup_funcptr("register_ftrace_function_probe"); |
5a9479dc MD |
34 | if (register_ftrace_function_probe_sym) { |
35 | return register_ftrace_function_probe_sym(glob, ops, data); | |
36 | } else { | |
e36de50d | 37 | printk_once(KERN_WARNING "LTTng: register_ftrace_function_probe symbol lookup failed.\n"); |
5a9479dc MD |
38 | return -EINVAL; |
39 | } | |
40 | } | |
41 | ||
42 | static inline | |
43 | void wrapper_unregister_ftrace_function_probe(char *glob, | |
44 | struct ftrace_probe_ops *ops, void *data) | |
45 | { | |
46 | void (*unregister_ftrace_function_probe_sym)(char *glob, | |
47 | struct ftrace_probe_ops *ops, void *data); | |
48 | ||
c539a324 | 49 | unregister_ftrace_function_probe_sym = (void *) kallsyms_lookup_funcptr("unregister_ftrace_function_probe"); |
5a9479dc MD |
50 | if (unregister_ftrace_function_probe_sym) { |
51 | unregister_ftrace_function_probe_sym(glob, ops, data); | |
52 | } else { | |
e36de50d | 53 | printk_once(KERN_WARNING "LTTng: unregister_ftrace_function_probe symbol lookup failed.\n"); |
5a9479dc MD |
54 | WARN_ON(1); |
55 | } | |
56 | } | |
57 | ||
58 | #else | |
59 | ||
60 | static inline | |
61 | int wrapper_register_ftrace_function_probe(char *glob, | |
c4c357a4 | 62 | struct ftrace_probe_ops *ops, void *data) |
5a9479dc | 63 | { |
9fe47d18 | 64 | return register_ftrace_function_probe(glob, ops, data); |
5a9479dc MD |
65 | } |
66 | ||
67 | static inline | |
68 | void wrapper_unregister_ftrace_function_probe(char *glob, | |
c4c357a4 | 69 | struct ftrace_probe_ops *ops, void *data) |
5a9479dc | 70 | { |
9fe47d18 | 71 | return unregister_ftrace_function_probe(glob, ops, data); |
5a9479dc MD |
72 | } |
73 | #endif | |
74 | ||
a90917c3 | 75 | #endif /* _LTTNG_WRAPPER_FTRACE_H */ |