Rename symbols.h to vmalloc.h
[lttng-modules.git] / ltt-events.c
index 0e34f6f8b0585bdc3f192467a4e5f75096f33d66..512e7a24676214e09063a35566cef322eca8644a 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/mutex.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
-#include <linux/vmalloc.h>     /* For vmalloc_sync_all */
+#include "wrapper/vmalloc.h"   /* for wrapper_vmalloc_sync_all() */
 #include "ltt-events.h"
 
 static LIST_HEAD(sessions);
@@ -46,9 +46,14 @@ void ltt_session_destroy(struct ltt_session *session)
 {
        struct ltt_channel *chan, *tmpchan;
        struct ltt_event *event, *tmpevent;
+       int ret;
 
        mutex_lock(&sessions_mutex);
-       session->active = 0;
+       ACCESS_ONCE(session->active) = 0;
+       list_for_each_entry(event, &session->events, list) {
+               ret = _ltt_event_unregister(event);
+               WARN_ON(ret);
+       }
        synchronize_trace();    /* Wait for in-flight events to complete */
        list_for_each_entry_safe(event, tmpevent, &session->events, list)
                _ltt_event_destroy(event);
@@ -68,7 +73,7 @@ int ltt_session_start(struct ltt_session *session)
                ret = -EBUSY;
                goto end;
        }
-       session->active = 1;
+       ACCESS_ONCE(session->active) = 1;
        synchronize_trace();    /* Wait for in-flight events to complete */
 end:
        mutex_unlock(&sessions_mutex);
@@ -84,14 +89,14 @@ int ltt_session_stop(struct ltt_session *session)
                ret = -EBUSY;
                goto end;
        }
-       session->active = 0;
+       ACCESS_ONCE(session->active) = 0;
        synchronize_trace();    /* Wait for in-flight events to complete */
 end:
        mutex_unlock(&sessions_mutex);
        return ret;
 }
 
-static struct ltt_transport *ltt_transport_find(char *name)
+static struct ltt_transport *ltt_transport_find(const char *name)
 {
        struct ltt_transport *transport;
 
@@ -103,21 +108,20 @@ static struct ltt_transport *ltt_transport_find(char *name)
 }
 
 struct ltt_channel *ltt_channel_create(struct ltt_session *session,
-                                      int overwrite, void *buf_addr,
+                                      const char *transport_name,
+                                      void *buf_addr,
                                       size_t subbuf_size, size_t num_subbuf,
                                       unsigned int switch_timer_interval,
                                       unsigned int read_timer_interval)
 {
        struct ltt_channel *chan;
        struct ltt_transport *transport;
-       char *transport_name;
 
        mutex_lock(&sessions_mutex);
        if (session->active) {
                printk(KERN_WARNING "LTTng refusing to add channel to active session\n");
                goto active;    /* Refuse to add channel to active session */
        }
-       transport_name = overwrite ? "relay-overwrite" : "relay-discard";
        transport = ltt_transport_find(transport_name);
        if (!transport) {
                printk(KERN_WARNING "LTTng transport %s not found\n",
@@ -172,8 +176,8 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
        if (chan->free_event_id == -1UL)
                goto full;
        /*
-        * This is O(n^2) (for each event loop called at event creation).
-        * Might require a hash if we have lots of events.
+        * This is O(n^2) (for each event, the loop is called at event
+        * creation). Might require a hash if we have lots of events.
         */
        list_for_each_entry(event, &chan->session->events, list)
                if (!strcmp(event->name, name))
@@ -201,6 +205,7 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
        default:
                WARN_ON_ONCE(1);
        }
+       list_add(&event->list, &chan->session->events);
        mutex_unlock(&sessions_mutex);
        return event;
 
@@ -218,7 +223,7 @@ full:
 /*
  * Only used internally at session destruction.
  */
-int _ltt_event_destroy(struct ltt_event *event)
+int _ltt_event_unregister(struct ltt_event *event)
 {
        int ret = -EINVAL;
 
@@ -232,9 +237,17 @@ int _ltt_event_destroy(struct ltt_event *event)
        default:
                WARN_ON_ONCE(1);
        }
+       return ret;
+}
+
+/*
+ * Only used internally at session destruction.
+ */
+void _ltt_event_destroy(struct ltt_event *event)
+{
        kfree(event->name);
+       list_del(&event->list);
        kmem_cache_free(event_cache, event);
-       return ret;
 }
 
 /**
@@ -256,7 +269,7 @@ void ltt_transport_register(struct ltt_transport *transport)
         * registered. We deal with this here so we don't have to call
         * vmalloc_sync_all() in each module's init.
         */
-       vmalloc_sync_all();
+       wrapper_vmalloc_sync_all();
 
        mutex_lock(&sessions_mutex);
        list_add_tail(&transport->node, &ltt_transport_list);
This page took 0.026072 seconds and 4 git commands to generate.