[lttng-dev] [PATCH 07/20] lttng wrappers
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Mon Nov 28 07:42:14 EST 2011
Implement wrappers for compatibility with older kernel versions and
kernels with had the libringbuffer (old) patchset applied.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
drivers/staging/lttng/wrapper/ftrace.h | 70 ++++++++++++++++++
drivers/staging/lttng/wrapper/inline_memcpy.h | 11 +++
drivers/staging/lttng/wrapper/kallsyms.h | 28 +++++++
drivers/staging/lttng/wrapper/perf.h | 32 ++++++++
drivers/staging/lttng/wrapper/poll.h | 14 ++++
drivers/staging/lttng/wrapper/ringbuffer/api.h | 1 +
drivers/staging/lttng/wrapper/ringbuffer/backend.h | 1 +
.../lttng/wrapper/ringbuffer/backend_internal.h | 2 +
.../lttng/wrapper/ringbuffer/backend_types.h | 1 +
drivers/staging/lttng/wrapper/ringbuffer/config.h | 1 +
.../staging/lttng/wrapper/ringbuffer/frontend.h | 1 +
.../lttng/wrapper/ringbuffer/frontend_api.h | 1 +
.../lttng/wrapper/ringbuffer/frontend_internal.h | 1 +
.../lttng/wrapper/ringbuffer/frontend_types.h | 1 +
.../staging/lttng/wrapper/ringbuffer/iterator.h | 1 +
drivers/staging/lttng/wrapper/ringbuffer/nohz.h | 1 +
drivers/staging/lttng/wrapper/ringbuffer/vatomic.h | 1 +
drivers/staging/lttng/wrapper/ringbuffer/vfs.h | 1 +
drivers/staging/lttng/wrapper/spinlock.h | 26 +++++++
drivers/staging/lttng/wrapper/splice.c | 46 ++++++++++++
drivers/staging/lttng/wrapper/splice.h | 23 ++++++
drivers/staging/lttng/wrapper/trace-clock.h | 75 ++++++++++++++++++++
drivers/staging/lttng/wrapper/uuid.h | 29 ++++++++
drivers/staging/lttng/wrapper/vmalloc.h | 49 +++++++++++++
24 files changed, 417 insertions(+), 0 deletions(-)
create mode 100644 drivers/staging/lttng/wrapper/ftrace.h
create mode 100644 drivers/staging/lttng/wrapper/inline_memcpy.h
create mode 100644 drivers/staging/lttng/wrapper/kallsyms.h
create mode 100644 drivers/staging/lttng/wrapper/perf.h
create mode 100644 drivers/staging/lttng/wrapper/poll.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/api.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/backend.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/backend_internal.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/backend_types.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/config.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/frontend.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/frontend_api.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/frontend_internal.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/frontend_types.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/iterator.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/nohz.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/vatomic.h
create mode 100644 drivers/staging/lttng/wrapper/ringbuffer/vfs.h
create mode 100644 drivers/staging/lttng/wrapper/spinlock.h
create mode 100644 drivers/staging/lttng/wrapper/splice.c
create mode 100644 drivers/staging/lttng/wrapper/splice.h
create mode 100644 drivers/staging/lttng/wrapper/trace-clock.h
create mode 100644 drivers/staging/lttng/wrapper/uuid.h
create mode 100644 drivers/staging/lttng/wrapper/vmalloc.h
diff --git a/drivers/staging/lttng/wrapper/ftrace.h b/drivers/staging/lttng/wrapper/ftrace.h
new file mode 100644
index 0000000..ace33c5
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ftrace.h
@@ -0,0 +1,70 @@
+#ifndef _LTT_WRAPPER_FTRACE_H
+#define _LTT_WRAPPER_FTRACE_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers at efficios.com)
+ *
+ * wrapper around vmalloc_sync_all. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/ftrace.h>
+
+#ifdef CONFIG_KALLSYMS
+
+#include <linux/kallsyms.h>
+#include "kallsyms.h"
+
+static inline
+int wrapper_register_ftrace_function_probe(char *glob,
+ struct ftrace_probe_ops *ops, void *data)
+{
+ int (*register_ftrace_function_probe_sym)(char *glob,
+ struct ftrace_probe_ops *ops, void *data);
+
+ register_ftrace_function_probe_sym = (void *) kallsyms_lookup_funcptr("register_ftrace_function_probe");
+ if (register_ftrace_function_probe_sym) {
+ return register_ftrace_function_probe_sym(glob, ops, data);
+ } else {
+ printk(KERN_WARNING "LTTng: register_ftrace_function_probe symbol lookup failed.\n");
+ return -EINVAL;
+ }
+}
+
+static inline
+void wrapper_unregister_ftrace_function_probe(char *glob,
+ struct ftrace_probe_ops *ops, void *data)
+{
+ void (*unregister_ftrace_function_probe_sym)(char *glob,
+ struct ftrace_probe_ops *ops, void *data);
+
+ unregister_ftrace_function_probe_sym = (void *) kallsyms_lookup_funcptr("unregister_ftrace_function_probe");
+ if (unregister_ftrace_function_probe_sym) {
+ unregister_ftrace_function_probe_sym(glob, ops, data);
+ } else {
+ printk(KERN_WARNING "LTTng: unregister_ftrace_function_probe symbol lookup failed.\n");
+ WARN_ON(1);
+ }
+}
+
+#else
+
+static inline
+int wrapper_register_ftrace_function_probe(char *glob,
+ struct ftrace_probe_ops *ops, void *data)
+{
+ return register_ftrace_function_probe(glob, ops, data);
+}
+
+static inline
+void wrapper_unregister_ftrace_function_probe(char *glob,
+ struct ftrace_probe_ops *ops, void *data)
+{
+ return unregister_ftrace_function_probe(glob, ops, data);
+}
+#endif
+
+#endif /* _LTT_WRAPPER_FTRACE_H */
diff --git a/drivers/staging/lttng/wrapper/inline_memcpy.h b/drivers/staging/lttng/wrapper/inline_memcpy.h
new file mode 100644
index 0000000..33150cd
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/inline_memcpy.h
@@ -0,0 +1,11 @@
+/*
+ * wrapper/inline_memcpy.h
+ *
+ * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#if !defined(__HAVE_ARCH_INLINE_MEMCPY) && !defined(inline_memcpy)
+#define inline_memcpy memcpy
+#endif
diff --git a/drivers/staging/lttng/wrapper/kallsyms.h b/drivers/staging/lttng/wrapper/kallsyms.h
new file mode 100644
index 0000000..bb45f38
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/kallsyms.h
@@ -0,0 +1,28 @@
+#ifndef _LTT_WRAPPER_KALLSYMS_H
+#define _LTT_WRAPPER_KALLSYMS_H
+
+/*
+ * Copyright (C) 2011 Avik Sil (avik.sil at linaro.org)
+ *
+ * wrapper around kallsyms_lookup_name. Implements arch-dependent code for
+ * arches where the address of the start of the function body is different
+ * from the pointer which can be used to call the function, e.g. ARM THUMB2.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+static inline
+unsigned long kallsyms_lookup_funcptr(const char *name)
+{
+ unsigned long addr;
+
+ addr = kallsyms_lookup_name(name);
+#ifdef CONFIG_ARM
+#ifdef CONFIG_THUMB2_KERNEL
+ if (addr)
+ addr |= 1; /* set bit 0 in address for thumb mode */
+#endif
+#endif
+ return addr;
+}
+#endif /* _LTT_WRAPPER_KALLSYMS_H */
diff --git a/drivers/staging/lttng/wrapper/perf.h b/drivers/staging/lttng/wrapper/perf.h
new file mode 100644
index 0000000..9a6dbfc
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/perf.h
@@ -0,0 +1,32 @@
+#ifndef _LTT_WRAPPER_PERF_H
+#define _LTT_WRAPPER_PERF_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers at efficios.com)
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/perf_event.h>
+
+#if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,99))
+static inline struct perf_event *
+wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
+ int cpu,
+ struct task_struct *task,
+ perf_overflow_handler_t callback)
+{
+ return perf_event_create_kernel_counter(attr, cpu, task, callback, NULL);
+}
+#else
+static inline struct perf_event *
+wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
+ int cpu,
+ struct task_struct *task,
+ perf_overflow_handler_t callback)
+{
+ return perf_event_create_kernel_counter(attr, cpu, task, callback);
+}
+#endif
+
+#endif /* _LTT_WRAPPER_PERF_H */
diff --git a/drivers/staging/lttng/wrapper/poll.h b/drivers/staging/lttng/wrapper/poll.h
new file mode 100644
index 0000000..9c2d18f
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/poll.h
@@ -0,0 +1,14 @@
+#ifndef _LTTNG_WRAPPER_POLL_H
+#define _LTTNG_WRAPPER_POLL_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers at efficios.com)
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/poll.h>
+
+#define poll_wait_set_exclusive(poll_table)
+
+#endif /* _LTTNG_WRAPPER_POLL_H */
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/api.h b/drivers/staging/lttng/wrapper/ringbuffer/api.h
new file mode 100644
index 0000000..182bee2
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/api.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/api.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/backend.h b/drivers/staging/lttng/wrapper/ringbuffer/backend.h
new file mode 100644
index 0000000..bfdd39d
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/backend.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/backend.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/backend_internal.h b/drivers/staging/lttng/wrapper/ringbuffer/backend_internal.h
new file mode 100644
index 0000000..00d45e4
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/backend_internal.h
@@ -0,0 +1,2 @@
+#include "../../wrapper/inline_memcpy.h"
+#include "../../lib/ringbuffer/backend_internal.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/backend_types.h b/drivers/staging/lttng/wrapper/ringbuffer/backend_types.h
new file mode 100644
index 0000000..c59effd
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/backend_types.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/backend_types.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/config.h b/drivers/staging/lttng/wrapper/ringbuffer/config.h
new file mode 100644
index 0000000..0ce7a9d
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/config.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/config.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/frontend.h b/drivers/staging/lttng/wrapper/ringbuffer/frontend.h
new file mode 100644
index 0000000..7c6c070
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/frontend.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/frontend.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/frontend_api.h b/drivers/staging/lttng/wrapper/ringbuffer/frontend_api.h
new file mode 100644
index 0000000..b03c501
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/frontend_api.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/frontend_api.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/frontend_internal.h b/drivers/staging/lttng/wrapper/ringbuffer/frontend_internal.h
new file mode 100644
index 0000000..1899101
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/frontend_internal.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/frontend_internal.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/frontend_types.h b/drivers/staging/lttng/wrapper/ringbuffer/frontend_types.h
new file mode 100644
index 0000000..0c23244
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/frontend_types.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/frontend_types.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/iterator.h b/drivers/staging/lttng/wrapper/ringbuffer/iterator.h
new file mode 100644
index 0000000..76e9edb
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/iterator.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/iterator.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/nohz.h b/drivers/staging/lttng/wrapper/ringbuffer/nohz.h
new file mode 100644
index 0000000..9fbb84d
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/nohz.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/nohz.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/vatomic.h b/drivers/staging/lttng/wrapper/ringbuffer/vatomic.h
new file mode 100644
index 0000000..d578445
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/vatomic.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/vatomic.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/vfs.h b/drivers/staging/lttng/wrapper/ringbuffer/vfs.h
new file mode 100644
index 0000000..f8e9ed9
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/ringbuffer/vfs.h
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/vfs.h"
diff --git a/drivers/staging/lttng/wrapper/spinlock.h b/drivers/staging/lttng/wrapper/spinlock.h
new file mode 100644
index 0000000..8b1ad99
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/spinlock.h
@@ -0,0 +1,26 @@
+#ifndef _LTT_WRAPPER_SPINLOCK_H
+#define _LTT_WRAPPER_SPINLOCK_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers at efficios.com)
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+
+#include <linux/string.h>
+
+#define raw_spin_lock_init(lock) \
+ do { \
+ raw_spinlock_t __lock = __RAW_SPIN_LOCK_UNLOCKED; \
+ memcpy(lock, &__lock, sizeof(lock)); \
+ } while (0)
+
+#define raw_spin_is_locked(lock) __raw_spin_is_locked(lock)
+
+
+#endif
+#endif /* _LTT_WRAPPER_SPINLOCK_H */
diff --git a/drivers/staging/lttng/wrapper/splice.c b/drivers/staging/lttng/wrapper/splice.c
new file mode 100644
index 0000000..ba224ee
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/splice.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers at efficios.com)
+ *
+ * wrapper around vmalloc_sync_all. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#ifdef CONFIG_KALLSYMS
+
+#include <linux/kallsyms.h>
+#include <linux/fs.h>
+#include <linux/splice.h>
+#include "kallsyms.h"
+
+static
+ssize_t (*splice_to_pipe_sym)(struct pipe_inode_info *pipe,
+ struct splice_pipe_desc *spd);
+
+ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
+ struct splice_pipe_desc *spd)
+{
+ if (!splice_to_pipe_sym)
+ splice_to_pipe_sym = (void *) kallsyms_lookup_funcptr("splice_to_pipe");
+ if (splice_to_pipe_sym) {
+ return splice_to_pipe_sym(pipe, spd);
+ } else {
+ printk(KERN_WARNING "LTTng: splice_to_pipe symbol lookup failed.\n");
+ return -ENOSYS;
+ }
+}
+
+#else
+
+#include <linux/fs.h>
+#include <linux/splice.h>
+
+ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
+ struct splice_pipe_desc *spd)
+{
+ return splice_to_pipe(pipe, spd);
+}
+
+#endif
diff --git a/drivers/staging/lttng/wrapper/splice.h b/drivers/staging/lttng/wrapper/splice.h
new file mode 100644
index 0000000..f75309a
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/splice.h
@@ -0,0 +1,23 @@
+#ifndef _LTT_WRAPPER_SPLICE_H
+#define _LTT_WRAPPER_SPLICE_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers at efficios.com)
+ *
+ * wrapper around vmalloc_sync_all. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/splice.h>
+
+ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
+ struct splice_pipe_desc *spd);
+
+#ifndef PIPE_DEF_BUFFERS
+#define PIPE_DEF_BUFFERS 16
+#endif
+
+#endif /* _LTT_WRAPPER_SPLICE_H */
diff --git a/drivers/staging/lttng/wrapper/trace-clock.h b/drivers/staging/lttng/wrapper/trace-clock.h
new file mode 100644
index 0000000..8b77428
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/trace-clock.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers at efficios.com)
+ *
+ * Contains LTTng trace clock mapping to LTTng trace clock or mainline monotonic
+ * clock. This wrapper depends on CONFIG_HIGH_RES_TIMERS=y.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#ifndef _LTT_TRACE_CLOCK_H
+#define _LTT_TRACE_CLOCK_H
+
+#ifdef CONFIG_HAVE_TRACE_CLOCK
+#include <linux/trace-clock.h>
+#else /* CONFIG_HAVE_TRACE_CLOCK */
+
+#include <linux/hardirq.h>
+#include <linux/ktime.h>
+#include <linux/time.h>
+#include <linux/hrtimer.h>
+
+static inline u64 trace_clock_monotonic_wrapper(void)
+{
+ ktime_t ktime;
+
+ /*
+ * Refuse to trace from NMIs with this wrapper, because an NMI could
+ * nest over the xtime write seqlock and deadlock.
+ */
+ if (in_nmi())
+ return (u64) -EIO;
+
+ ktime = ktime_get();
+ return (u64) ktime.tv64;
+}
+
+static inline u32 trace_clock_read32(void)
+{
+ return (u32) trace_clock_monotonic_wrapper();
+}
+
+static inline u64 trace_clock_read64(void)
+{
+ return (u64) trace_clock_monotonic_wrapper();
+}
+
+static inline u64 trace_clock_frequency(void)
+{
+ return (u64)NSEC_PER_SEC;
+}
+
+static inline u32 trace_clock_freq_scale(void)
+{
+ return 1;
+}
+
+static inline int get_trace_clock(void)
+{
+ printk(KERN_WARNING "LTTng: Using mainline kernel monotonic clock.\n");
+ printk(KERN_WARNING " * NMIs will not be traced,\n");
+ printk(KERN_WARNING " * expect significant performance degradation compared to the\n");
+ printk(KERN_WARNING " LTTng trace clocks.\n");
+ printk(KERN_WARNING "Integration of the LTTng 0.x trace clocks into LTTng 2.0 is planned\n");
+ printk(KERN_WARNING "in a near future.\n");
+
+ return 0;
+}
+
+static inline void put_trace_clock(void)
+{
+}
+
+#endif /* CONFIG_HAVE_TRACE_CLOCK */
+
+#endif /* _LTT_TRACE_CLOCK_H */
diff --git a/drivers/staging/lttng/wrapper/uuid.h b/drivers/staging/lttng/wrapper/uuid.h
new file mode 100644
index 0000000..bfa67ff
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/uuid.h
@@ -0,0 +1,29 @@
+#ifndef _LTT_WRAPPER_UUID_H
+#define _LTT_WRAPPER_UUID_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers at efficios.com)
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+#include <linux/uuid.h>
+#else
+
+#include <linux/random.h>
+
+typedef struct {
+ __u8 b[16];
+} uuid_le;
+
+static inline
+void uuid_le_gen(uuid_le *u)
+{
+ generate_random_uuid(u->b);
+}
+
+#endif
+#endif /* _LTT_WRAPPER_UUID_H */
diff --git a/drivers/staging/lttng/wrapper/vmalloc.h b/drivers/staging/lttng/wrapper/vmalloc.h
new file mode 100644
index 0000000..765f2ad
--- /dev/null
+++ b/drivers/staging/lttng/wrapper/vmalloc.h
@@ -0,0 +1,49 @@
+#ifndef _LTT_WRAPPER_VMALLOC_H
+#define _LTT_WRAPPER_VMALLOC_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers at efficios.com)
+ *
+ * wrapper around vmalloc_sync_all. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#ifdef CONFIG_KALLSYMS
+
+#include <linux/kallsyms.h>
+#include "kallsyms.h"
+
+static inline
+void wrapper_vmalloc_sync_all(void)
+{
+ void (*vmalloc_sync_all_sym)(void);
+
+ vmalloc_sync_all_sym = (void *) kallsyms_lookup_funcptr("vmalloc_sync_all");
+ if (vmalloc_sync_all_sym) {
+ vmalloc_sync_all_sym();
+ } else {
+#ifdef CONFIG_X86
+ /*
+ * Only x86 needs vmalloc_sync_all to make sure LTTng does not
+ * trigger recursive page faults.
+ */
+ printk(KERN_WARNING "LTTng: vmalloc_sync_all symbol lookup failed.\n");
+ printk(KERN_WARNING "Page fault handler and NMI tracing might trigger faults.\n");
+#endif
+ }
+}
+#else
+
+#include <linux/vmalloc.h>
+
+static inline
+void wrapper_vmalloc_sync_all(void)
+{
+ return vmalloc_sync_all();
+}
+#endif
+
+#endif /* _LTT_WRAPPER_VMALLOC_H */
--
1.7.2.5
More information about the lttng-dev
mailing list