From: Pierre-Marc Fournier Date: Mon, 24 May 2010 03:55:13 +0000 (-0400) Subject: remove mutex_lock, mutex_unlock macros X-Git-Tag: v1.9.1~595 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f7b16408b00ecce757bdde940853a48534b25edd;p=lttng-ust.git remove mutex_lock, mutex_unlock macros --- diff --git a/include/ust/core.h b/include/ust/core.h index c6057ea7..8cedf989 100644 --- a/include/ust/core.h +++ b/include/ust/core.h @@ -115,11 +115,6 @@ static inline long IS_ERR(const void *ptr) #define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER; #define DECLARE_MUTEX(m) extern pthread_mutex_t (m); -#define mutex_lock(m) pthread_mutex_lock(m) - -#define mutex_unlock(m) pthread_mutex_unlock(m) - - /* MALLOCATION */ #define zmalloc(s) calloc(1, s) diff --git a/libust/buffers.c b/libust/buffers.c index ac34e5fa..7b540de8 100644 --- a/libust/buffers.c +++ b/libust/buffers.c @@ -242,14 +242,14 @@ int ust_buffers_channel_open(struct ust_channel *chan, size_t subbuf_size, size_ kref_init(&chan->kref); - mutex_lock(&ust_buffers_channels_mutex); + pthread_mutex_lock(&ust_buffers_channels_mutex); for(i=0; in_cpus; i++) { result = ust_buffers_open_buf(chan, i); if (result == -1) goto error; } list_add(&chan->list, &ust_buffers_channels); - mutex_unlock(&ust_buffers_channels_mutex); + pthread_mutex_unlock(&ust_buffers_channels_mutex); return 0; @@ -262,7 +262,7 @@ error: } kref_put(&chan->kref, ust_buffers_destroy_channel); - mutex_unlock(&ust_buffers_channels_mutex); + pthread_mutex_unlock(&ust_buffers_channels_mutex); return -1; } @@ -272,7 +272,7 @@ void ust_buffers_channel_close(struct ust_channel *chan) if(!chan) return; - mutex_lock(&ust_buffers_channels_mutex); + pthread_mutex_lock(&ust_buffers_channels_mutex); for(i=0; in_cpus; i++) { /* FIXME: if we make it here, then all buffers were necessarily allocated. Moreover, we don't * initialize to NULL so we cannot use this check. Should we? */ @@ -282,7 +282,7 @@ void ust_buffers_channel_close(struct ust_channel *chan) list_del(&chan->list); kref_put(&chan->kref, ust_buffers_destroy_channel); - mutex_unlock(&ust_buffers_channels_mutex); + pthread_mutex_unlock(&ust_buffers_channels_mutex); } /* diff --git a/libust/channels.c b/libust/channels.c index e06720f3..df1a9725 100644 --- a/libust/channels.c +++ b/libust/channels.c @@ -109,7 +109,7 @@ int ltt_channels_register(const char *name) struct ltt_channel_setting *setting; int ret = 0; - mutex_lock(<t_channel_mutex); + pthread_mutex_lock(<t_channel_mutex); setting = lookup_channel(name); if (setting) { if (uatomic_read(&setting->kref.refcount) == 0) @@ -130,7 +130,7 @@ int ltt_channels_register(const char *name) init_kref: kref_init(&setting->kref); end: - mutex_unlock(<t_channel_mutex); + pthread_mutex_unlock(<t_channel_mutex); return ret; } //ust// EXPORT_SYMBOL_GPL(ltt_channels_register); @@ -146,7 +146,7 @@ int ltt_channels_unregister(const char *name) struct ltt_channel_setting *setting; int ret = 0; - mutex_lock(<t_channel_mutex); + pthread_mutex_lock(<t_channel_mutex); setting = lookup_channel(name); if (!setting || uatomic_read(&setting->kref.refcount) == 0) { ret = -ENOENT; @@ -154,7 +154,7 @@ int ltt_channels_unregister(const char *name) } kref_put(&setting->kref, release_channel_setting); end: - mutex_unlock(<t_channel_mutex); + pthread_mutex_unlock(<t_channel_mutex); return ret; } //ust// EXPORT_SYMBOL_GPL(ltt_channels_unregister); @@ -172,7 +172,7 @@ int ltt_channels_set_default(const char *name, struct ltt_channel_setting *setting; int ret = 0; - mutex_lock(<t_channel_mutex); + pthread_mutex_lock(<t_channel_mutex); setting = lookup_channel(name); if (!setting || uatomic_read(&setting->kref.refcount) == 0) { ret = -ENOENT; @@ -181,7 +181,7 @@ int ltt_channels_set_default(const char *name, setting->subbuf_size = subbuf_size; setting->subbuf_cnt = subbuf_cnt; end: - mutex_unlock(<t_channel_mutex); + pthread_mutex_unlock(<t_channel_mutex); return ret; } //ust// EXPORT_SYMBOL_GPL(ltt_channels_set_default); @@ -254,7 +254,7 @@ struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels, struct ust_channel *channel = NULL; struct ltt_channel_setting *iter; - mutex_lock(<t_channel_mutex); + pthread_mutex_lock(<t_channel_mutex); if (!free_index) { WARN("ltt_channels_trace_alloc: no free_index; are there any probes connected?"); goto end; @@ -280,7 +280,7 @@ struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels, channel[iter->index].channel_name = iter->name; } end: - mutex_unlock(<t_channel_mutex); + pthread_mutex_unlock(<t_channel_mutex); return channel; } //ust// EXPORT_SYMBOL_GPL(ltt_channels_trace_alloc); @@ -295,10 +295,10 @@ end: void ltt_channels_trace_free(struct ust_channel *channels) { lock_markers(); - mutex_lock(<t_channel_mutex); + pthread_mutex_lock(<t_channel_mutex); free(channels); kref_put(&index_kref, release_trace_channel); - mutex_unlock(<t_channel_mutex); + pthread_mutex_unlock(<t_channel_mutex); unlock_markers(); } //ust// EXPORT_SYMBOL_GPL(ltt_channels_trace_free); @@ -352,9 +352,9 @@ int ltt_channels_get_event_id(const char *channel, const char *name) { int ret; - mutex_lock(<t_channel_mutex); + pthread_mutex_lock(<t_channel_mutex); ret = _ltt_channels_get_event_id(channel, name); - mutex_unlock(<t_channel_mutex); + pthread_mutex_unlock(<t_channel_mutex); return ret; } diff --git a/libust/marker-control.c b/libust/marker-control.c index 9ee5b7cd..b4b7ce1a 100644 --- a/libust/marker-control.c +++ b/libust/marker-control.c @@ -103,7 +103,7 @@ int ltt_probe_register(struct ltt_available_probe *pdata) int comparison; struct ltt_available_probe *iter; - mutex_lock(&probes_mutex); + pthread_mutex_lock(&probes_mutex); list_for_each_entry_reverse(iter, &probes_registered_list, node) { comparison = strcmp(pdata->name, iter->name); if (!comparison) { @@ -118,7 +118,7 @@ int ltt_probe_register(struct ltt_available_probe *pdata) /* Should be added at the head of the list */ list_add(&pdata->node, &probes_registered_list); end: - mutex_unlock(&probes_mutex); + pthread_mutex_unlock(&probes_mutex); return ret; } @@ -130,7 +130,7 @@ int ltt_probe_unregister(struct ltt_available_probe *pdata) int ret = 0; struct ltt_active_marker *amark, *tmp; - mutex_lock(&probes_mutex); + pthread_mutex_lock(&probes_mutex); list_for_each_entry_safe(amark, tmp, &markers_loaded_list, node) { if (amark->probe == pdata) { ret = marker_probe_unregister_private_data( @@ -143,7 +143,7 @@ int ltt_probe_unregister(struct ltt_available_probe *pdata) } list_del(&pdata->node); end: - mutex_unlock(&probes_mutex); + pthread_mutex_unlock(&probes_mutex); return ret; } @@ -160,7 +160,7 @@ int ltt_marker_connect(const char *channel, const char *mname, struct ltt_available_probe *probe; ltt_lock_traces(); - mutex_lock(&probes_mutex); + pthread_mutex_lock(&probes_mutex); probe = get_probe_from_name(pname); if (!probe) { ret = -ENOENT; @@ -187,7 +187,7 @@ int ltt_marker_connect(const char *channel, const char *mname, else list_add(&pdata->node, &markers_loaded_list); end: - mutex_unlock(&probes_mutex); + pthread_mutex_unlock(&probes_mutex); ltt_unlock_traces(); return ret; } @@ -202,7 +202,7 @@ int ltt_marker_disconnect(const char *channel, const char *mname, struct ltt_available_probe *probe; int ret = 0; - mutex_lock(&probes_mutex); + pthread_mutex_lock(&probes_mutex); probe = get_probe_from_name(pname); if (!probe) { ret = -ENOENT; @@ -227,7 +227,7 @@ int ltt_marker_disconnect(const char *channel, const char *mname, free(pdata); } end: - mutex_unlock(&probes_mutex); + pthread_mutex_unlock(&probes_mutex); return ret; } diff --git a/libust/marker.c b/libust/marker.c index 56ffe399..4dc7de1c 100644 --- a/libust/marker.c +++ b/libust/marker.c @@ -50,12 +50,12 @@ static LIST_HEAD(libs); void lock_markers(void) { - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); } void unlock_markers(void) { - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); } /* @@ -661,9 +661,9 @@ int is_marker_enabled(const char *channel, const char *name) { struct marker_entry *entry; - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); entry = get_marker(channel, name); - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); return entry && !!entry->refcount; } @@ -681,7 +681,7 @@ void marker_update_probe_range(struct marker *begin, struct marker *iter; struct marker_entry *mark_entry; - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); for (iter = begin; iter < end; iter++) { mark_entry = get_marker(iter->channel, iter->name); if (mark_entry) { @@ -707,7 +707,7 @@ void marker_update_probe_range(struct marker *begin, disable_marker(iter); } } - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); } static void lib_update_markers(void) @@ -715,11 +715,11 @@ static void lib_update_markers(void) struct lib *lib; /* FIXME: we should probably take a mutex here on libs */ -//ust// mutex_lock(&module_mutex); +//ust// pthread_mutex_lock(&module_mutex); list_for_each_entry(lib, &libs, list) marker_update_probe_range(lib->markers_start, lib->markers_start + lib->markers_count); -//ust// mutex_unlock(&module_mutex); +//ust// pthread_mutex_unlock(&module_mutex); } /* @@ -774,7 +774,7 @@ int marker_probe_register(const char *channel, const char *name, struct marker_probe_closure *old; int first_probe = 0; - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); entry = get_marker(channel, name); if (!entry) { first_probe = 1; @@ -825,12 +825,12 @@ int marker_probe_register(const char *channel, const char *name, else goto end; } - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); /* Activate marker if necessary */ marker_update_probes(); - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); entry = get_marker(channel, name); if (!entry) goto end; @@ -851,7 +851,7 @@ error_remove_marker: ret_err = remove_marker(channel, name); WARN_ON(ret_err); end: - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); return ret; } //ust// EXPORT_SYMBOL_GPL(marker_probe_register); @@ -876,18 +876,18 @@ int marker_probe_unregister(const char *channel, const char *name, struct marker_probe_closure *old; int ret = -ENOENT; - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); entry = get_marker(channel, name); if (!entry) goto end; //ust// if (entry->rcu_pending) //ust// rcu_barrier_sched(); old = marker_entry_remove_probe(entry, probe, probe_private); - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); marker_update_probes(); - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); entry = get_marker(channel, name); if (!entry) goto end; @@ -902,7 +902,7 @@ int marker_probe_unregister(const char *channel, const char *name, remove_marker(channel, name); /* Ignore busy error message */ ret = 0; end: - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); return ret; } //ust// EXPORT_SYMBOL_GPL(marker_probe_unregister); @@ -959,7 +959,7 @@ int marker_probe_unregister_private_data(marker_probe_func *probe, struct marker_probe_closure *old; char *channel = NULL, *name = NULL; - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); entry = get_marker_from_private_data(probe, probe_private); if (!entry) { ret = -ENOENT; @@ -970,11 +970,11 @@ int marker_probe_unregister_private_data(marker_probe_func *probe, old = marker_entry_remove_probe(entry, NULL, probe_private); channel = strdup(entry->channel); name = strdup(entry->name); - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); marker_update_probes(); - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); entry = get_marker(channel, name); if (!entry) goto end; @@ -989,7 +989,7 @@ int marker_probe_unregister_private_data(marker_probe_func *probe, /* Ignore busy error message */ remove_marker(channel, name); end: - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); free(channel); free(name); return ret; @@ -1085,7 +1085,7 @@ int lib_get_iter_markers(struct marker_iter *iter) struct lib *iter_lib; int found = 0; -//ust// mutex_lock(&module_mutex); +//ust// pthread_mutex_lock(&module_mutex); list_for_each_entry(iter_lib, &libs, list) { if (iter_lib < iter->lib) continue; @@ -1099,7 +1099,7 @@ int lib_get_iter_markers(struct marker_iter *iter) break; } } -//ust// mutex_unlock(&module_mutex); +//ust// pthread_mutex_unlock(&module_mutex); return found; } @@ -1203,8 +1203,8 @@ static void free_user_marker(char __user *state, struct hlist_head *head) //ust// struct hlist_node *pos; //ust// struct marker_entry *entry; //ust// -//ust// mutex_lock(&markers_mutex); -//ust// mutex_lock(¤t->group_leader->user_markers_mutex); +//ust// pthread_mutex_lock(&markers_mutex); +//ust// pthread_mutex_lock(¤t->group_leader->user_markers_mutex); //ust// if (strcmp(current->comm, "testprog") == 0) //ust// DBG("do update pending for testprog"); //ust// hlist_for_each_entry(umark, pos, @@ -1231,8 +1231,8 @@ static void free_user_marker(char __user *state, struct hlist_head *head) //ust// } //ust// } //ust// clear_thread_flag(TIF_MARKER_PENDING); -//ust// mutex_unlock(¤t->group_leader->user_markers_mutex); -//ust// mutex_unlock(&markers_mutex); +//ust// pthread_mutex_unlock(¤t->group_leader->user_markers_mutex); +//ust// pthread_mutex_unlock(&markers_mutex); //ust// } /* @@ -1246,15 +1246,15 @@ void exit_user_markers(struct task_struct *p) struct hlist_node *pos, *n; if (thread_group_leader(p)) { - mutex_lock(&markers_mutex); - mutex_lock(&p->user_markers_mutex); + pthread_mutex_lock(&markers_mutex); + pthread_mutex_lock(&p->user_markers_mutex); hlist_for_each_entry_safe(umark, pos, n, &p->user_markers, hlist) free(umark); INIT_HLIST_HEAD(&p->user_markers); p->user_markers_sequence++; - mutex_unlock(&p->user_markers_mutex); - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&p->user_markers_mutex); + pthread_mutex_unlock(&markers_mutex); } } @@ -1262,9 +1262,9 @@ int is_marker_enabled(const char *channel, const char *name) { struct marker_entry *entry; - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); entry = get_marker(channel, name); - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); return entry && !!entry->refcount; } @@ -1310,7 +1310,7 @@ void ltt_dump_marker_state(struct ust_trace *trace) struct hlist_node *node; unsigned int i; - mutex_lock(&markers_mutex); + pthread_mutex_lock(&markers_mutex); call_data.trace = trace; call_data.serializer = NULL; @@ -1338,7 +1338,7 @@ void ltt_dump_marker_state(struct ust_trace *trace) entry->format); } } - mutex_unlock(&markers_mutex); + pthread_mutex_unlock(&markers_mutex); } //ust// EXPORT_SYMBOL_GPL(ltt_dump_marker_state); @@ -1393,7 +1393,7 @@ int marker_unregister_lib(struct marker *markers_start) lock_markers(); /* FIXME: we should probably take a mutex here on libs */ -//ust// mutex_lock(&module_mutex); +//ust// pthread_mutex_lock(&module_mutex); list_for_each_entry(lib, &libs, list) { if(lib->markers_start == markers_start) { struct lib *lib2free = lib; diff --git a/libust/tracepoint.c b/libust/tracepoint.c index 8eee320d..6155e290 100644 --- a/libust/tracepoint.c +++ b/libust/tracepoint.c @@ -285,7 +285,7 @@ void tracepoint_update_probe_range(struct tracepoint *begin, struct tracepoint *iter; struct tracepoint_entry *mark_entry; - mutex_lock(&tracepoints_mutex); + pthread_mutex_lock(&tracepoints_mutex); for (iter = begin; iter < end; iter++) { mark_entry = get_tracepoint(iter->name); if (mark_entry) { @@ -295,18 +295,18 @@ void tracepoint_update_probe_range(struct tracepoint *begin, disable_tracepoint(iter); } } - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); } static void lib_update_tracepoints(void) { struct tracepoint_lib *lib; -//ust// mutex_lock(&module_mutex); +//ust// pthread_mutex_lock(&module_mutex); list_for_each_entry(lib, &libs, list) tracepoint_update_probe_range(lib->tracepoints_start, lib->tracepoints_start + lib->tracepoints_count); -//ust// mutex_unlock(&module_mutex); +//ust// pthread_mutex_unlock(&module_mutex); } /* @@ -353,9 +353,9 @@ int tracepoint_probe_register(const char *name, void *probe) { void *old; - mutex_lock(&tracepoints_mutex); + pthread_mutex_lock(&tracepoints_mutex); old = tracepoint_add_probe(name, probe); - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); if (IS_ERR(old)) return PTR_ERR(old); @@ -395,9 +395,9 @@ int tracepoint_probe_unregister(const char *name, void *probe) { void *old; - mutex_lock(&tracepoints_mutex); + pthread_mutex_lock(&tracepoints_mutex); old = tracepoint_remove_probe(name, probe); - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); if (IS_ERR(old)) return PTR_ERR(old); @@ -431,14 +431,14 @@ int tracepoint_probe_register_noupdate(const char *name, void *probe) { void *old; - mutex_lock(&tracepoints_mutex); + pthread_mutex_lock(&tracepoints_mutex); old = tracepoint_add_probe(name, probe); if (IS_ERR(old)) { - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); return PTR_ERR(old); } tracepoint_add_old_probes(old); - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); return 0; } //ust// EXPORT_SYMBOL_GPL(tracepoint_probe_register_noupdate); @@ -454,14 +454,14 @@ int tracepoint_probe_unregister_noupdate(const char *name, void *probe) { void *old; - mutex_lock(&tracepoints_mutex); + pthread_mutex_lock(&tracepoints_mutex); old = tracepoint_remove_probe(name, probe); if (IS_ERR(old)) { - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); return PTR_ERR(old); } tracepoint_add_old_probes(old); - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); return 0; } //ust// EXPORT_SYMBOL_GPL(tracepoint_probe_unregister_noupdate); @@ -474,15 +474,15 @@ void tracepoint_probe_update_all(void) LIST_HEAD(release_probes); struct tp_probes *pos, *next; - mutex_lock(&tracepoints_mutex); + pthread_mutex_lock(&tracepoints_mutex); if (!need_update) { - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); return; } if (!list_empty(&old_probes)) list_replace_init(&old_probes, &release_probes); need_update = 0; - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); tracepoint_update_probes(); list_for_each_entry_safe(pos, next, &release_probes, u.list) { @@ -503,7 +503,7 @@ int lib_get_iter_tracepoints(struct tracepoint_iter *iter) struct tracepoint_lib *iter_lib; int found = 0; -//ust// mutex_lock(&module_mutex); +//ust// pthread_mutex_lock(&module_mutex); list_for_each_entry(iter_lib, &libs, list) { if (iter_lib < iter->lib) continue; @@ -517,7 +517,7 @@ int lib_get_iter_tracepoints(struct tracepoint_iter *iter) break; } } -//ust// mutex_unlock(&module_mutex); +//ust// pthread_mutex_unlock(&module_mutex); return found; } @@ -652,9 +652,9 @@ int tracepoint_register_lib(struct tracepoint *tracepoints_start, int tracepoint pl->tracepoints_count = tracepoints_count; /* FIXME: maybe protect this with its own mutex? */ - mutex_lock(&tracepoints_mutex); + pthread_mutex_lock(&tracepoints_mutex); list_add(&pl->list, &libs); - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); new_tracepoints(tracepoints_start, tracepoints_start + tracepoints_count); @@ -670,7 +670,7 @@ int tracepoint_unregister_lib(struct tracepoint *tracepoints_start) { struct tracepoint_lib *lib; - mutex_lock(&tracepoints_mutex); + pthread_mutex_lock(&tracepoints_mutex); list_for_each_entry(lib, &libs, list) { if(lib->tracepoints_start == tracepoints_start) { @@ -681,7 +681,7 @@ int tracepoint_unregister_lib(struct tracepoint *tracepoints_start) } } - mutex_unlock(&tracepoints_mutex); + pthread_mutex_unlock(&tracepoints_mutex); return 0; } diff --git a/libust/tracercore.c b/libust/tracercore.c index ff01f5e2..bbc86913 100644 --- a/libust/tracercore.c +++ b/libust/tracercore.c @@ -31,12 +31,12 @@ static DEFINE_MUTEX(ltt_traces_mutex); void ltt_lock_traces(void) { - mutex_lock(<t_traces_mutex); + pthread_mutex_lock(<t_traces_mutex); } void ltt_unlock_traces(void) { - mutex_unlock(<t_traces_mutex); + pthread_mutex_unlock(<t_traces_mutex); } //ust// DEFINE_PER_CPU(unsigned int, ltt_nesting);