X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=libust%2Fchannels.c;h=e06720f3bc75c3f4fd1ac1b4958d827391dba9f8;hb=a4e826d7ad30a0a6d68c04e585a51849d4aa6509;hp=c90733cbbc863061684adb6495bfec232736d8e7;hpb=b5b073e22d34bec71259d39b8946354f170f01a9;p=ust.git diff --git a/libust/channels.c b/libust/channels.c index c90733c..e06720f 100644 --- a/libust/channels.c +++ b/libust/channels.c @@ -23,15 +23,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -//ust// #include -//ust// #include -//ust// #include -//ust// #include - -#include +#include +#include #include "channels.h" #include "usterr.h" -#include /* * ltt_channel_mutex may be nested inside the LTT trace mutex. @@ -49,6 +44,9 @@ static LIST_HEAD(ltt_channels); static unsigned int free_index; static struct kref index_kref; /* Keeps track of allocated trace channels */ +int ust_channels_overwrite_by_default = 0; +int ust_channels_request_collection_by_default = 1; + static struct ltt_channel_setting *lookup_channel(const char *name) { struct ltt_channel_setting *iter; @@ -72,16 +70,17 @@ static void release_channel_setting(struct kref *kref) struct ltt_channel_setting, kref); struct ltt_channel_setting *iter; - if (atomic_read(&index_kref.refcount) == 0 - && atomic_read(&setting->kref.refcount) == 0) { + if (uatomic_read(&index_kref.refcount) == 0 + && uatomic_read(&setting->kref.refcount) == 0) { list_del(&setting->list); - kfree(setting); + free(setting); free_index = 0; list_for_each_entry(iter, <t_channels, list) { iter->index = free_index++; iter->free_event_id = 0; } + /* FIXME: why not run this? */ //ust// markers_compact_event_ids(); } } @@ -113,14 +112,14 @@ int ltt_channels_register(const char *name) mutex_lock(<t_channel_mutex); setting = lookup_channel(name); if (setting) { - if (atomic_read(&setting->kref.refcount) == 0) + if (uatomic_read(&setting->kref.refcount) == 0) goto init_kref; else { kref_get(&setting->kref); goto end; } } - setting = kzalloc(sizeof(*setting), GFP_KERNEL); + setting = zmalloc(sizeof(*setting)); if (!setting) { ret = -ENOMEM; goto end; @@ -149,7 +148,7 @@ int ltt_channels_unregister(const char *name) mutex_lock(<t_channel_mutex); setting = lookup_channel(name); - if (!setting || atomic_read(&setting->kref.refcount) == 0) { + if (!setting || uatomic_read(&setting->kref.refcount) == 0) { ret = -ENOENT; goto end; } @@ -175,7 +174,7 @@ int ltt_channels_set_default(const char *name, mutex_lock(<t_channel_mutex); setting = lookup_channel(name); - if (!setting || atomic_read(&setting->kref.refcount) == 0) { + if (!setting || uatomic_read(&setting->kref.refcount) == 0) { ret = -ENOENT; goto end; } @@ -199,7 +198,7 @@ const char *ltt_channels_get_name_from_index(unsigned int index) struct ltt_channel_setting *iter; list_for_each_entry(iter, <t_channels, list) - if (iter->index == index && atomic_read(&iter->kref.refcount)) + if (iter->index == index && uatomic_read(&iter->kref.refcount)) return iter->name; return NULL; } @@ -212,7 +211,7 @@ ltt_channels_get_setting_from_name(const char *name) list_for_each_entry(iter, <t_channels, list) if (!strcmp(iter->name, name) - && atomic_read(&iter->kref.refcount)) + && uatomic_read(&iter->kref.refcount)) return iter; return NULL; } @@ -249,6 +248,7 @@ int ltt_channels_get_index_from_name(const char *name) */ struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels, int overwrite, + int request_collection, int active) { struct ust_channel *channel = NULL; @@ -259,23 +259,23 @@ struct ust_channel *ltt_channels_trace_alloc(unsigned int *nr_channels, WARN("ltt_channels_trace_alloc: no free_index; are there any probes connected?"); goto end; } - if (!atomic_read(&index_kref.refcount)) + if (!uatomic_read(&index_kref.refcount)) kref_init(&index_kref); else kref_get(&index_kref); *nr_channels = free_index; - channel = kzalloc(sizeof(struct ust_channel) * free_index, - GFP_KERNEL); + channel = zmalloc(sizeof(struct ust_channel) * free_index); if (!channel) { WARN("ltt_channel_struct: channel null after alloc"); goto end; } list_for_each_entry(iter, <t_channels, list) { - if (!atomic_read(&iter->kref.refcount)) + if (!uatomic_read(&iter->kref.refcount)) continue; channel[iter->index].subbuf_size = iter->subbuf_size; channel[iter->index].subbuf_cnt = iter->subbuf_cnt; channel[iter->index].overwrite = overwrite; + channel[iter->index].request_collection = request_collection; channel[iter->index].active = active; channel[iter->index].channel_name = iter->name; } @@ -296,7 +296,7 @@ void ltt_channels_trace_free(struct ust_channel *channels) { lock_markers(); mutex_lock(<t_channel_mutex); - kfree(channels); + free(channels); kref_put(&index_kref, release_trace_channel); mutex_unlock(<t_channel_mutex); unlock_markers();