Handle refcount of modules having dynamically alloc event description
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 24 May 2011 15:37:06 +0000 (11:37 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 24 May 2011 15:37:06 +0000 (11:37 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ltt-events.h
ltt-probes.c
probes/lttng-events.h
probes/lttng-ftrace.c
probes/lttng-kprobes.c

index 6cc3753101fb1606de8f1c11fe1f81c504c7553b..9baf660ded332a2570b32a34114bf322d4453e5e 100644 (file)
@@ -139,6 +139,7 @@ struct lttng_event_desc {
        const struct lttng_event_ctx *ctx;      /* context */
        const struct lttng_event_field *fields; /* event payload */
        unsigned int nr_fields;
+       struct module *owner;
 };
 
 struct lttng_probe_desc {
index ad7f7c2b5a539ce46516b81270f5315b3823a593..0efc23c5c61b749c996783f604c26a537d822416 100644 (file)
@@ -30,11 +30,6 @@ const struct lttng_event_desc *find_event(const char *name)
        return NULL;
 }
 
-/*
- * TODO: registration of probe descriptions in dynamically allocated memory (not
- * directly in a module memory) will require some care for refcounting: it's
- * currently done by just refcounting the module in event_get/put.
- */
 int ltt_probe_register(struct lttng_probe_desc *desc)
 {
        int ret = 0;
@@ -76,7 +71,7 @@ const struct lttng_event_desc *ltt_event_get(const char *name)
        mutex_unlock(&probe_mutex);
        if (!event)
                return NULL;
-       ret = try_module_get(__module_text_address((unsigned long) event));
+       ret = try_module_get(event->owner);
        WARN_ON_ONCE(!ret);
        return event;
 }
@@ -84,6 +79,6 @@ EXPORT_SYMBOL_GPL(ltt_event_get);
 
 void ltt_event_put(const struct lttng_event_desc *event)
 {
-       module_put(__module_text_address((unsigned long) event));
+       module_put(event->owner);
 }
 EXPORT_SYMBOL_GPL(ltt_event_put);
index 9aaf1573b2576742faa6d79d1e197e1dcfa430fa..beedb22b6bb4bce475dfb0ee03bd9f9ec389534f 100644 (file)
@@ -195,6 +195,7 @@ static void __event_probe__##_name(void *__data, _proto);
                        .name = #_name,                                        \
                        .probe_callback = (void *) &__event_probe__##_template,\
                        .nr_fields = ARRAY_SIZE(__event_fields___##_template), \
+                       .owner = THIS_MODULE,                                  \
                },
 
 #define TP_ID1(_token, _system)        _token##_system
index 5b4cf2e7e153c0318e2ca8d485489bd46340e7aa..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;
index 65c1d3ba80ecf30eedbe8ccf1402c81ab4864998..650144cbe0cdc4793c91bf46825f74a5f9ae042b 100644 (file)
@@ -71,6 +71,7 @@ int lttng_create_kprobe_event(const char *name, struct ltt_event *event)
        field->type.u.basic.integer.reverse_byte_order = 0;
        field->type.u.basic.integer.base = 16;
        field->type.u.basic.integer.encoding = lttng_encode_none;
+       desc->owner = THIS_MODULE;
        event->desc = desc;
 
        return 0;
This page took 0.030241 seconds and 4 git commands to generate.