Add vmalloc sync all calls in ftrace and kprobes modules
[lttng-modules.git] / probes / lttng-ftrace.c
index 3ec000ae576e8b5adde12b6bb27fc4b408f033fc..27f4e2bef81117b6bb1e0dc257b838f1c97162c0 100644 (file)
@@ -7,12 +7,19 @@
  * Dual LGPL v2.1/GPL v2 license.
  */
 
+/*
+ * Ftrace function tracer does not seem to provide synchronization between probe
+ * teardown and callback execution. Therefore, we make this module permanently
+ * loaded (unloadable).
+ */
+
 #include <linux/module.h>
 #include <linux/ftrace.h>
 #include <linux/slab.h>
 #include "../ltt-events.h"
 #include "../wrapper/ringbuffer/frontend_types.h"
 #include "../wrapper/ftrace.h"
+#include "../wrapper/vmalloc.h"
 #include "../ltt-tracer.h"
 
 static
@@ -109,6 +116,9 @@ int lttng_ftrace_register(const char *name,
        if (!event->u.ftrace.symbol_name)
                goto name_error;
 
+       /* Ensure the memory we just allocated don't trigger page faults */
+       wrapper_vmalloc_sync_all();
+
        ret = wrapper_register_ftrace_function_probe(event->u.ftrace.symbol_name,
                        &lttng_ftrace_ops, event);
        if (ret)
@@ -135,6 +145,14 @@ void lttng_ftrace_unregister(struct ltt_event *event)
 }
 EXPORT_SYMBOL_GPL(lttng_ftrace_unregister);
 
+/* This module is permanent. */
+int lttng_ftrace_init(void)
+{
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+module_init(lttng_ftrace_init)
+
 MODULE_LICENSE("GPL and additional rights");
 MODULE_AUTHOR("Mathieu Desnoyers");
 MODULE_DESCRIPTION("Linux Trace Toolkit Ftrace Support");
This page took 0.023668 seconds and 4 git commands to generate.