#define _LGPL_SOURCE
#include <stdlib.h>
#include <errno.h>
+#include <pthread.h>
+#include <urcu-call-rcu.h>
#include <urcu-bp.h>
#include <urcu/rculist.h>
#include <urcu/hlist.h>
/* Set to 1 to enable ust_marker debug output */
static const int ust_marker_debug;
+static int initialized;
+static void (*new_ust_marker_cb)(struct ust_marker *);
/*
* ust_marker mutex protects the builtin and module ust_marker and the
static DEFINE_MUTEX(ust_marker_mutex);
static CDS_LIST_HEAD(ust_marker_libs);
+/*
+ * Allow nested mutex for mutex listing and nested enable.
+ */
+static __thread int nested_mutex;
+
void lock_ust_marker(void)
{
- pthread_mutex_lock(&ust_marker_mutex);
+ if (!(nested_mutex++))
+ pthread_mutex_lock(&ust_marker_mutex);
}
void unlock_ust_marker(void)
{
- pthread_mutex_unlock(&ust_marker_mutex);
+ if (!(--nested_mutex))
+ pthread_mutex_unlock(&ust_marker_mutex);
}
/*
{
struct ust_marker_entry *entry;
- pthread_mutex_lock(&ust_marker_mutex);
+ lock_ust_marker();
entry = get_ust_marker(channel, name);
- pthread_mutex_unlock(&ust_marker_mutex);
+ unlock_ust_marker();
return entry && !!entry->refcount;
}
{
struct ust_marker_lib *lib;
- pthread_mutex_lock(&ust_marker_mutex);
+ lock_ust_marker();
cds_list_for_each_entry(lib, &ust_marker_libs, list)
ust_marker_update_probe_range(lib->ust_marker_start,
lib->ust_marker_start + lib->ust_marker_count);
- pthread_mutex_unlock(&ust_marker_mutex);
+ unlock_ust_marker();
}
/*
struct ust_marker_probe_array *old;
int first_probe = 0;
- pthread_mutex_lock(&ust_marker_mutex);
+ lock_ust_marker();
entry = get_ust_marker(channel, name);
if (!entry) {
first_probe = 1;
else
goto end;
}
- pthread_mutex_unlock(&ust_marker_mutex);
+ unlock_ust_marker();
/* Activate ust_marker if necessary */
ust_marker_update_probes();
ret_err = remove_ust_marker(channel, name);
WARN_ON(ret_err);
end:
- pthread_mutex_unlock(&ust_marker_mutex);
+ unlock_ust_marker();
return ret;
}
struct ust_marker_probe_array *old;
int ret = 0;
- pthread_mutex_lock(&ust_marker_mutex);
+ lock_ust_marker();
entry = get_ust_marker(channel, name);
if (!entry) {
ret = -ENOENT;
goto end;
}
old = ust_marker_entry_remove_probe(entry, probe, probe_private);
- pthread_mutex_unlock(&ust_marker_mutex);
+ unlock_ust_marker();
ust_marker_update_probes();
return ret;
end:
- pthread_mutex_unlock(&ust_marker_mutex);
+ unlock_ust_marker();
return ret;
}
struct ust_marker_probe_array *old;
char *channel = NULL, *name = NULL;
- pthread_mutex_lock(&ust_marker_mutex);
+ lock_ust_marker();
entry = get_ust_marker_from_private_data(probe, probe_private);
if (!entry) {
ret = -ENOENT;
name = strdup(entry->name);
/* Ignore busy error message */
remove_ust_marker(channel, name);
- pthread_mutex_unlock(&ust_marker_mutex);
+ unlock_ust_marker();
ust_marker_update_probes();
goto end;
unlock:
- pthread_mutex_unlock(&ust_marker_mutex);
+ unlock_ust_marker();
end:
free(channel);
free(name);
ust_marker_iter_reset(iter);
}
-/* Called with markers mutex held. */
void ust_marker_iter_start(struct ust_marker_iter *iter)
{
+ lock_ust_marker();
ust_marker_get_iter(iter);
}
ust_marker_get_iter(iter);
}
-/* Called with markers mutex held. */
void ust_marker_iter_stop(struct ust_marker_iter *iter)
{
+ unlock_ust_marker();
}
-/* Called with markers mutex held. */
void ust_marker_iter_reset(struct ust_marker_iter *iter)
{
iter->lib = NULL;
struct cds_hlist_node *node;
unsigned int i;
- pthread_mutex_lock(&ust_marker_mutex);
+ lock_ust_marker();
call_data.trace = trace;
call_data.serializer = NULL;
entry->format);
}
}
- pthread_mutex_unlock(&ust_marker_mutex);
+ unlock_ust_marker();
}
-static void (*new_ust_marker_cb)(struct ust_marker *) = NULL;
-
void ust_marker_set_new_ust_marker_cb(void (*cb)(struct ust_marker *))
{
new_ust_marker_cb = cb;
if (new_ust_marker_cb) {
struct ust_marker * const *m;
- for(m = start; m < end; m++) {
+ for (m = start; m < end; m++) {
if (*m)
new_ust_marker_cb(*m);
}
return 0;
}
-static int initialized = 0;
-
void __attribute__((constructor)) init_ust_marker(void)
{
if (!initialized) {
+ init_tracepoint();
ust_marker_register_lib(__start___ust_marker_ptrs,
__stop___ust_marker_ptrs
- __start___ust_marker_ptrs);