X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=lttng-events.c;h=0faff8498df3d61eb972415a4b1c1336ccce20a4;hb=b8590f409425c30491f1c25e16ea5f156b0e605b;hp=567df65acea12345f51e46c937efa5f95cb15202;hpb=f613e3e6ea34dec9fe9232056bc02f6d80d95965;p=lttng-modules.git diff --git a/lttng-events.c b/lttng-events.c index 567df65a..0faff849 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -31,6 +31,7 @@ #include "wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */ #include "wrapper/random.h" #include "wrapper/tracepoint.h" +#include "lttng-kernel-version.h" #include "lttng-events.h" #include "lttng-tracer.h" #include "lttng-abi-old.h" @@ -60,9 +61,15 @@ void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream); void synchronize_trace(void) { synchronize_sched(); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) +#ifdef CONFIG_PREEMPT_RT_FULL + synchronize_rcu(); +#endif +#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) */ #ifdef CONFIG_PREEMPT_RT synchronize_rcu(); #endif +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) */ } struct lttng_session *lttng_session_create(void) @@ -285,6 +292,7 @@ struct lttng_channel *lttng_channel_create(struct lttng_session *session, goto nomem; chan->session = session; chan->id = session->free_chan_id++; + chan->ops = &transport->ops; /* * Note: the channel creation op already writes into the packet * headers. Therefore the "chan" information used as input @@ -296,7 +304,6 @@ struct lttng_channel *lttng_channel_create(struct lttng_session *session, if (!chan->chan) goto create_error; chan->enabled = 1; - chan->ops = &transport->ops; chan->transport = transport; chan->channel_type = channel_type; list_add(&chan->list, &session->chan); @@ -553,9 +560,11 @@ void _lttng_event_destroy(struct lttng_event *event) * sessions_mutex), so we can do racy operations such as looking for * remaining space left in packet and write, since mutual exclusion * protects us from concurrent writes. + * Returns the number of bytes written in the channel, 0 if no data + * was written and a negative value on error. */ -int lttng_metadata_output_channel(struct lttng_channel *chan, - struct lttng_metadata_stream *stream) +int lttng_metadata_output_channel(struct lttng_metadata_stream *stream, + struct channel *chan) { struct lib_ring_buffer_ctx ctx; int ret = 0; @@ -574,22 +583,22 @@ int lttng_metadata_output_channel(struct lttng_channel *chan, if (!len) return 0; reserve_len = min_t(size_t, - chan->ops->packet_avail_size(chan->chan), + stream->transport->ops.packet_avail_size(chan), len); - lib_ring_buffer_ctx_init(&ctx, chan->chan, NULL, reserve_len, + lib_ring_buffer_ctx_init(&ctx, chan, NULL, reserve_len, sizeof(char), -1); /* * If reservation failed, return an error to the caller. */ - ret = chan->ops->event_reserve(&ctx, 0); + ret = stream->transport->ops.event_reserve(&ctx, 0); if (ret != 0) { printk(KERN_WARNING "LTTng: Metadata event reservation failed\n"); goto end; } - chan->ops->event_write(&ctx, + stream->transport->ops.event_write(&ctx, stream->metadata_cache->data + stream->metadata_in, reserve_len); - chan->ops->event_commit(&ctx); + stream->transport->ops.event_commit(&ctx); stream->metadata_in += reserve_len; ret = reserve_len;