Fix: kmem probe with Ubuntu 3.13 kernels
[lttng-modules.git] / wrapper / page_alloc.c
CommitLineData
165eee70
MD
1/*
2 * wrapper/page_alloc.c
3 *
be41221e
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.
165eee70
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
e5ffe240
MD
28#if (defined(CONFIG_KALLSYMS) \
29 && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,2) \
30 || LTTNG_DEBIAN_KERNEL_RANGE(3,16,7,9,0,0, 3,17,0,0,0,0)))
165eee70
MD
31
32#include <linux/kallsyms.h>
33#include <linux/mm_types.h>
34#include <linux/module.h>
35#include "kallsyms.h"
36#include "page_alloc.h"
37
38static
39unsigned long (*get_pfnblock_flags_mask_sym)(struct page *page,
40 unsigned long pfn,
41 unsigned long end_bitidx,
42 unsigned long mask);
43
44unsigned long wrapper_get_pfnblock_flags_mask(struct page *page,
45 unsigned long pfn,
46 unsigned long end_bitidx,
47 unsigned long mask)
48{
49 WARN_ON_ONCE(!get_pfnblock_flags_mask_sym);
50 if (get_pfnblock_flags_mask_sym) {
51 return get_pfnblock_flags_mask_sym(page, pfn, end_bitidx, mask);
52 } else {
53 return -ENOSYS;
54 }
55}
56EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask);
57
58int wrapper_get_pfnblock_flags_mask_init(void)
59{
60 get_pfnblock_flags_mask_sym =
61 (void *) kallsyms_lookup_funcptr("get_pfnblock_flags_mask");
62 if (!get_pfnblock_flags_mask_sym)
63 return -1;
64 return 0;
65}
66
be41221e 67#else
165eee70
MD
68
69#include <linux/pageblock-flags.h>
70
be41221e
MD
71#endif
72
73#if (defined(CONFIG_KALLSYMS) \
74 && LTTNG_UBUNTU_KERNEL_RANGE(3,13,11,50, 3,14,0,0))
75
76#include <linux/kallsyms.h>
77#include <linux/mm_types.h>
78#include <linux/module.h>
79#include "kallsyms.h"
80#include "page_alloc.h"
81
82static
83unsigned long (*get_pageblock_flags_mask_sym)(struct page *page,
84 unsigned long end_bitidx,
85 unsigned long mask);
86
87unsigned long wrapper_get_pageblock_flags_mask(struct page *page,
88 unsigned long end_bitidx,
89 unsigned long mask)
90{
91 WARN_ON_ONCE(!get_pageblock_flags_mask_sym);
92 if (get_pageblock_flags_mask_sym) {
93 return get_pageblock_flags_mask_sym(page, end_bitidx, mask);
94 } else {
95 return -ENOSYS;
96 }
97}
98EXPORT_SYMBOL_GPL(wrapper_get_pageblock_flags_mask);
99
100int wrapper_get_pageblock_flags_mask_init(void)
101{
102 get_pageblock_flags_mask_sym =
103 (void *) kallsyms_lookup_funcptr("get_pageblock_flags_mask");
104 if (!get_pageblock_flags_mask_sym)
105 return -1;
106 return 0;
107}
108
109#else
110
111#include <linux/pageblock-flags.h>
112
113#endif
This page took 0.02733 seconds and 4 git commands to generate.