add regex support for marker names
[ust.git] / libust / marker.c
index e417b62fbb76a384e6c2cbafd2ebecabc181ca84..33c500af1b931728b4ad1d3027d1532aa0d3e20c 100644 (file)
@@ -1,19 +1,19 @@
 /*
  * Copyright (C) 2007 Mathieu Desnoyers
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 //ust// #include <linux/module.h>
 //ust// #include <linux/mutex.h>
 //ust// #include <linux/user_marker.h>
 //ust// #include <linux/ltt-tracer.h>
 
-#include "marker.h"
+#define _LGPL_SOURCE
+#include <urcu.h>
+
 #include "kernelcompat.h"
+
+#include "marker.h"
 #include "usterr.h"
 #include "channels.h"
 #include "tracercore.h"
@@ -501,8 +505,8 @@ static int remove_marker(const char *channel, const char *name)
        ret = ltt_channels_unregister(e->channel);
        WARN_ON(ret);
        /* Make sure the call_rcu has been executed */
-       if (e->rcu_pending)
-               rcu_barrier_sched();
+//ust//        if (e->rcu_pending)
+//ust//                rcu_barrier_sched();
        kfree(e);
        return 0;
 }
@@ -792,8 +796,8 @@ int marker_probe_register(const char *channel, const char *name,
         * If we detect that a call_rcu is pending for this marker,
         * make sure it's executed now.
         */
-       if (entry->rcu_pending)
-               rcu_barrier_sched();
+//ust//        if (entry->rcu_pending)
+//ust//                rcu_barrier_sched();
        old = marker_entry_add_probe(entry, probe, probe_private);
        if (IS_ERR(old)) {
                ret = PTR_ERR(old);
@@ -810,14 +814,14 @@ int marker_probe_register(const char *channel, const char *name,
        entry = get_marker(channel, name);
        if (!entry)
                goto end;
-       if (entry->rcu_pending)
-               rcu_barrier_sched();
+//ust//        if (entry->rcu_pending)
+//ust//                rcu_barrier_sched();
        entry->oldptr = old;
        entry->rcu_pending = 1;
        /* write rcu_pending before calling the RCU callback */
        smp_wmb();
-       call_rcu_sched(&entry->rcu, free_old_closure);
-       /*synchronize_rcu(); free_old_closure();*/
+//ust//        call_rcu_sched(&entry->rcu, free_old_closure);
+       synchronize_rcu(); free_old_closure(&entry->rcu);
        goto end;
 
 error_unregister_channel:
@@ -856,8 +860,8 @@ int marker_probe_unregister(const char *channel, const char *name,
        entry = get_marker(channel, name);
        if (!entry)
                goto end;
-       if (entry->rcu_pending)
-               rcu_barrier_sched();
+//ust//        if (entry->rcu_pending)
+//ust//                rcu_barrier_sched();
        old = marker_entry_remove_probe(entry, probe, probe_private);
        mutex_unlock(&markers_mutex);
 
@@ -867,13 +871,14 @@ int marker_probe_unregister(const char *channel, const char *name,
        entry = get_marker(channel, name);
        if (!entry)
                goto end;
-       if (entry->rcu_pending)
-               rcu_barrier_sched();
+//ust//        if (entry->rcu_pending)
+//ust//                rcu_barrier_sched();
        entry->oldptr = old;
        entry->rcu_pending = 1;
        /* write rcu_pending before calling the RCU callback */
        smp_wmb();
-       call_rcu_sched(&entry->rcu, free_old_closure);
+//ust//        call_rcu_sched(&entry->rcu, free_old_closure);
+       synchronize_rcu(); free_old_closure(&entry->rcu);
        remove_marker(channel, name);   /* Ignore busy error message */
        ret = 0;
 end:
@@ -940,8 +945,8 @@ int marker_probe_unregister_private_data(marker_probe_func *probe,
                ret = -ENOENT;
                goto end;
        }
-       if (entry->rcu_pending)
-               rcu_barrier_sched();
+//ust//        if (entry->rcu_pending)
+//ust//                rcu_barrier_sched();
        old = marker_entry_remove_probe(entry, NULL, probe_private);
        channel = kstrdup(entry->channel, GFP_KERNEL);
        name = kstrdup(entry->name, GFP_KERNEL);
@@ -953,13 +958,14 @@ int marker_probe_unregister_private_data(marker_probe_func *probe,
        entry = get_marker(channel, name);
        if (!entry)
                goto end;
-       if (entry->rcu_pending)
-               rcu_barrier_sched();
+//ust//        if (entry->rcu_pending)
+//ust//                rcu_barrier_sched();
        entry->oldptr = old;
        entry->rcu_pending = 1;
        /* write rcu_pending before calling the RCU callback */
        smp_wmb();
-       call_rcu_sched(&entry->rcu, free_old_closure);
+//ust//        call_rcu_sched(&entry->rcu, free_old_closure);
+       synchronize_rcu(); free_old_closure(&entry->rcu);
        /* Ignore busy error message */
        remove_marker(channel, name);
 end:
@@ -1392,41 +1398,41 @@ struct notifier_block marker_module_nb = {
 
 void ltt_dump_marker_state(struct ltt_trace_struct *trace)
 {
-       struct marker_iter iter;
+       struct marker_entry *entry;
        struct ltt_probe_private_data call_data;
-       const char *channel;
+       struct hlist_head *head;
+       struct hlist_node *node;
+       unsigned int i;
 
+       mutex_lock(&markers_mutex);
        call_data.trace = trace;
        call_data.serializer = NULL;
 
-       marker_iter_reset(&iter);
-       marker_iter_start(&iter);
-       for (; iter.marker != NULL; marker_iter_next(&iter)) {
-               if (!_imv_read(iter.marker->state))
-                       continue;
-               channel = ltt_channels_get_name_from_index(
-                               iter.marker->channel_id);
-               __trace_mark(0, metadata, core_marker_id,
-                       &call_data,
-                       "channel %s name %s event_id %hu "
-                       "int #1u%zu long #1u%zu pointer #1u%zu "
-                       "size_t #1u%zu alignment #1u%u",
-                       channel,
-                       iter.marker->name,
-                       iter.marker->event_id,
-                       sizeof(int), sizeof(long),
-                       sizeof(void *), sizeof(size_t),
-                       ltt_get_alignment());
-               if (iter.marker->format)
-                       __trace_mark(0, metadata,
-                               core_marker_format,
+       for (i = 0; i < MARKER_TABLE_SIZE; i++) {
+               head = &marker_table[i];
+               hlist_for_each_entry(entry, node, head, hlist) {
+                       __trace_mark(0, metadata, core_marker_id,
                                &call_data,
-                               "channel %s name %s format %s",
-                               channel,
-                               iter.marker->name,
-                               iter.marker->format);
+                               "channel %s name %s event_id %hu "
+                               "int #1u%zu long #1u%zu pointer #1u%zu "
+                               "size_t #1u%zu alignment #1u%u",
+                               entry->channel,
+                               entry->name,
+                               entry->event_id,
+                               sizeof(int), sizeof(long),
+                               sizeof(void *), sizeof(size_t),
+                               ltt_get_alignment());
+                       if (entry->format)
+                               __trace_mark(0, metadata,
+                                       core_marker_format,
+                                       &call_data,
+                                       "channel %s name %s format %s",
+                                       entry->channel,
+                                       entry->name,
+                                       entry->format);
+               }
        }
-       marker_iter_stop(&iter);
+       mutex_unlock(&markers_mutex);
 }
 //ust// EXPORT_SYMBOL_GPL(ltt_dump_marker_state);
 
@@ -1526,7 +1532,7 @@ void __attribute__((constructor)) init_markers(void)
 {
        if(!initialized) {
                marker_register_lib(__start___markers, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker));
-               printf("markers_start: %p, markers_stop: %p\n", __start___markers, __stop___markers);
+               DBG("markers_start: %p, markers_stop: %p\n", __start___markers, __stop___markers);
                initialized = 1;
        }
 }
This page took 0.030379 seconds and 4 git commands to generate.