Fix: global_dirty_limit for kernel v4.2 and up
[lttng-modules.git] / wrapper / writeback.h
CommitLineData
42d9070d
AG
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
6284ae7c 28#include <lttng-kernel-version.h>
42d9070d 29
6284ae7c 30#ifdef CONFIG_KALLSYMS_ALL
42d9070d 31#include <linux/kallsyms.h>
5a2f5e92 32#include <wrapper/kallsyms.h>
42d9070d 33
6284ae7c
MJ
34
35
36#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
37
38static struct wb_domain *global_wb_domain_sym;
39
40static inline
41unsigned 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
42d9070d
AG
55static unsigned long *global_dirty_limit_sym;
56
57static inline
58unsigned 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 {
e36de50d 66 printk_once(KERN_WARNING "LTTng: global_dirty_limit symbol lookup failed.\n");
42d9070d
AG
67 return 0;
68 }
69}
6284ae7c 70#endif
42d9070d 71
6284ae7c 72#else /* CONFIG_KALLSYMS_ALL */
42d9070d
AG
73
74#include <linux/writeback.h>
75
76static inline
77unsigned 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.033786 seconds and 4 git commands to generate.