X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=libust%2Fmarker-control.c;h=3d509525508a0446e828e1b3fecc165bcf75a560;hb=30ffe2794fc413035208cdd2a7a061bc208e210f;hp=a0786bad6fb306af26c8c1c300b01d5f2526f1db;hpb=c93858f1db9c8fedb9cb3dc751c95ce77083c7ee;p=ust.git diff --git a/libust/marker-control.c b/libust/marker-control.c index a0786ba..3d50952 100644 --- a/libust/marker-control.c +++ b/libust/marker-control.c @@ -15,33 +15,23 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * LTT marker control module over /proc */ -//ust// #include -//ust// #include -//ust// #include -//ust// #include -//ust// #include -//ust// #include -//ust// #include -//ust// #include -//ust// #include -//ust// #include -//ust// #include -//ust// #include -//ust// #include +/* This file contains a high-level API for activating and deactivating markers, + * and making sure markers in a given library can be released when the library + * is unloaded. + */ + #include +#include -#include -//#include "list.h" #include "tracer.h" -#include "usterr.h" +#include "usterr_signal_safe.h" #define DEFAULT_CHANNEL "cpu" #define DEFAULT_PROBE "default" -LIST_HEAD(probes_list); +CDS_LIST_HEAD(probes_list); /* * Mutex protecting the probe slab cache. @@ -57,11 +47,11 @@ struct ltt_available_probe default_probe = { }; //ust//static struct kmem_cache *markers_loaded_cachep; -static LIST_HEAD(markers_loaded_list); +static CDS_LIST_HEAD(markers_loaded_list); /* * List sorted by name strcmp order. */ -static LIST_HEAD(probes_registered_list); +static CDS_LIST_HEAD(probes_registered_list); //ust// static struct proc_dir_entry *pentry; @@ -74,7 +64,7 @@ static struct ltt_available_probe *get_probe_from_name(const char *pname) if (!pname) pname = DEFAULT_PROBE; - list_for_each_entry(iter, &probes_registered_list, node) { + cds_list_for_each_entry(iter, &probes_registered_list, node) { comparison = strcmp(pname, iter->name); if (!comparison) found = 1; @@ -117,22 +107,22 @@ int ltt_probe_register(struct ltt_available_probe *pdata) int comparison; struct ltt_available_probe *iter; - mutex_lock(&probes_mutex); - list_for_each_entry_reverse(iter, &probes_registered_list, node) { + pthread_mutex_lock(&probes_mutex); + cds_list_for_each_entry_reverse(iter, &probes_registered_list, node) { comparison = strcmp(pdata->name, iter->name); if (!comparison) { ret = -EBUSY; goto end; } else if (comparison > 0) { /* We belong to the location right after iter. */ - list_add(&pdata->node, &iter->node); + cds_list_add(&pdata->node, &iter->node); goto end; } } /* Should be added at the head of the list */ - list_add(&pdata->node, &probes_registered_list); + cds_list_add(&pdata->node, &probes_registered_list); end: - mutex_unlock(&probes_mutex); + pthread_mutex_unlock(&probes_mutex); return ret; } @@ -144,20 +134,20 @@ int ltt_probe_unregister(struct ltt_available_probe *pdata) int ret = 0; struct ltt_active_marker *amark, *tmp; - mutex_lock(&probes_mutex); - list_for_each_entry_safe(amark, tmp, &markers_loaded_list, node) { + pthread_mutex_lock(&probes_mutex); + cds_list_for_each_entry_safe(amark, tmp, &markers_loaded_list, node) { if (amark->probe == pdata) { ret = marker_probe_unregister_private_data( pdata->probe_func, amark); if (ret) goto end; - list_del(&amark->node); + cds_list_del(&amark->node); free(amark); } } - list_del(&pdata->node); + cds_list_del(&pdata->node); end: - mutex_unlock(&probes_mutex); + pthread_mutex_unlock(&probes_mutex); return ret; } @@ -174,7 +164,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; @@ -199,9 +189,9 @@ int ltt_marker_connect(const char *channel, const char *mname, if (ret) free(pdata); else - list_add(&pdata->node, &markers_loaded_list); + cds_list_add(&pdata->node, &markers_loaded_list); end: - mutex_unlock(&probes_mutex); + pthread_mutex_unlock(&probes_mutex); ltt_unlock_traces(); return ret; } @@ -216,7 +206,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; @@ -237,11 +227,11 @@ int ltt_marker_disconnect(const char *channel, const char *mname, if (ret) goto end; else { - list_del(&pdata->node); + cds_list_del(&pdata->node); free(pdata); } end: - mutex_unlock(&probes_mutex); + pthread_mutex_unlock(&probes_mutex); return ret; } @@ -401,10 +391,10 @@ static void disconnect_all_markers(void) { struct ltt_active_marker *pdata, *tmp; - list_for_each_entry_safe(pdata, tmp, &markers_loaded_list, node) { + cds_list_for_each_entry_safe(pdata, tmp, &markers_loaded_list, node) { marker_probe_unregister_private_data(pdata->probe->probe_func, pdata); - list_del(&pdata->node); + cds_list_del(&pdata->node); free(pdata); } }