Implement wrapper around get_pfnblock_flags_mask
[lttng-modules.git] / wrapper / page_alloc.c
1 /*
2 * wrapper/page_alloc.c
3 *
4 * wrapper around get_pfnblock_flags_mask. Using KALLSYMS to get its address
5 * when available, else we need to have a kernel that exports this function to
6 * GPL modules.
7 *
8 * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; only
13 * version 2.1 of the License.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #include "../lttng-kernel-version.h"
26
27 #if defined(CONFIG_KALLSYMS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,2))
28
29 #include <linux/kallsyms.h>
30 #include <linux/mm_types.h>
31 #include <linux/module.h>
32 #include "kallsyms.h"
33 #include "page_alloc.h"
34
35 static
36 unsigned long (*get_pfnblock_flags_mask_sym)(struct page *page,
37 unsigned long pfn,
38 unsigned long end_bitidx,
39 unsigned long mask);
40
41 unsigned long wrapper_get_pfnblock_flags_mask(struct page *page,
42 unsigned long pfn,
43 unsigned long end_bitidx,
44 unsigned long mask)
45 {
46 WARN_ON_ONCE(!get_pfnblock_flags_mask_sym);
47 if (get_pfnblock_flags_mask_sym) {
48 return get_pfnblock_flags_mask_sym(page, pfn, end_bitidx, mask);
49 } else {
50 return -ENOSYS;
51 }
52 }
53 EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask);
54
55 int wrapper_get_pfnblock_flags_mask_init(void)
56 {
57 get_pfnblock_flags_mask_sym =
58 (void *) kallsyms_lookup_funcptr("get_pfnblock_flags_mask");
59 if (!get_pfnblock_flags_mask_sym)
60 return -1;
61 return 0;
62 }
63
64 #else /* #if defined(CONFIG_KALLSYMS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,2)) */
65
66 #include <linux/pageblock-flags.h>
67
68 #endif /* #else #if defined(CONFIG_KALLSYMS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,2)) */
This page took 0.030359 seconds and 4 git commands to generate.