Fix: global_dirty_limit for kernel v4.2 and up
[lttng-modules.git] / wrapper / writeback.h
1 #ifndef _LTTNG_WRAPPER_WRITEBACK_H
2 #define _LTTNG_WRAPPER_WRITEBACK_H
3
4 /*
5 * wrapper/writeback.h
6 *
7 * wrapper around global_dirty_limit read. Using KALLSYMS with KALLSYMS_ALL
8 * to get its address when available, else we need to have a kernel that
9 * exports this variable to GPL modules.
10 *
11 * Copyright (C) 2013 Mentor Graphics Corp.
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 #include <lttng-kernel-version.h>
29
30 #ifdef CONFIG_KALLSYMS_ALL
31 #include <linux/kallsyms.h>
32 #include <wrapper/kallsyms.h>
33
34
35
36 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
37
38 static struct wb_domain *global_wb_domain_sym;
39
40 static inline
41 unsigned long wrapper_global_dirty_limit(void)
42 {
43 if (!global_wb_domain_sym)
44 global_wb_domain_sym =
45 (void *) kallsyms_lookup_dataptr("global_wb_domain");
46 if (global_wb_domain_sym) {
47 return global_wb_domain_sym->dirty_limit;
48 } else {
49 printk_once(KERN_WARNING "LTTng: global_wb_domain symbol lookup failed.\n");
50 return 0;
51 }
52 }
53 #else
54
55 static unsigned long *global_dirty_limit_sym;
56
57 static inline
58 unsigned long wrapper_global_dirty_limit(void)
59 {
60 if (!global_dirty_limit_sym)
61 global_dirty_limit_sym =
62 (void *) kallsyms_lookup_dataptr("global_dirty_limit");
63 if (global_dirty_limit_sym) {
64 return *global_dirty_limit_sym;
65 } else {
66 printk_once(KERN_WARNING "LTTng: global_dirty_limit symbol lookup failed.\n");
67 return 0;
68 }
69 }
70 #endif
71
72 #else /* CONFIG_KALLSYMS_ALL */
73
74 #include <linux/writeback.h>
75
76 static inline
77 unsigned long wrapper_global_dirty_limit(void)
78 {
79 return global_dirty_limit;
80 }
81
82 #endif
83
84 #endif /* _LTTNG_WRAPPER_WRITEBACK_H */
This page took 0.029925 seconds and 4 git commands to generate.