Handle refcount of modules having dynamically alloc event description
[lttng-modules.git] / probes / lttng-ftrace.c
index 7c4fc9f55d78f5fc98898cd45af8a630b37e90ae..c866876e6f07dcf5b4d7612d27d4d9e6de08f223 100644 (file)
@@ -92,6 +92,7 @@ int lttng_create_ftrace_event(const char *name, struct ltt_event *event)
        fields[1].type.u.basic.integer.base = 16;
        fields[1].type.u.basic.integer.encoding = lttng_encode_none;
 
+       desc->owner = THIS_MODULE;
        event->desc = desc;
 
        return 0;
@@ -118,7 +119,7 @@ int lttng_ftrace_register(const char *name,
        if (ret)
                goto error;
 
-       event->u.ftrace.symbol_name = kstrdup(name, GFP_KERNEL);
+       event->u.ftrace.symbol_name = kstrdup(symbol_name, GFP_KERNEL);
        if (!event->u.ftrace.symbol_name)
                goto name_error;
 
@@ -127,7 +128,7 @@ int lttng_ftrace_register(const char *name,
 
        ret = wrapper_register_ftrace_function_probe(event->u.ftrace.symbol_name,
                        &lttng_ftrace_ops, event);
-       if (ret)
+       if (ret < 0)
                goto register_error;
        return 0;
 
@@ -152,7 +153,6 @@ 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();
@@ -160,6 +160,15 @@ int lttng_ftrace_init(void)
 }
 module_init(lttng_ftrace_init)
 
+/*
+ * Ftrace takes care of waiting for a grace period (RCU sched) at probe
+ * unregistration, and disables preemption around probe call.
+ */
+void lttng_ftrace_exit(void)
+{
+}
+module_exit(lttng_ftrace_exit)
+
 MODULE_LICENSE("GPL and additional rights");
 MODULE_AUTHOR("Mathieu Desnoyers");
 MODULE_DESCRIPTION("Linux Trace Toolkit Ftrace Support");
This page took 0.023307 seconds and 4 git commands to generate.