From 6d2a620c03c40df6fb09429e9895f71c5d9dfa76 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 11 May 2011 09:24:54 -0400 Subject: [PATCH] Remove dependency on vmalloc_sync_all symbol Signed-off-by: Mathieu Desnoyers --- lib/ringbuffer/ring_buffer_backend.c | 4 +-- ltt-debugfs-abi.c | 4 +-- ltt-events.c | 4 +-- ltt-ring-buffer-client.h | 4 +-- probes/lttng-events.h | 4 +-- probes/lttng-types.c | 4 +-- wrapper/symbols.h | 43 ++++++++++++++++++++++++++++ 7 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 wrapper/symbols.h diff --git a/lib/ringbuffer/ring_buffer_backend.c b/lib/ringbuffer/ring_buffer_backend.c index f9ec3d1e..2d272c77 100644 --- a/lib/ringbuffer/ring_buffer_backend.c +++ b/lib/ringbuffer/ring_buffer_backend.c @@ -6,7 +6,6 @@ * Dual LGPL v2.1/GPL v2 license. */ -#include #include #include #include @@ -17,6 +16,7 @@ #include #include +#include "../../wrapper/symbols.h" /* for wrapper_vmalloc_sync_all() */ #include "../../wrapper/ringbuffer/config.h" #include "../../wrapper/ringbuffer/backend.h" #include "../../wrapper/ringbuffer/frontend.h" @@ -131,7 +131,7 @@ int lib_ring_buffer_backend_allocate(const struct lib_ring_buffer_config *config * If kmalloc ever uses vmalloc underneath, make sure the buffer pages * will not fault. */ - vmalloc_sync_all(); + wrapper_vmalloc_sync_all(); kfree(virt); kfree(pages); return 0; diff --git a/ltt-debugfs-abi.c b/ltt-debugfs-abi.c index 2f200ed1..4319ef3f 100644 --- a/ltt-debugfs-abi.c +++ b/ltt-debugfs-abi.c @@ -28,7 +28,7 @@ #include #include #include -#include /* For vmalloc_sync_all */ +#include "wrapper/symbols.h" /* for wrapper_vmalloc_sync_all() */ #include "wrapper/ringbuffer/vfs.h" #include "ltt-debugfs-abi.h" #include "ltt-events.h" @@ -538,7 +538,7 @@ int __init ltt_debugfs_abi_init(void) { int ret = 0; - vmalloc_sync_all(); + wrapper_vmalloc_sync_all(); lttng_dentry = debugfs_create_file("lttng", S_IWUSR, NULL, NULL, <tng_fops); if (IS_ERR(lttng_dentry) || !lttng_dentry) { diff --git a/ltt-events.c b/ltt-events.c index 93638cd8..9eb2c2f2 100644 --- a/ltt-events.c +++ b/ltt-events.c @@ -11,7 +11,7 @@ #include #include #include -#include /* For vmalloc_sync_all */ +#include "wrapper/symbols.h" /* for wrapper_vmalloc_sync_all() */ #include "ltt-events.h" static LIST_HEAD(sessions); @@ -269,7 +269,7 @@ void ltt_transport_register(struct ltt_transport *transport) * registered. We deal with this here so we don't have to call * vmalloc_sync_all() in each module's init. */ - vmalloc_sync_all(); + wrapper_vmalloc_sync_all(); mutex_lock(&sessions_mutex); list_add_tail(&transport->node, <t_transport_list); diff --git a/ltt-ring-buffer-client.h b/ltt-ring-buffer-client.h index e889c571..00cac160 100644 --- a/ltt-ring-buffer-client.h +++ b/ltt-ring-buffer-client.h @@ -10,7 +10,7 @@ #include #include -#include /* for vmalloc_sync_all */ +#include "wrapper/symbols.h" /* for wrapper_vmalloc_sync_all() */ #include "wrapper/trace-clock.h" #include "ltt-events.h" #include "ltt-tracer.h" @@ -203,7 +203,7 @@ static int __init ltt_ring_buffer_client_init(void) * This vmalloc sync all also takes care of the lib ring buffer * vmalloc'd module pages when it is built as a module into LTTng. */ - vmalloc_sync_all(); + wrapper_vmalloc_sync_all(); printk(KERN_INFO "LTT : ltt ring buffer client init\n"); ltt_transport_register(<t_relay_transport); return 0; diff --git a/probes/lttng-events.h b/probes/lttng-events.h index 38c61cd8..f697eadc 100644 --- a/probes/lttng-events.h +++ b/probes/lttng-events.h @@ -1,7 +1,7 @@ #include #include #include -#include /* for vmalloc_sync_all() */ +#include "../wrapper/symbols.h" /* for wrapper_vmalloc_sync_all() */ #include "../wrapper/ringbuffer/frontend_types.h" #include "../ltt-events.h" #include "../ltt-tracer-core.h" @@ -573,7 +573,7 @@ static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void) int ret; int i; - vmalloc_sync_all(); + wrapper_vmalloc_sync_all(); ret = TP_ID(__lttng_types_init__, TRACE_SYSTEM)(); if (ret) return ret; diff --git a/probes/lttng-types.c b/probes/lttng-types.c index a4b40cf7..7f9d20e5 100644 --- a/probes/lttng-types.c +++ b/probes/lttng-types.c @@ -11,7 +11,7 @@ #include #include /* tid_t */ #include -#include /* for vmalloc_sync_all */ +#include "../wrapper/symbols.h" /* for wrapper_vmalloc_sync_all() */ #include "lttng-types.h" struct dentry *lttng_types_dentry; @@ -186,7 +186,7 @@ static int lttng_types_init(void) { int ret = 0; - vmalloc_sync_all(); + wrapper_vmalloc_sync_all(); lttng_types_dentry = debugfs_create_file("lttng-types", S_IWUSR, NULL, NULL, <tng_types_fops); if (IS_ERR(lttng_types_dentry) || !lttng_types_dentry) { diff --git a/wrapper/symbols.h b/wrapper/symbols.h new file mode 100644 index 00000000..523f553b --- /dev/null +++ b/wrapper/symbols.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011 Mathieu Desnoyers (mathieu.desnoyers@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 + +static inline +void wrapper_vmalloc_sync_all(void) +{ + void (*vmalloc_sync_all_sym)(void); + + vmalloc_sync_all_sym = (void *) kallsyms_lookup_name("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 + +static inline +void wrapper_vmalloc_sync_all(void) +{ + return vmalloc_sync_all(); +} +#endif -- 2.34.1