Privatize part of marker.h, and type-serializer.h
[ust.git] / libust / marker.c
index 4a7eec63c992dbbcfe192cac35590929c3535c39..33827fdc9026aa0002bec893c3f20867c820c700 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * Copyright (C) 2007 Mathieu Desnoyers
+ * Copyright (C) 2007-2011 Mathieu Desnoyers
  *
  * 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.
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#define _LGPL_SOURCE
 #include <stdlib.h>
 #include <errno.h>
-#define _LGPL_SOURCE
 #include <urcu-bp.h>
 #include <urcu/rculist.h>
 #include <urcu/hlist.h>
 
 #include <ust/core.h>
 #include <ust/marker.h>
+#include <ust/marker-internal.h>
 #include <ust/tracepoint.h>
+#include <ust/tracepoint-internal.h>
 
 #include "usterr_signal_safe.h"
 #include "channels.h"
@@ -64,9 +66,9 @@ void unlock_ust_marker(void)
  * ust_marker hash table, containing the active ust_marker.
  * Protected by module_mutex.
  */
-#define ust_marker_HASH_BITS 6
-#define ust_marker_TABLE_SIZE (1 << ust_marker_HASH_BITS)
-static struct cds_hlist_head ust_marker_table[ust_marker_TABLE_SIZE];
+#define UST_MARKER_HASH_BITS 6
+#define UST_MARKER_TABLE_SIZE (1 << UST_MARKER_HASH_BITS)
+static struct cds_hlist_head ust_marker_table[UST_MARKER_TABLE_SIZE];
 
 /*
  * Note about RCU :
@@ -81,7 +83,7 @@ struct ust_marker_entry {
        char *format;
        char *name;
                        /* Probe wrapper */
-       void (*call)(const struct ust_marker *mdata, void *call_private, struct registers *regs, ...);
+       void (*call)(const struct ust_marker *mdata, void *call_private, ...);
        struct ust_marker_probe_closure single;
        struct ust_marker_probe_closure *multi;
        int refcount;   /* Number of times armed. 0 if disarmed. */
@@ -118,7 +120,7 @@ static void ust_marker_update_processes(void)
  * execution flow of preemptible code.
  */
 notrace void __ust_marker_empty_function(const struct ust_marker *mdata,
-       void *probe_private, struct registers *regs, void *call_private, const char *fmt, va_list *args)
+       void *probe_private, void *call_private, const char *fmt, va_list *args)
 {
 }
 //ust// EXPORT_SYMBOL_GPL(__ust_marker_empty_function);
@@ -134,7 +136,7 @@ notrace void __ust_marker_empty_function(const struct ust_marker *mdata,
  * rcu_dereference() for the pointer read.
  */
 notrace void ust_marker_probe_cb(const struct ust_marker *mdata,
-               void *call_private, struct registers *regs, ...)
+               void *call_private, ...)
 {
        va_list args;
        char ptype;
@@ -155,8 +157,8 @@ notrace void ust_marker_probe_cb(const struct ust_marker *mdata,
                /* Must read the ptr before private data. They are not data
                 * dependant, so we put an explicit cmm_smp_rmb() here. */
                cmm_smp_rmb();
-               va_start(args, regs);
-               func(mdata, mdata->single.probe_private, regs, call_private,
+               va_start(args, call_private);
+               func(mdata, mdata->single.probe_private, call_private,
                        mdata->format, &args);
                va_end(args);
        } else {
@@ -176,9 +178,9 @@ notrace void ust_marker_probe_cb(const struct ust_marker *mdata,
                 */
                cmm_smp_read_barrier_depends();
                for (i = 0; multi[i].func; i++) {
-                       va_start(args, regs);
+                       va_start(args, call_private);
                        multi[i].func(mdata, multi[i].probe_private,
-                               regs, call_private, mdata->format, &args);
+                               call_private, mdata->format, &args);
                        va_end(args);
                }
        }
@@ -195,7 +197,7 @@ notrace void ust_marker_probe_cb(const struct ust_marker *mdata,
  * Should be connected to ust_marker "UST_MARKER_NOARGS".
  */
 static notrace void ust_marker_probe_cb_noarg(const struct ust_marker *mdata,
-               void *call_private, struct registers *regs, ...)
+               void *call_private, ...)
 {
        va_list args;   /* not initialized */
        char ptype;
@@ -211,7 +213,7 @@ static notrace void ust_marker_probe_cb_noarg(const struct ust_marker *mdata,
                /* Must read the ptr before private data. They are not data
                 * dependant, so we put an explicit cmm_smp_rmb() here. */
                cmm_smp_rmb();
-               func(mdata, mdata->single.probe_private, regs, call_private,
+               func(mdata, mdata->single.probe_private, call_private,
                        mdata->format, &args);
        } else {
                struct ust_marker_probe_closure *multi;
@@ -230,7 +232,7 @@ static notrace void ust_marker_probe_cb_noarg(const struct ust_marker *mdata,
                 */
                cmm_smp_read_barrier_depends();
                for (i = 0; multi[i].func; i++)
-                       multi[i].func(mdata, multi[i].probe_private, regs,
+                       multi[i].func(mdata, multi[i].probe_private,
                                call_private, mdata->format, &args);
        }
 //ust//        rcu_read_unlock_sched_notrace();
@@ -397,7 +399,7 @@ static struct ust_marker_entry *get_ust_marker(const char *channel, const char *
        u32 hash;
 
        hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
-       head = &ust_marker_table[hash & ((1 << ust_marker_HASH_BITS)-1)];
+       head = &ust_marker_table[hash & ((1 << UST_MARKER_HASH_BITS)-1)];
        cds_hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(channel, e->channel) && !strcmp(name, e->name))
                        return e;
@@ -423,7 +425,7 @@ static struct ust_marker_entry *add_ust_marker(const char *channel, const char *
        hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
        if (format)
                format_len = strlen(format) + 1;
-       head = &ust_marker_table[hash & ((1 << ust_marker_HASH_BITS)-1)];
+       head = &ust_marker_table[hash & ((1 << UST_MARKER_HASH_BITS)-1)];
        cds_hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
                        DBG("ust_marker %s.%s busy", channel, name);
@@ -448,7 +450,7 @@ static struct ust_marker_entry *add_ust_marker(const char *channel, const char *
                        e->call = ust_marker_probe_cb_noarg;
                else
                        e->call = ust_marker_probe_cb;
-               __ust_marker(0, metadata, core_marker_format, NULL,
+               __ust_marker(metadata, core_marker_format, NULL,
                           "channel %s name %s format %s",
                           e->channel, e->name, e->format);
        } else {
@@ -482,7 +484,7 @@ static int remove_ust_marker(const char *channel, const char *name)
        int ret;
 
        hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
-       head = &ust_marker_table[hash & ((1 << ust_marker_HASH_BITS)-1)];
+       head = &ust_marker_table[hash & ((1 << UST_MARKER_HASH_BITS)-1)];
        cds_hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
                        found = 1;
@@ -515,7 +517,7 @@ static int ust_marker_set_format(struct ust_marker_entry *entry, const char *for
                return -ENOMEM;
        entry->format_allocated = 1;
 
-       __ust_marker(0, metadata, core_marker_format, NULL,
+       __ust_marker(metadata, core_marker_format, NULL,
                   "channel %s name %s format %s",
                   entry->channel, entry->name, entry->format);
        return 0;
@@ -580,7 +582,7 @@ static int set_ust_marker(struct ust_marker_entry *entry, struct ust_marker *ele
        cmm_smp_wmb();
        elem->ptype = entry->ptype;
 
-       if (elem->tp_name && (active ^ _imv_read(elem->state))) {
+       if (elem->tp_name && (active ^ elem->state)) {
                WARN_ON(!elem->tp_cb);
                /*
                 * It is ok to directly call the probe registration because type
@@ -610,7 +612,7 @@ static int set_ust_marker(struct ust_marker_entry *entry, struct ust_marker *ele
 //ust//                                (unsigned long)elem->tp_cb));
                }
        }
-       elem->state__imv = active;
+       elem->state = active;
 
        return ret;
 }
@@ -626,7 +628,7 @@ static void disable_ust_marker(struct ust_marker *elem)
        int ret;
 
        /* leave "call" as is. It is known statically. */
-       if (elem->tp_name && _imv_read(elem->state)) {
+       if (elem->tp_name && elem->state) {
                WARN_ON(!elem->tp_cb);
                /*
                 * It is ok to directly call the probe registration because type
@@ -641,7 +643,7 @@ static void disable_ust_marker(struct ust_marker *elem)
                 */
 //ust//                module_put(__module_text_address((unsigned long)elem->tp_cb));
        }
-       elem->state__imv = 0;
+       elem->state = 0;
        elem->single.func = __ust_marker_empty_function;
        /* Update the function before setting the ptype */
        cmm_smp_wmb();
@@ -734,9 +736,6 @@ static void ust_marker_update_probes(void)
 {
        lib_update_ust_marker();
        tracepoint_probe_update_all();
-       /* Update immediate values */
-       core_imv_update();
-//ust//        module_imv_update(); /* FIXME: need to port for libs? */
        ust_marker_update_processes();
 }
 
@@ -782,7 +781,7 @@ int ust_marker_probe_register(const char *channel, const char *name,
                        goto error_unregister_channel;
                entry->event_id = ret;
                ret = 0;
-               __ust_marker(0, metadata, core_marker_id, NULL,
+               __ust_marker(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",
@@ -902,7 +901,7 @@ get_ust_marker_from_private_data(ust_marker_probe_func *probe, void *probe_priva
        struct cds_hlist_head *head;
        struct cds_hlist_node *node;
 
-       for (i = 0; i < ust_marker_TABLE_SIZE; i++) {
+       for (i = 0; i < UST_MARKER_TABLE_SIZE; i++) {
                head = &ust_marker_table[i];
                cds_hlist_for_each_entry(entry, node, head, hlist) {
                        if (!entry->ptype) {
@@ -1009,7 +1008,7 @@ void *ust_marker_get_private_data(const char *channel, const char *name,
        u32 hash;
 
        hash = jhash(channel, channel_len-1, 0) ^ jhash(name, name_len-1, 0);
-       head = &ust_marker_table[hash & ((1 << ust_marker_HASH_BITS)-1)];
+       head = &ust_marker_table[hash & ((1 << UST_MARKER_HASH_BITS)-1)];
        cds_hlist_for_each_entry(e, node, head, hlist) {
                if (!strcmp(channel, e->channel) && !strcmp(name, e->name)) {
                        if (!e->ptype) {
@@ -1047,7 +1046,7 @@ void *ust_marker_get_private_data(const char *channel, const char *name,
 //ust//        struct hlist_node *node;
 //ust//        int ret;
 //ust// 
-//ust//        for (i = 0; i < ust_marker_TABLE_SIZE; i++) {
+//ust//        for (i = 0; i < UST_MARKER_TABLE_SIZE; i++) {
 //ust//                head = &ust_marker_table[i];
 //ust//                hlist_for_each_entry(entry, node, head, hlist) {
 //ust//                        ret = ltt_channels_get_index_from_name(entry->channel);
@@ -1210,7 +1209,7 @@ static void free_user_ust_marker(char __user *state, struct cds_hlist_head *head
 //ust//                        }
 //ust//                }
 //ust//        }
-//ust//        clear_thread_flag(TIF_ust_marker_PENDING);
+//ust//        clear_thread_flag(TIF_UST_MARKER_PENDING);
 //ust//        pthread_mutex_unlock(&current->group_leader->user_ust_marker_mutex);
 //ust//        pthread_mutex_unlock(&ust_marker_mutex);
 //ust// }
@@ -1294,10 +1293,10 @@ void ltt_dump_ust_marker_state(struct ust_trace *trace)
        call_data.trace = trace;
        call_data.serializer = NULL;
 
-       for (i = 0; i < ust_marker_TABLE_SIZE; i++) {
+       for (i = 0; i < UST_MARKER_TABLE_SIZE; i++) {
                head = &ust_marker_table[i];
                cds_hlist_for_each_entry(entry, node, head, hlist) {
-                       __ust_marker(0, metadata, core_marker_id,
+                       __ust_marker(metadata, core_marker_id,
                                &call_data,
                                "channel %s name %s event_id %hu "
                                "int #1u%zu long #1u%zu pointer #1u%zu "
@@ -1309,7 +1308,7 @@ void ltt_dump_ust_marker_state(struct ust_trace *trace)
                                sizeof(void *), sizeof(size_t),
                                ltt_get_alignment());
                        if (entry->format)
-                               __ust_marker(0, metadata,
+                               __ust_marker(metadata,
                                        core_marker_format,
                                        &call_data,
                                        "channel %s name %s format %s",
This page took 0.027218 seconds and 4 git commands to generate.