kprobes support: fix handling of event description
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 19 May 2011 02:55:16 +0000 (22:55 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 19 May 2011 02:55:16 +0000 (22:55 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ltt-debugfs-abi.c
ltt-events.c
ltt-events.h
probes/lttng-kprobes.c

index d013fa5a86a4e1fd33507ceff92dab0c509386de..9139e5a1751f8ba56ea48c2676d6480d8c08a779 100644 (file)
@@ -143,21 +143,15 @@ void lttng_metadata_create_events(struct file *channel_file)
 {
        struct ltt_channel *channel = channel_file->private_data;
        char *event_name = "lttng_metadata";
-       const struct lttng_event_desc *event_desc;
        struct ltt_event *event;
        int ret;
 
-       event_desc = ltt_event_get(event_name);
-       if (!event_desc) {
-               ret = -ENOENT;
-               goto get_error;
-       }
        /*
         * We tolerate no failure path after event creation. It will stay
         * invariant for the rest of the session.
         */
        event = ltt_event_create(channel, event_name, LTTNG_KERNEL_TRACEPOINTS,
-                                event_desc, NULL);
+                                NULL);
        if (!event) {
                goto create_error;
                ret = -EEXIST;
@@ -165,8 +159,6 @@ void lttng_metadata_create_events(struct file *channel_file)
        return;
 
 create_error:
-       ltt_event_put(event_desc);
-get_error:
        WARN_ON(1);
        return;         /* not allowed to return error */
 }
@@ -359,7 +351,6 @@ int lttng_abi_create_event(struct file *channel_file,
                           struct lttng_kernel_event __user *uevent_param)
 {
        struct ltt_channel *channel = channel_file->private_data;
-       const struct lttng_event_desc *event_desc;
        struct ltt_event *event;
        char *event_name;
        struct lttng_kernel_event event_param;
@@ -376,12 +367,8 @@ int lttng_abi_create_event(struct file *channel_file,
                goto name_error;
        }
        event_name[PATH_MAX - 1] = '\0';
+       event_param.u.kprobe.symbol_name[LTTNG_KPROBE_SYM_NAME_LEN - 1] = '\0';
 
-       event_desc = ltt_event_get(event_name);
-       if (!event_desc) {
-               ret = -ENOENT;
-               goto get_error;
-       }
        event_fd = get_unused_fd();
        if (event_fd < 0) {
                ret = event_fd;
@@ -398,8 +385,7 @@ int lttng_abi_create_event(struct file *channel_file,
         * We tolerate no failure path after event creation. It will stay
         * invariant for the rest of the session.
         */
-       event = ltt_event_create(channel, event_name, &event_param,
-                                event_desc, NULL);
+       event = ltt_event_create(channel, event_name, &event_param, NULL);
        if (!event) {
                ret = -EEXIST;
                goto event_error;
@@ -416,8 +402,6 @@ event_error:
 file_error:
        put_unused_fd(event_fd);
 fd_error:
-       ltt_event_put(event_desc);
-get_error:
 name_error:
        kfree(event_name);
        return ret;
index 29d0ed749b78db62258e22506231452c0397bf19..cf4fc8b77158fb0f0c398d49249dacce16511ad4 100644 (file)
@@ -203,7 +203,6 @@ void _ltt_channel_destroy(struct ltt_channel *chan)
  */
 struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
                                   struct lttng_kernel_event *event_param,
-                                  const struct lttng_event_desc *event_desc,
                                   void *filter)
 {
        struct ltt_event *event;
@@ -223,7 +222,6 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
        if (!event)
                goto cache_error;
        event->chan = chan;
-       event->desc = event_desc;
        event->filter = filter;
        event->id = chan->free_event_id++;
        event->instrumentation = event_param->instrumentation;
@@ -231,8 +229,12 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
        smp_wmb();
        switch (event_param->instrumentation) {
        case LTTNG_KERNEL_TRACEPOINTS:
-               ret = tracepoint_probe_register(name, event_desc->probe_callback,
-                                               event);
+               event->desc = ltt_event_get(name);
+               if (!event->desc)
+                       goto register_error;
+               ret = tracepoint_probe_register(name,
+                               event->desc->probe_callback,
+                               event);
                if (ret)
                        goto register_error;
                break;
@@ -256,8 +258,10 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
        return event;
 
 statedump_error:
-       WARN_ON_ONCE(tracepoint_probe_unregister(name, event_desc->probe_callback,
-                                                event));
+       WARN_ON_ONCE(tracepoint_probe_unregister(name,
+                               event->desc->probe_callback,
+                               event));
+       ltt_event_put(event->desc);
 register_error:
        kmem_cache_free(event_cache, event);
 cache_error:
@@ -281,6 +285,7 @@ int _ltt_event_unregister(struct ltt_event *event)
                                                  event);
                if (ret)
                        return ret;
+               ltt_event_put(event->desc);
                break;
        case LTTNG_KERNEL_KPROBES:
                lttng_kprobes_unregister(event);
index a26638c43f8e2a5fe6dc12520487d39e569c382b..030ffe02356189b792ebb7b41850eeb115043e54 100644 (file)
@@ -127,7 +127,7 @@ struct lttng_probe_desc {
 struct ltt_event {
        unsigned int id;
        struct ltt_channel *chan;
-       struct lttng_event_desc *desc;
+       const struct lttng_event_desc *desc;
        void *filter;
        enum lttng_kernel_instrumentation instrumentation;
        union {
@@ -217,7 +217,6 @@ void _ltt_channel_destroy(struct ltt_channel *chan);
 struct ltt_event *ltt_event_create(struct ltt_channel *chan,
                                   char *name,
                                   struct lttng_kernel_event *event_param,
-                                  const struct lttng_event_desc *event_desc,
                                   void *filter);
 int ltt_event_unregister(struct ltt_event *event);
 
index bee935f779bfe699ecd1e97e299c41c8e32155a6..1cffe685bd834f7738020e4f36a4c13e7127245c 100644 (file)
@@ -44,18 +44,19 @@ static
 int lttng_create_kprobe_event(const char *name, struct ltt_event *event)
 {
        struct lttng_event_field *field;
+       struct lttng_event_desc *desc;
        int ret;
 
-       event->desc = kzalloc(sizeof(*event->desc), GFP_KERNEL);
-       if (!event->desc)
+       desc = kzalloc(sizeof(*event->desc), GFP_KERNEL);
+       if (!desc)
                return -ENOMEM;
-       event->desc->name = kstrdup(name, GFP_KERNEL);
-       if (!event->desc->name) {
+       desc->name = kstrdup(name, GFP_KERNEL);
+       if (!desc->name) {
                ret = -ENOMEM;
                goto error_str;
        }
-       event->desc->nr_fields = 1;
-       event->desc->fields = field =
+       desc->nr_fields = 1;
+       desc->fields = field =
                kzalloc(1 * sizeof(struct lttng_event_field), GFP_KERNEL);
        field->name = "ip";
        field->type.atype = atype_integer;
@@ -63,11 +64,12 @@ int lttng_create_kprobe_event(const char *name, struct ltt_event *event)
        field->type.u.basic.integer.alignment = ltt_alignof(unsigned long);
        field->type.u.basic.integer.signedness = 0;
        field->type.u.basic.integer.reverse_byte_order = 0;
+       event->desc = desc;
 
        return 0;
 
 error_str:
-       kfree(event->desc);
+       kfree(desc);
        return ret;
 }
 
This page took 0.030648 seconds and 4 git commands to generate.