/*
* The sessions mutex is the centralized mutex across UST tracing
- * control and probe registration.
+ * control and probe registration. All operations within this file are
+ * called by the communication thread, under ust_lock protection.
*/
static DEFINE_MUTEX(sessions_mutex);
-void lock_ust(void)
+void ust_lock(void)
{
pthread_mutex_lock(&sessions_mutex);
}
-void unlock_ust(void)
+void ust_unlock(void)
{
pthread_mutex_unlock(&sessions_mutex);
}
session = zmalloc(sizeof(struct ltt_session));
if (!session)
return NULL;
- pthread_mutex_lock(&sessions_mutex);
CDS_INIT_LIST_HEAD(&session->chan);
CDS_INIT_LIST_HEAD(&session->events);
uuid_generate(session->uuid);
cds_list_add(&session->list, &sessions);
- pthread_mutex_unlock(&sessions_mutex);
return session;
}
struct ltt_event *event, *tmpevent;
int ret;
- pthread_mutex_lock(&sessions_mutex);
CMM_ACCESS_ONCE(session->active) = 0;
cds_list_for_each_entry(event, &session->events, list) {
ret = _ltt_event_unregister(event);
cds_list_for_each_entry_safe(chan, tmpchan, &session->chan, list)
_ltt_channel_destroy(chan);
cds_list_del(&session->list);
- pthread_mutex_unlock(&sessions_mutex);
free(session);
}
int ret = 0;
struct ltt_channel *chan;
- pthread_mutex_lock(&sessions_mutex);
if (session->active) {
ret = -EBUSY;
goto end;
if (ret)
CMM_ACCESS_ONCE(session->active) = 0;
end:
- pthread_mutex_unlock(&sessions_mutex);
return ret;
}
{
int ret = 0;
- pthread_mutex_lock(&sessions_mutex);
if (!session->active) {
ret = -EBUSY;
goto end;
}
CMM_ACCESS_ONCE(session->active) = 0;
end:
- pthread_mutex_unlock(&sessions_mutex);
return ret;
}
struct ltt_channel *chan;
struct ltt_transport *transport;
- pthread_mutex_lock(&sessions_mutex);
if (session->been_active)
goto active; /* Refuse to add channel to active session */
transport = ltt_transport_find(transport_name);
chan->enabled = 1;
chan->ops = &transport->ops;
cds_list_add(&chan->list, &session->chan);
- pthread_mutex_unlock(&sessions_mutex);
return chan;
create_error:
nomem:
notransport:
active:
- pthread_mutex_unlock(&sessions_mutex);
return NULL;
}
struct ltt_event *event;
int ret;
- pthread_mutex_lock(&sessions_mutex);
if (chan->used_event_id == -1UL)
goto full;
/*
goto statedump_error;
}
cds_list_add(&event->list, &chan->session->events);
- pthread_mutex_unlock(&sessions_mutex);
return event;
statedump_error:
cache_error:
exist:
full:
- pthread_mutex_unlock(&sessions_mutex);
return NULL;
}
/*
* We have exclusive access to our metadata buffer (protected by the
- * sessions_mutex), so we can do racy operations such as looking for
+ * ust_lock), so we can do racy operations such as looking for
* remaining space left in packet and write, since mutual exclusion
* protects us from concurrent writes.
*/
* @transport: transport structure
*
* Registers a transport which can be used as output to extract the data out of
- * LTTng.
+ * LTTng. Called with ust_lock held.
*/
void ltt_transport_register(struct ltt_transport *transport)
{
- pthread_mutex_lock(&sessions_mutex);
cds_list_add_tail(&transport->node, <t_transport_list);
- pthread_mutex_unlock(&sessions_mutex);
}
/**
* ltt_transport_unregister - LTT transport unregistration
* @transport: transport structure
+ * Called with ust_lock held.
*/
void ltt_transport_unregister(struct ltt_transport *transport)
{
- pthread_mutex_lock(&sessions_mutex);
cds_list_del(&transport->node);
- pthread_mutex_unlock(&sessions_mutex);
}
void ltt_events_exit(void)