X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt-events.c;h=947d772cf37bec3c1a6b1d2557e2aeb2f19dd904;hb=681cc3bb4f00fd63ad65920ea6e201fcaed300c0;hp=603170682a822dea830830cf0ec155e5651b124b;hpb=f3d01b96c9189afbeb273ad7382eb89ee70a0e61;p=lttng-modules.git diff --git a/ltt-events.c b/ltt-events.c index 60317068..947d772c 100644 --- a/ltt-events.c +++ b/ltt-events.c @@ -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,7 +89,7 @@ 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); @@ -124,7 +129,6 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session, transport_name); goto notransport; } - printk("got transport\n"); chan = kzalloc(sizeof(struct ltt_channel), GFP_KERNEL); if (!chan) goto nomem; @@ -133,7 +137,6 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session, 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; @@ -174,8 +177,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)) @@ -203,6 +206,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; @@ -220,7 +224,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; @@ -234,9 +238,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; } /** @@ -286,10 +298,15 @@ static int __init ltt_events_init(void) 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; @@ -302,6 +319,7 @@ static void __exit ltt_events_exit(void) 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);