tracectl cleanup v3
[ust.git] / libust / tracer.c
index d5ec43e8356c2e527bc5642cc301fe1edb273770..8c3f77466f057f8fc89afcfc3c1dd2a5ac57b45f 100644 (file)
@@ -34,7 +34,8 @@
 #include <urcu-bp.h>
 #include <urcu/rculist.h>
 
-#include <ust/kernelcompat.h>
+#include <ust/clock.h>
+
 #include "tracercore.h"
 #include "tracer.h"
 #include "usterr.h"
@@ -68,11 +69,7 @@ int (*ltt_statedump_functor)(struct ust_trace *trace) =
                                        ltt_statedump_default;
 struct module *ltt_statedump_owner;
 
-struct chan_info_struct {
-       const char *name;
-       unsigned int def_subbufsize;
-       unsigned int def_subbufcount;
-} chan_infos[] = {
+struct chan_info_struct chan_infos[] = {
        [LTT_CHANNEL_METADATA] = {
                LTT_METADATA_CHANNEL,
                LTT_DEFAULT_SUBBUF_SIZE_LOW,
@@ -343,7 +340,7 @@ void ltt_release_trace(struct kref *kref)
        struct ust_trace *trace = container_of(kref,
                        struct ust_trace, kref);
        ltt_channels_trace_free(trace->channels);
-       kfree(trace);
+       free(trace);
 }
 
 static inline void prepare_chan_size_num(unsigned int *subbuf_size,
@@ -381,7 +378,7 @@ int _ltt_trace_setup(const char *trace_name)
                goto traces_error;
        }
 
-       new_trace = kzalloc(sizeof(struct ust_trace), GFP_KERNEL);
+       new_trace = zmalloc(sizeof(struct ust_trace));
        if (!new_trace) {
                ERR("Unable to allocate memory for trace %s", trace_name);
                err = -ENOMEM;
@@ -389,7 +386,8 @@ int _ltt_trace_setup(const char *trace_name)
        }
        strncpy(new_trace->trace_name, trace_name, NAME_MAX);
        new_trace->channels = ltt_channels_trace_alloc(&new_trace->nr_channels,
-                                                      0, 1);
+                               ust_channels_overwrite_by_default,
+                               ust_channels_request_collection_by_default, 1);
        if (!new_trace->channels) {
                ERR("Unable to allocate memory for chaninfo  %s\n", trace_name);
                err = -ENOMEM;
@@ -423,7 +421,7 @@ int _ltt_trace_setup(const char *trace_name)
        return 0;
 
 trace_free:
-       kfree(new_trace);
+       free(new_trace);
 traces_error:
        return err;
 }
@@ -442,7 +440,7 @@ int ltt_trace_setup(const char *trace_name)
 static void _ltt_trace_free(struct ust_trace *trace)
 {
        list_del(&trace->list);
-       kfree(trace);
+       free(trace);
 }
 
 int ltt_trace_set_type(const char *trace_name, const char *trace_type)
@@ -630,6 +628,11 @@ int ltt_trace_alloc(const char *trace_name)
 
        ltt_lock_traces();
 
+       if (_ltt_trace_find(trace_name)) { /* Trace already allocated */
+               err = 1;
+               goto traces_error;
+       }
+
        trace = _ltt_trace_find_setup(trace_name);
        if (!trace) {
                ERR("Trace not found %s", trace_name);
@@ -779,15 +782,17 @@ traces_error:
 }
 
 /* Sleepable part of the destroy */
-static void __ltt_trace_destroy(struct ust_trace *trace)
+static void __ltt_trace_destroy(struct ust_trace *trace, int drop)
 {
        int i;
        struct ust_channel *chan;
 
-       for (i = 0; i < trace->nr_channels; i++) {
-               chan = &trace->channels[i];
-               if (chan->active)
-                       trace->ops->finish_channel(chan);
+       if(!drop) {
+               for (i = 0; i < trace->nr_channels; i++) {
+                       chan = &trace->channels[i];
+                       if (chan->active)
+                               trace->ops->finish_channel(chan);
+               }
        }
 
        return; /* FIXME: temporary for ust */
@@ -822,7 +827,7 @@ static void __ltt_trace_destroy(struct ust_trace *trace)
        kref_put(&trace->kref, ltt_release_trace);
 }
 
-int ltt_trace_destroy(const char *trace_name)
+int ltt_trace_destroy(const char *trace_name, int drop)
 {
        int err = 0;
        struct ust_trace *trace;
@@ -837,7 +842,7 @@ int ltt_trace_destroy(const char *trace_name)
 
                ltt_unlock_traces();
 
-               __ltt_trace_destroy(trace);
+               __ltt_trace_destroy(trace, drop);
 //ust//                put_trace_clock();
 
                return 0;
This page took 0.023938 seconds and 4 git commands to generate.