Markers: remove channel name from trace_mark()
[ust.git] / libust / marker.c
index 8ca028c3e0f38f36cbadf18fabcb413452a6011c..4b23e53d51363357e06f79fee32b5840aa77dd08 100644 (file)
@@ -27,7 +27,7 @@
 #include <ust/marker.h>
 #include <ust/tracepoint.h>
 
-#include "usterr.h"
+#include "usterr_signal_safe.h"
 #include "channels.h"
 #include "tracercore.h"
 #include "tracer.h"
@@ -447,7 +447,7 @@ static struct marker_entry *add_marker(const char *channel, const char *name,
                        e->call = marker_probe_cb_noarg;
                else
                        e->call = marker_probe_cb;
-               trace_mark(metadata, core_marker_format,
+               __trace_mark(0, metadata, core_marker_format, NULL,
                           "channel %s name %s format %s",
                           e->channel, e->name, e->format);
        } else {
@@ -514,7 +514,7 @@ static int marker_set_format(struct marker_entry *entry, const char *format)
                return -ENOMEM;
        entry->format_allocated = 1;
 
-       trace_mark(metadata, core_marker_format,
+       __trace_mark(0, metadata, core_marker_format, NULL,
                   "channel %s name %s format %s",
                   entry->channel, entry->name, entry->format);
        return 0;
@@ -685,26 +685,14 @@ void marker_update_probe_range(struct marker * const *begin,
 
        pthread_mutex_lock(&markers_mutex);
        for (iter = begin; iter < end; iter++) {
+               if (!*iter)
+                       continue;       /* skip dummy */
                mark_entry = get_marker((*iter)->channel, (*iter)->name);
                if (mark_entry) {
                        set_marker(mark_entry, *iter, !!mark_entry->refcount);
                        /*
                         * ignore error, continue
                         */
-
-                       /* This is added for UST. We emit a core_marker_id event
-                        * for markers that are already registered to a probe
-                        * upon library load. Otherwise, no core_marker_id will
-                        * be generated for these markers. Is this the right thing
-                        * to do?
-                        */
-                       trace_mark(metadata, core_marker_id,
-                                  "channel %s name %s event_id %hu "
-                                  "int #1u%zu long #1u%zu pointer #1u%zu "
-                                  "size_t #1u%zu alignment #1u%u",
-                                  (*iter)->channel, (*iter)->name, mark_entry->event_id,
-                                  sizeof(int), sizeof(long), sizeof(void *),
-                                  sizeof(size_t), ltt_get_alignment());
                } else {
                        disable_marker(*iter);
                }
@@ -793,7 +781,7 @@ int marker_probe_register(const char *channel, const char *name,
                        goto error_unregister_channel;
                entry->event_id = ret;
                ret = 0;
-               trace_mark(metadata, core_marker_id,
+               __trace_mark(0, metadata, core_marker_id, NULL,
                           "channel %s name %s event_id %hu "
                           "int #1u%zu long #1u%zu pointer #1u%zu "
                           "size_t #1u%zu alignment #1u%u",
@@ -1114,12 +1102,14 @@ int marker_get_iter_range(struct marker * const **marker,
        struct marker * const *begin,
        struct marker * const *end)
 {
-       if (!*marker && begin != end) {
+       if (!*marker && begin != end)
                *marker = begin;
-               return 1;
+       while (*marker >= begin && *marker < end) {
+               if (!**marker)
+                       (*marker)++;    /* skip dummy */
+               else
+                       return 1;
        }
-       if (*marker >= begin && *marker < end)
-               return 1;
        return 0;
 }
 //ust// EXPORT_SYMBOL_GPL(marker_get_iter_range);
@@ -1342,15 +1332,17 @@ static void new_markers(struct marker * const *start, struct marker * const *end
 {
        if (new_marker_cb) {
                struct marker * const *m;
-               for(m=start; m < end; m++) {
-                       new_marker_cb(*m);
+
+               for(m = start; m < end; m++) {
+                       if (*m)
+                               new_marker_cb(*m);
                }
        }
 }
 
 int marker_register_lib(struct marker * const *markers_start, int markers_count)
 {
-       struct lib *pl;
+       struct lib *pl, *iter;
 
        pl = (struct lib *) zmalloc(sizeof(struct lib));
 
@@ -1359,7 +1351,21 @@ int marker_register_lib(struct marker * const *markers_start, int markers_count)
 
        /* FIXME: maybe protect this with its own mutex? */
        lock_markers();
+
+       /*
+        * We sort the libs by struct lib pointer address.
+        */
+       cds_list_for_each_entry_reverse(iter, &libs, list) {
+               BUG_ON(iter == pl);    /* Should never be in the list twice */
+               if (iter < pl) {
+                       /* We belong to the location right after iter. */
+                       cds_list_add(&pl->list, &iter->list);
+                       goto lib_added;
+               }
+       }
+       /* We should be added at the head of the list */
        cds_list_add(&pl->list, &libs);
+lib_added:
        unlock_markers();
 
        new_markers(markers_start, markers_start + markers_count);
@@ -1367,7 +1373,7 @@ int marker_register_lib(struct marker * const *markers_start, int markers_count)
        /* FIXME: update just the loaded lib */
        lib_update_markers();
 
-       DBG("just registered a markers section from %p and having %d markers", markers_start, markers_count);
+       DBG("just registered a markers section from %p and having %d markers (minus dummy markers)", markers_start, markers_count);
        
        return 0;
 }
@@ -1409,7 +1415,7 @@ void __attribute__((constructor)) init_markers(void)
        }
 }
 
-void __attribute__((constructor)) destroy_markers(void)
+void __attribute__((destructor)) destroy_markers(void)
 {
        marker_unregister_lib(__start___markers_ptrs);
 }
This page took 0.025831 seconds and 4 git commands to generate.