Commit | Line | Data |
---|---|---|
66861b2e MD |
1 | /* |
2 | * wrapper/page_alloc.c | |
3 | * | |
7d5f6cef MD |
4 | * wrapper around get_pfnblock_flags_mask and Ubuntu |
5 | * get_pageblock_flags_mask. Using KALLSYMS to get their address when | |
6 | * available, else we need to have a kernel that exports this function | |
7 | * to GPL modules. | |
66861b2e MD |
8 | * |
9 | * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
10 | * | |
11 | * This library is free software; you can redistribute it and/or | |
12 | * modify it under the terms of the GNU Lesser General Public | |
13 | * License as published by the Free Software Foundation; only | |
14 | * version 2.1 of the License. | |
15 | * | |
16 | * This library is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | * Lesser General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU Lesser General Public | |
22 | * License along with this library; if not, write to the Free Software | |
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
24 | */ | |
25 | ||
26 | #include "../lttng-kernel-version.h" | |
27 | ||
28 | #if defined(CONFIG_KALLSYMS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,2)) | |
29 | ||
30 | #include <linux/kallsyms.h> | |
31 | #include <linux/mm_types.h> | |
32 | #include <linux/module.h> | |
33 | #include "kallsyms.h" | |
34 | #include "page_alloc.h" | |
35 | ||
36 | static | |
37 | unsigned long (*get_pfnblock_flags_mask_sym)(struct page *page, | |
38 | unsigned long pfn, | |
39 | unsigned long end_bitidx, | |
40 | unsigned long mask); | |
41 | ||
42 | unsigned long wrapper_get_pfnblock_flags_mask(struct page *page, | |
43 | unsigned long pfn, | |
44 | unsigned long end_bitidx, | |
45 | unsigned long mask) | |
46 | { | |
47 | WARN_ON_ONCE(!get_pfnblock_flags_mask_sym); | |
48 | if (get_pfnblock_flags_mask_sym) { | |
49 | return get_pfnblock_flags_mask_sym(page, pfn, end_bitidx, mask); | |
50 | } else { | |
51 | return -ENOSYS; | |
52 | } | |
53 | } | |
54 | EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask); | |
55 | ||
56 | int wrapper_get_pfnblock_flags_mask_init(void) | |
57 | { | |
58 | get_pfnblock_flags_mask_sym = | |
59 | (void *) kallsyms_lookup_funcptr("get_pfnblock_flags_mask"); | |
60 | if (!get_pfnblock_flags_mask_sym) | |
61 | return -1; | |
62 | return 0; | |
63 | } | |
64 | ||
7d5f6cef | 65 | #else |
66861b2e MD |
66 | |
67 | #include <linux/pageblock-flags.h> | |
68 | ||
7d5f6cef MD |
69 | #endif |
70 | ||
71 | #if (defined(CONFIG_KALLSYMS) \ | |
72 | && LTTNG_UBUNTU_KERNEL_RANGE(3,13,11,50, 3,14,0,0)) | |
73 | ||
74 | #include <linux/kallsyms.h> | |
75 | #include <linux/mm_types.h> | |
76 | #include <linux/module.h> | |
77 | #include "kallsyms.h" | |
78 | #include "page_alloc.h" | |
79 | ||
80 | static | |
81 | unsigned long (*get_pageblock_flags_mask_sym)(struct page *page, | |
82 | unsigned long end_bitidx, | |
83 | unsigned long mask); | |
84 | ||
85 | unsigned long wrapper_get_pageblock_flags_mask(struct page *page, | |
86 | unsigned long end_bitidx, | |
87 | unsigned long mask) | |
88 | { | |
89 | WARN_ON_ONCE(!get_pageblock_flags_mask_sym); | |
90 | if (get_pageblock_flags_mask_sym) { | |
91 | return get_pageblock_flags_mask_sym(page, end_bitidx, mask); | |
92 | } else { | |
93 | return -ENOSYS; | |
94 | } | |
95 | } | |
96 | EXPORT_SYMBOL_GPL(wrapper_get_pageblock_flags_mask); | |
97 | ||
98 | int wrapper_get_pageblock_flags_mask_init(void) | |
99 | { | |
100 | get_pageblock_flags_mask_sym = | |
101 | (void *) kallsyms_lookup_funcptr("get_pageblock_flags_mask"); | |
102 | if (!get_pageblock_flags_mask_sym) | |
103 | return -1; | |
104 | return 0; | |
105 | } | |
106 | ||
107 | #else | |
108 | ||
109 | #include <linux/pageblock-flags.h> | |
110 | ||
111 | #endif |