2332439fe34c56515cefcaa4eda787a65ecaf835
[lttng-modules.git] / wrapper / vmalloc.h
1 #ifndef _LTTNG_WRAPPER_VMALLOC_H
2 #define _LTTNG_WRAPPER_VMALLOC_H
3
4 /*
5 * wrapper/vmalloc.h
6 *
7 * wrapper around vmalloc_sync_all. Using KALLSYMS to get its address when
8 * available, else we need to have a kernel that exports this function to GPL
9 * modules.
10 *
11 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; only
16 * version 2.1 of the License.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 */
27
28 #ifdef CONFIG_KALLSYMS
29
30 #include <linux/kallsyms.h>
31 #include <wrapper/kallsyms.h>
32
33 static inline
34 void wrapper_vmalloc_sync_all(void)
35 {
36 void (*vmalloc_sync_all_sym)(void);
37
38 vmalloc_sync_all_sym = (void *) kallsyms_lookup_funcptr("vmalloc_sync_all");
39 if (vmalloc_sync_all_sym) {
40 vmalloc_sync_all_sym();
41 } else {
42 #ifdef CONFIG_X86
43 /*
44 * Only x86 needs vmalloc_sync_all to make sure LTTng does not
45 * trigger recursive page faults.
46 */
47 printk_once(KERN_WARNING "LTTng: vmalloc_sync_all symbol lookup failed.\n");
48 printk_once(KERN_WARNING "Page fault handler and NMI tracing might trigger faults.\n");
49 #endif
50 }
51 }
52 #else
53
54 #include <linux/vmalloc.h>
55
56 static inline
57 void wrapper_vmalloc_sync_all(void)
58 {
59 return vmalloc_sync_all();
60 }
61 #endif
62
63 #endif /* _LTTNG_WRAPPER_VMALLOC_H */
This page took 0.029841 seconds and 3 git commands to generate.