#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/slab.h>
-#include <linux/vmalloc.h> /* For vmalloc_sync_all */
+#include "wrapper/symbols.h" /* for wrapper_vmalloc_sync_all() */
#include "ltt-events.h"
static LIST_HEAD(sessions);
{
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);
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);
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;
}
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",
transport_name);
goto notransport;
}
- printk("got transport\n");
chan = kzalloc(sizeof(struct ltt_channel), GFP_KERNEL);
if (!chan)
goto nomem;
chan->chan = transport->ops.channel_create("[lttng]", session, buf_addr,
subbuf_size, num_subbuf, switch_timer_interval,
read_timer_interval);
- printk("chan create %p\n", chan->chan);
if (!chan->chan)
goto create_error;
chan->ops = &transport->ops;
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))
default:
WARN_ON_ONCE(1);
}
+ list_add(&event->list, &chan->session->events);
mutex_unlock(&sessions_mutex);
return event;
/*
* 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;
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;
}
/**
* 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, <t_transport_list);
event_cache = KMEM_CACHE(ltt_event, 0);
if (!event_cache)
return -ENOMEM;
- ret = ltt_debugfs_abi_init();
+ ret = ltt_probes_init();
if (ret)
goto error;
+ ret = ltt_debugfs_abi_init();
+ if (ret)
+ goto error_abi;
return 0;
+error_abi:
+ ltt_probes_exit();
error:
kmem_cache_destroy(event_cache);
return ret;
struct ltt_session *session, *tmpsession;
ltt_debugfs_abi_exit();
+ ltt_probes_exit();
list_for_each_entry_safe(session, tmpsession, &sessions, list)
ltt_session_destroy(session);
kmem_cache_destroy(event_cache);