libust: New transport mutex v2
authorNils Carlson <nils.carlson@ericsson.com>
Tue, 15 Mar 2011 13:17:34 +0000 (14:17 +0100)
committerNils Carlson <nils.carlson@ericsson.com>
Wed, 16 Mar 2011 08:50:43 +0000 (09:50 +0100)
Changes since v1:
Add a nesting comment

Make the locking around the transport list more intelligent, give
it its own mutex.

Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
libust/tracer.c

index 100dec09a5b670461cb287b07682ab862f509b82..ffcc2e74926996257ef7531fa622c1ee9179c0c9 100644 (file)
@@ -182,7 +182,8 @@ static enum ltt_channels get_channel_type_from_name(const char *name)
 //ust// }
 
 static CDS_LIST_HEAD(ltt_transport_list);
-
+/* transport mutex, nests inside traces mutex (ltt_lock_traces) */
+static DEFINE_MUTEX(ltt_transport_mutex);
 /**
  * ltt_transport_register - LTT transport registration
  * @transport: transport structure
@@ -204,9 +205,9 @@ void ltt_transport_register(struct ltt_transport *transport)
         */
 //ust//        vmalloc_sync_all();
 
-       ltt_lock_traces();
+       pthread_mutex_lock(&ltt_transport_mutex);
        cds_list_add_tail(&transport->node, &ltt_transport_list);
-       ltt_unlock_traces();
+       pthread_mutex_unlock(&ltt_transport_mutex);
 }
 
 /**
@@ -215,9 +216,9 @@ void ltt_transport_register(struct ltt_transport *transport)
  */
 void ltt_transport_unregister(struct ltt_transport *transport)
 {
-       ltt_lock_traces();
+       pthread_mutex_lock(&ltt_transport_mutex);
        cds_list_del(&transport->node);
-       ltt_unlock_traces();
+       pthread_mutex_unlock(&ltt_transport_mutex);
 }
 
 static inline int is_channel_overwrite(enum ltt_channels chan,
@@ -458,12 +459,15 @@ int ltt_trace_set_type(const char *trace_name, const char *trace_type)
                goto traces_error;
        }
 
+       pthread_mutex_lock(&ltt_transport_mutex);
        cds_list_for_each_entry(tran_iter, &ltt_transport_list, node) {
                if (!strcmp(tran_iter->name, trace_type)) {
                        transport = tran_iter;
                        break;
                }
        }
+       pthread_mutex_unlock(&ltt_transport_mutex);
+
        if (!transport) {
                ERR("Transport %s is not present", trace_type);
                err = -EINVAL;
This page took 0.024816 seconds and 4 git commands to generate.