Version 2.6.0
[lttng-modules.git] / lttng-events.c
index f47e9dcfcebbf9f62c488eac3b339e0d497c1499..135c8c527123acd43266c7191148d9bc314121a8 100644 (file)
@@ -98,6 +98,8 @@ struct lttng_session *lttng_session_create(void)
        kref_init(&metadata_cache->refcount);
        session->metadata_cache = metadata_cache;
        INIT_LIST_HEAD(&metadata_cache->metadata_stream);
+       memcpy(&metadata_cache->uuid, &session->uuid,
+               sizeof(metadata_cache->uuid));
        list_add(&session->list, &sessions);
        mutex_unlock(&sessions_mutex);
        return session;
@@ -377,8 +379,14 @@ struct lttng_event *lttng_event_create(struct lttng_channel *chan,
         */
        list_for_each_entry(event, &chan->session->events, list) {
                if (!strcmp(event->desc->name, event_param->name)) {
-                       ret = -EEXIST;
-                       goto exist;
+                       /*
+                        * Allow events with the same name to appear in
+                        * different channels.
+                        */
+                       if (event->chan == chan) {
+                               ret = -EEXIST;
+                               goto exist;
+                       }
                }
        }
        event = kmem_cache_zalloc(event_cache, GFP_KERNEL);
@@ -400,7 +408,7 @@ struct lttng_event *lttng_event_create(struct lttng_channel *chan,
                        ret = -ENOENT;
                        goto register_error;
                }
-               ret = kabi_2635_tracepoint_probe_register(event->desc->kname,
+               ret = lttng_wrapper_tracepoint_probe_register(event->desc->kname,
                                event->desc->probe_callback,
                                event);
                if (ret) {
@@ -519,7 +527,7 @@ int _lttng_event_unregister(struct lttng_event *event)
 
        switch (event->instrumentation) {
        case LTTNG_KERNEL_TRACEPOINT:
-               ret = kabi_2635_tracepoint_probe_unregister(event->desc->name,
+               ret = lttng_wrapper_tracepoint_probe_unregister(event->desc->kname,
                                                  event->desc->probe_callback,
                                                  event);
                if (ret)
@@ -597,16 +605,20 @@ int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
 
        /*
         * Ensure we support mutiple get_next / put sequences followed
-        * by put_next.
+        * by put_next. The metadata stream lock internally protects
+        * reading the metadata cache. It can indeed be read
+        * concurrently by "get_next_subbuf" and "flush" operations on
+        * the buffer invoked by different processes.
         */
+       mutex_lock(&stream->lock);
        WARN_ON(stream->metadata_in < stream->metadata_out);
        if (stream->metadata_in != stream->metadata_out)
-               return 0;
+               goto end;
 
        len = stream->metadata_cache->metadata_written -
                stream->metadata_in;
        if (!len)
-               return 0;
+               goto end;
        reserve_len = min_t(size_t,
                        stream->transport->ops.packet_avail_size(chan),
                        len);
@@ -628,6 +640,7 @@ int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
        ret = reserve_len;
 
 end:
+       mutex_unlock(&stream->lock);
        return ret;
 }
 
@@ -1255,15 +1268,32 @@ static int __init lttng_events_init(void)
 {
        int ret;
 
+       ret = wrapper_lttng_fixup_sig(THIS_MODULE);
+       if (ret)
+               return ret;
+
+       ret = lttng_tracepoint_init();
+       if (ret)
+               return ret;
        event_cache = KMEM_CACHE(lttng_event, 0);
-       if (!event_cache)
-               return -ENOMEM;
+       if (!event_cache) {
+               ret = -ENOMEM;
+               goto error_kmem;
+       }
        ret = lttng_abi_init();
        if (ret)
                goto error_abi;
+       ret = lttng_logger_init();
+       if (ret)
+               goto error_logger;
        return 0;
+
+error_logger:
+       lttng_abi_exit();
 error_abi:
        kmem_cache_destroy(event_cache);
+error_kmem:
+       lttng_tracepoint_exit();
        return ret;
 }
 
@@ -1273,10 +1303,12 @@ static void __exit lttng_events_exit(void)
 {
        struct lttng_session *session, *tmpsession;
 
+       lttng_logger_exit();
        lttng_abi_exit();
        list_for_each_entry_safe(session, tmpsession, &sessions, list)
                lttng_session_destroy(session);
        kmem_cache_destroy(event_cache);
+       lttng_tracepoint_exit();
 }
 
 module_exit(lttng_events_exit);
@@ -1286,4 +1318,5 @@ MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
 MODULE_DESCRIPTION("LTTng Events");
 MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
        __stringify(LTTNG_MODULES_MINOR_VERSION) "."
-       __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION));
+       __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
+       LTTNG_MODULES_EXTRAVERSION);
This page took 0.024512 seconds and 4 git commands to generate.