update ltt-events
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 23 Nov 2010 22:59:20 +0000 (17:59 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 23 Nov 2010 22:59:20 +0000 (17:59 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ltt-events.c
ltt-events.h

index a85b7932e38e42ffda5fba7fa501aa55b0282381..688d7f3bb491811e131cf846e14d251706f80dfa 100644 (file)
@@ -59,6 +59,8 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session, char *name,
        struct ltt_channel *chan;
 
        mutex_lock(&sessions_mutex);
+       if (session->active)
+               goto active;    /* Refuse to add channel to active session */
        list_for_each_entry(chan, &session->chan, list)
                if (!strcmp(chan->name, name))
                        goto exist;
@@ -74,6 +76,7 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session, char *name,
        return chan;
 
 exist:
+active:
        mutex_unlock(&sessions_mutex);
        return NULL;
 }
@@ -87,12 +90,17 @@ int _ltt_channel_destroy(struct ltt_channel *chan)
        kfree(chan);
 }
 
+/*
+ * Supports event creation while tracing session is active.
+ */
 struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
                                   void *filter)
 {
        struct ltt_event *event;
 
        mutex_lock(&sessions_mutex);
+       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.
@@ -109,15 +117,18 @@ struct ltt_event *ltt_event_create(struct ltt_channel *chan, char *name,
        strcpy(event->name, name);
        event->chan = chan;
        event->filter = filter;
-       event->id = atomic_inc_return(&chan->free_event_id) - 1;
-       /* TODO register to tracepoint */
+       event->id = chan->free_event_id++;
        mutex_unlock(&sessions_mutex);
+       /* Populate ltt_event structure before tracepoint registration. */
+       smp_wmb();
+       /* TODO register to tracepoint */
        return event;
 
 error:
        kmem_cache_free(event);
 cache_error:
 exist:
+full:
        mutex_unlock(&sessions_mutex);
        return NULL;
 }
index d205cdb079ecfc88858b2b45270f0f5b118bb013..99edb4b12801bd3d1301f3eb7743ced4ad7a4012 100644 (file)
@@ -27,12 +27,13 @@ struct ltt_channel {
        struct channel *chan;           /* Channel buffers */
        /* Event ID management */
        struct ltt_session *session;
-       atomic_t free_event_id;         /* Next event ID to allocate */
+       unsigned int free_event_id;     /* Next event ID to allocate */
        struct list_head list;          /* Channel list */
        char name[PATH_MAX];
 };
 
 struct ltt_session {
+       int active;                     /* Is trace session active ? */
        struct list_head chan;          /* Channel list head */
        struct list_head events;        /* Event list head */
        struct list_head list;          /* Session list */
This page took 0.02742 seconds and 4 git commands to generate.