Fix: include loglevel type in UST event's primary key
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 2 Sep 2015 02:53:30 +0000 (22:53 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 8 Sep 2015 13:59:48 +0000 (09:59 -0400)
Refs: #913

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/event.c
src/bin/lttng-sessiond/event.h
src/bin/lttng-sessiond/trace-ust.c
src/bin/lttng-sessiond/trace-ust.h

index cf0b445532d80d1f8fdf6c9546ee5c57d60810ea..1c3166ed3ee17f1d4f3ff567fb1dde2098eb2284 100644 (file)
@@ -49,7 +49,8 @@ static void add_unique_ust_event(struct lttng_ht *ht,
 
        key.name = event->attr.name;
        key.filter = (struct lttng_filter_bytecode *) event->filter;
-       key.loglevel_type = event->attr.loglevel;
+       key.loglevel_type = event->attr.loglevel_type;
+       key.loglevel_value = event->attr.loglevel;
        key.exclusion = event->exclusion;
 
        node_ptr = cds_lfht_add_unique(ht->ht,
@@ -185,103 +186,6 @@ end:
  * ============================
  */
 
-/*
- * Enable all UST tracepoints for a channel from a UST session.
- */
-int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan,
-               char *filter_expression,
-               struct lttng_filter_bytecode *filter)
-{
-       int ret, i, size;
-       struct lttng_ht_iter iter;
-       struct ltt_ust_event *uevent = NULL;
-       struct lttng_event *events = NULL;
-
-       assert(usess);
-       assert(uchan);
-
-       rcu_read_lock();
-
-       /* Enable existing events */
-       cds_lfht_for_each_entry(uchan->events->ht, &iter.iter, uevent,
-                       node.node) {
-               if (uevent->enabled == 0) {
-                       ret = ust_app_enable_event_glb(usess, uchan, uevent);
-                       if (ret < 0) {
-                               continue;
-                       }
-                       uevent->enabled = 1;
-               }
-       }
-
-       /* Get all UST available events */
-       size = ust_app_list_events(&events);
-       if (size < 0) {
-               ret = LTTNG_ERR_UST_LIST_FAIL;
-               goto error;
-       }
-
-       for (i = 0; i < size; i++) {
-               /*
-                * Check if event exist and if so, continue since it was enable
-                * previously.
-                */
-               uevent = trace_ust_find_event(uchan->events, events[i].name, filter,
-                               events[i].loglevel, NULL);
-               if (uevent != NULL) {
-                       ret = ust_app_enable_event_pid(usess, uchan, uevent,
-                                       events[i].pid);
-                       if (ret < 0) {
-                               if (ret != -LTTNG_UST_ERR_EXIST) {
-                                       ret = LTTNG_ERR_UST_ENABLE_FAIL;
-                                       goto error;
-                               }
-                       }
-                       continue;
-               }
-
-               /* Create ust event */
-               uevent = trace_ust_create_event(&events[i], filter_expression,
-                               filter, NULL, false);
-               if (uevent == NULL) {
-                       ret = LTTNG_ERR_FATAL;
-                       goto error_destroy;
-               }
-
-               /* Create event for the specific PID */
-               ret = ust_app_enable_event_pid(usess, uchan, uevent,
-                               events[i].pid);
-               if (ret < 0) {
-                       if (ret == -LTTNG_UST_ERR_EXIST) {
-                               ret = LTTNG_ERR_UST_EVENT_EXIST;
-                               goto error;
-                       } else {
-                               ret = LTTNG_ERR_UST_ENABLE_FAIL;
-                               goto error_destroy;
-                       }
-               }
-
-               uevent->enabled = 1;
-               /* Add ltt ust event to channel */
-               rcu_read_lock();
-               add_unique_ust_event(uchan->events, uevent);
-               rcu_read_unlock();
-       }
-       free(events);
-
-       rcu_read_unlock();
-       return LTTNG_OK;
-
-error_destroy:
-       trace_ust_destroy_event(uevent);
-
-error:
-       free(events);
-       rcu_read_unlock();
-       return ret;
-}
-
 /*
  * Enable UST tracepoint event for a channel from a UST session.
  * We own filter_expression, filter, and exclusion.
@@ -303,8 +207,8 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess,
        rcu_read_lock();
 
        uevent = trace_ust_find_event(uchan->events, event->name, filter,
-                       event->loglevel, exclusion);
-       if (uevent == NULL) {
+                       event->loglevel_type, event->loglevel, exclusion);
+       if (!uevent) {
                uevent = trace_ust_create_event(event, filter_expression,
                                filter, exclusion, internal_event);
                /* We have passed ownership */
@@ -448,60 +352,6 @@ error:
        return ret;
 }
 
-/*
- * Disable all UST tracepoints for a channel from a UST session.
- */
-int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan)
-{
-       int ret, i, size;
-       struct lttng_ht_iter iter;
-       struct ltt_ust_event *uevent = NULL;
-       struct lttng_event *events = NULL;
-
-       assert(usess);
-       assert(uchan);
-
-       rcu_read_lock();
-
-       /* Disabling existing events */
-       cds_lfht_for_each_entry(uchan->events->ht, &iter.iter, uevent,
-                       node.node) {
-               if (uevent->enabled == 1) {
-                       ret = event_ust_disable_tracepoint(usess, uchan,
-                                       uevent->attr.name);
-                       if (ret < 0) {
-                               continue;
-                       }
-               }
-       }
-
-       /* Get all UST available events */
-       size = ust_app_list_events(&events);
-       if (size < 0) {
-               ret = LTTNG_ERR_UST_LIST_FAIL;
-               goto error;
-       }
-
-       for (i = 0; i < size; i++) {
-               ret = event_ust_disable_tracepoint(usess, uchan,
-                               events[i].name);
-               if (ret != LTTNG_OK) {
-                       /* Continue to disable the rest... */
-                       continue;
-               }
-       }
-       free(events);
-
-       rcu_read_unlock();
-       return LTTNG_OK;
-
-error:
-       free(events);
-       rcu_read_unlock();
-       return ret;
-}
-
 /*
  * Enable all agent event for a given UST session.
  *
@@ -691,12 +541,13 @@ int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt,
        }
 
        /*
-        * The loglevel is hardcoded with 0 here since the agent ust event is set
-        * with the loglevel type to ALL thus the loglevel stays 0. The event's
-        * filter is the one handling the loglevel for agent.
+        * Agent UST event has its loglevel type forced to
+        * LTTNG_UST_LOGLEVEL_ALL. The actual loglevel type/value filtering
+        * happens thanks to an UST filter. The following -1 is actually
+        * ignored since the type is LTTNG_UST_LOGLEVEL_ALL.
         */
        uevent = trace_ust_find_event(uchan->events, (char *) ust_event_name,
-                       aevent->filter, 0, NULL);
+                       aevent->filter, LTTNG_UST_LOGLEVEL_ALL, -1, NULL);
        /* If the agent event exists, it must be available on the UST side. */
        assert(uevent);
 
index fd47c7764d25a1fec89a1481eb650c8c13a4a10d..4e7de911cd812f2d96841e7934735ee3ca1b4cea 100644 (file)
@@ -40,13 +40,6 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess,
 int event_ust_disable_tracepoint(struct ltt_ust_session *usess,
                struct ltt_ust_channel *uchan, char *event_name);
 
-int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan,
-               char *filter_expression,
-               struct lttng_filter_bytecode *filter);
-int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess,
-               struct ltt_ust_channel *uchan);
-
 int event_agent_enable(struct ltt_ust_session *usess, struct agent *agt,
                struct lttng_event *event, struct lttng_filter_bytecode *filter,
                char *filter_expression);
index 8da942f01c8d9a7bc835804adf57f542edd7b062..1bc3c77806ae563e5fb972475ed11d49d5e4035d 100644 (file)
@@ -86,19 +86,21 @@ int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key)
                goto no_match;
        }
 
-       /* Event loglevel. */
-       if (ev_loglevel_value != key->loglevel_type) {
-               if (event->attr.loglevel_type == LTTNG_UST_LOGLEVEL_ALL
-                               && key->loglevel_type == 0 && ev_loglevel_value == -1) {
+       /* Event loglevel value and type. */
+       if (event->attr.loglevel_type == key->loglevel_type) {
+               /* Same loglevel type. */
+               if (key->loglevel_type != LTTNG_UST_LOGLEVEL_ALL) {
                        /*
-                        * Match is accepted. This is because on event creation, the
-                        * loglevel is set to -1 if the event loglevel type is ALL so 0 and
-                        * -1 are accepted for this loglevel type since 0 is the one set by
-                        * the API when receiving an enable event.
+                        * Loglevel value must also match since the loglevel
+                        * type is not all.
                         */
-               } else {
-                       goto no_match;
+                       if (ev_loglevel_value != key->loglevel_value) {
+                               goto no_match;
+                       }
                }
+       } else {
+               /* Loglevel type is different: no match. */
+               goto no_match;
        }
 
        /* Only one of the filters is NULL, fail. */
@@ -173,7 +175,8 @@ error:
  */
 struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
                char *name, struct lttng_filter_bytecode *filter,
-               int loglevel_value, struct lttng_event_exclusion *exclusion)
+               enum lttng_ust_loglevel_type loglevel_type, int loglevel_value,
+               struct lttng_event_exclusion *exclusion)
 {
        struct lttng_ht_node_str *node;
        struct lttng_ht_iter iter;
@@ -184,7 +187,8 @@ struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
 
        key.name = name;
        key.filter = filter;
-       key.loglevel_type = loglevel_value;
+       key.loglevel_type = loglevel_type;
+       key.loglevel_value = loglevel_value;
        key.exclusion = exclusion;
 
        cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed),
index d7f732e158c6543e627752182a4eac76127fe9ee..e96f8550b5e51f5ae498f3d84a225773984f2f9d 100644 (file)
@@ -34,6 +34,7 @@ struct ltt_ust_ht_key {
        const char *name;
        const struct lttng_filter_bytecode *filter;
        enum lttng_ust_loglevel_type loglevel_type;
+       int loglevel_value;
        const struct lttng_event_exclusion *exclusion;
 };
 
@@ -170,7 +171,8 @@ int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node,
  */
 struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
                char *name, struct lttng_filter_bytecode *filter,
-               int loglevel_value, struct lttng_event_exclusion *exclusion);
+               enum lttng_ust_loglevel_type loglevel_type, int loglevel_value,
+               struct lttng_event_exclusion *exclusion);
 struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
                char *name);
 struct agent *trace_ust_find_agent(struct ltt_ust_session *session,
@@ -275,9 +277,11 @@ int trace_ust_match_context(struct ltt_ust_context *uctx,
 {
        return 0;
 }
-static inline struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
+static inline
+struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
                char *name, struct lttng_filter_bytecode *filter,
-               int loglevel_value, struct lttng_event_exclusion *exclusion)
+               enum lttng_ust_loglevel_type loglevel_type, int loglevel_value,
+               struct lttng_event_exclusion *exclusion)
 {
        return NULL;
 }
This page took 0.043466 seconds and 4 git commands to generate.