All of lore.kernel.org
 help / color / mirror / Atom feed
* [UST PATCH 2/2] LTTng ringbuffer ABI calls for index generation
       [not found] <1376678386-18607-1-git-send-email-jdesfossez@efficios.com>
@ 2013-08-16 18:39 ` Julien Desfossez
  2013-08-16 18:47 ` [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb Mathieu Desnoyers
       [not found] ` <1376678386-18607-2-git-send-email-jdesfossez@efficios.com>
  2 siblings, 0 replies; 9+ messages in thread
From: Julien Desfossez @ 2013-08-16 18:39 UTC (permalink / raw)
  To: mathieu.desnoyers; +Cc: lttng-dev, Julien Desfossez

These new calls export the data required for the consumer to
generate the index while tracing :
- timestamp begin
- timestamp end
- events discarded
- context size
- packet size
- stream id

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
---
 include/lttng/ust-ctl.h                 |   14 ++++
 liblttng-ust-ctl/ustctl.c               |  125 +++++++++++++++++++++++++++++++
 liblttng-ust/lttng-rb-clients.h         |   19 +++++
 liblttng-ust/lttng-ring-buffer-client.h |   91 ++++++++++++++++++++++
 4 files changed, 249 insertions(+)

diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h
index 3c81e50..88112ad 100644
--- a/include/lttng/ust-ctl.h
+++ b/include/lttng/ust-ctl.h
@@ -220,6 +220,20 @@ int ustctl_put_subbuf(struct ustctl_consumer_stream *stream);
 void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
 		int producer_active);
 
+/* index */
+int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream,
+		uint64_t *timestamp_begin);
+int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream,
+	uint64_t *timestamp_end);
+int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream,
+	uint64_t *events_discarded);
+int ustctl_get_content_size(struct ustctl_consumer_stream *stream,
+	uint64_t *content_size);
+int ustctl_get_packet_size(struct ustctl_consumer_stream *stream,
+	uint64_t *packet_size);
+int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
+		uint64_t *stream_id);
+
 /* event registry management */
 
 enum ustctl_socket_type {
diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c
index 28dee5e..9255416 100644
--- a/liblttng-ust-ctl/ustctl.c
+++ b/liblttng-ust-ctl/ustctl.c
@@ -31,6 +31,7 @@
 #include "../libringbuffer/backend.h"
 #include "../libringbuffer/frontend.h"
 #include "../liblttng-ust/wait.h"
+#include "../liblttng-ust/lttng-rb-clients.h"
 
 /*
  * Number of milliseconds to retry before failing metadata writes on
@@ -1461,6 +1462,130 @@ void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
 		consumer_chan->chan->handle);
 }
 
+static
+struct lttng_ust_client_lib_ring_buffer_client_cb *get_client_cb(
+		struct lttng_ust_lib_ring_buffer *buf,
+		struct lttng_ust_shm_handle *handle)
+{
+	struct channel *chan;
+	const struct lttng_ust_lib_ring_buffer_config *config;
+	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
+
+	chan = shmp(handle, buf->backend.chan);
+	config = &chan->backend.config;
+
+	if (!config->cb_ptr)
+		return NULL;
+
+	client_cb = caa_container_of(config->cb_ptr,
+			struct lttng_ust_client_lib_ring_buffer_client_cb,
+			parent);
+
+	return client_cb;
+}
+
+int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream,
+		uint64_t *timestamp_begin)
+{
+	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
+	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
+	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
+
+	if (!stream || !timestamp_begin)
+		return -EINVAL;
+
+	client_cb = get_client_cb(buf, handle);
+	if (!client_cb)
+		return -ENOSYS;
+
+	return client_cb->timestamp_begin(buf, handle, timestamp_begin);
+}
+
+int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream,
+	uint64_t *timestamp_end)
+{
+	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
+	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
+	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
+
+	if (!stream || !timestamp_end)
+		return -EINVAL;
+
+	client_cb = get_client_cb(buf, handle);
+	if (!client_cb)
+		return -ENOSYS;
+
+	return client_cb->timestamp_end(buf, handle, timestamp_end);
+}
+
+int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream,
+	uint64_t *events_discarded)
+{
+	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
+	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
+	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
+
+	if (!stream || !events_discarded)
+		return -EINVAL;
+
+	client_cb = get_client_cb(buf, handle);
+	if (!client_cb)
+		return -ENOSYS;
+
+	return client_cb->events_discarded(buf, handle, events_discarded);
+}
+
+int ustctl_get_content_size(struct ustctl_consumer_stream *stream,
+	uint64_t *content_size)
+{
+	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
+	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
+	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
+
+	if (!stream || !content_size)
+		return -EINVAL;
+
+	client_cb = get_client_cb(buf, handle);
+	if (!client_cb)
+		return -ENOSYS;
+
+	return client_cb->content_size(buf, handle, content_size);
+}
+
+int ustctl_get_packet_size(struct ustctl_consumer_stream *stream,
+	uint64_t *packet_size)
+{
+	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
+	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
+	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
+
+	if (!stream || !packet_size)
+		return -EINVAL;
+
+	client_cb = get_client_cb(buf, handle);
+	if (!client_cb)
+		return -ENOSYS;
+
+	return client_cb->packet_size(buf, handle, packet_size);
+}
+
+int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
+		uint64_t *stream_id)
+{
+	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
+	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
+	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
+
+	if (!stream || !stream_id)
+		return -EINVAL;
+
+	client_cb = get_client_cb(buf, handle);
+	if (!client_cb)
+		return -ENOSYS;
+
+	return client_cb->stream_id(buf, handle, stream_id);
+}
+
 /*
  * Returns 0 on success, negative error value on error.
  */
diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
index c9a1619..c43aa75 100644
--- a/liblttng-ust/lttng-rb-clients.h
+++ b/liblttng-ust/lttng-rb-clients.h
@@ -21,6 +21,25 @@
 
 struct lttng_ust_client_lib_ring_buffer_client_cb {
 	struct lttng_ust_lib_ring_buffer_client_cb parent;
+
+	int (*timestamp_begin) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *timestamp_begin);
+	int (*timestamp_end) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *timestamp_end);
+	int (*events_discarded) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *events_discarded);
+	int (*content_size) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *content_size);
+	int (*packet_size) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *packet_size);
+	int (*stream_id) (struct lttng_ust_lib_ring_buffer *buf,
+			struct lttng_ust_shm_handle *handle,
+			uint64_t *stream_id);
 };
 
 #endif /* _LTTNG_RB_CLIENT_H */
diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h
index 383fce0..5ce672c 100644
--- a/liblttng-ust/lttng-ring-buffer-client.h
+++ b/liblttng-ust/lttng-ring-buffer-client.h
@@ -386,6 +386,91 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
 {
 }
 
+static struct packet_header *client_packet_header(struct lttng_ust_lib_ring_buffer *buf,
+		struct lttng_ust_shm_handle *handle)
+{
+	struct channel *chan = shmp(handle, buf->backend.chan);
+	struct lttng_channel *lttng_chan = channel_get_private(chan);
+	unsigned long sb_index;
+	struct lttng_ust_lib_ring_buffer_backend *bufb;
+	struct packet_header *header;
+
+	bufb = &buf->backend;
+	sb_index = subbuffer_id_get_index(&lttng_chan->chan->backend.config,
+			bufb->buf_rsb.id);
+
+	header = lib_ring_buffer_offset_address(bufb,
+			sb_index * lttng_chan->chan->backend.subbuf_size,
+			handle);
+
+	return header;
+}
+
+static int client_timestamp_begin(struct lttng_ust_lib_ring_buffer *buf,
+		struct lttng_ust_shm_handle *handle,
+		uint64_t *timestamp_begin)
+{
+	struct packet_header *header = client_packet_header(buf, handle);
+
+	*timestamp_begin = header->ctx.timestamp_begin;
+
+	return 0;
+}
+
+static int client_timestamp_end(struct lttng_ust_lib_ring_buffer *buf,
+		struct lttng_ust_shm_handle *handle,
+		uint64_t *timestamp_end)
+{
+	struct packet_header *header = client_packet_header(buf, handle);
+
+	*timestamp_end = header->ctx.timestamp_end;
+
+	return 0;
+}
+
+static int client_events_discarded(struct lttng_ust_lib_ring_buffer *buf,
+		struct lttng_ust_shm_handle *handle,
+		uint64_t *events_discarded)
+{
+	struct packet_header *header = client_packet_header(buf, handle);
+
+	*events_discarded = header->ctx.events_discarded;
+
+	return 0;
+}
+
+static int client_content_size(struct lttng_ust_lib_ring_buffer *buf,
+		struct lttng_ust_shm_handle *handle,
+		uint64_t *content_size)
+{
+	struct packet_header *header = client_packet_header(buf, handle);
+
+	*content_size = header->ctx.content_size;
+
+	return 0;
+}
+
+static int client_packet_size(struct lttng_ust_lib_ring_buffer *buf,
+		struct lttng_ust_shm_handle *handle,
+		uint64_t *packet_size)
+{
+	struct packet_header *header = client_packet_header(buf, handle);
+
+	*packet_size = header->ctx.packet_size;
+
+	return 0;
+}
+
+static int client_stream_id(struct lttng_ust_lib_ring_buffer *buf,
+		struct lttng_ust_shm_handle *handle,
+		uint64_t *stream_id)
+{
+	struct packet_header *header = client_packet_header(buf, handle);
+
+	*stream_id = header->stream_id;
+
+	return 0;
+}
 static const
 struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
 	.parent = {
@@ -397,6 +482,12 @@ struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
 		.buffer_create = client_buffer_create,
 		.buffer_finalize = client_buffer_finalize,
 	},
+	.timestamp_begin = client_timestamp_begin,
+	.timestamp_end = client_timestamp_end,
+	.events_discarded = client_events_discarded,
+	.content_size = client_content_size,
+	.packet_size = client_packet_size,
+	.stream_id = client_stream_id,
 };
 
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb
       [not found] <1376678386-18607-1-git-send-email-jdesfossez@efficios.com>
  2013-08-16 18:39 ` [UST PATCH 2/2] LTTng ringbuffer ABI calls for index generation Julien Desfossez
@ 2013-08-16 18:47 ` Mathieu Desnoyers
       [not found] ` <1376678386-18607-2-git-send-email-jdesfossez@efficios.com>
  2 siblings, 0 replies; 9+ messages in thread
From: Mathieu Desnoyers @ 2013-08-16 18:47 UTC (permalink / raw)
  To: Julien Desfossez; +Cc: lttng-dev

* Julien Desfossez (jdesfossez@efficios.com) wrote:
> Prepare the ring-buffer config to have custom callbacks. These custom
> callbacks are not related to the ring-buffer operations but allow
> applications to add custom functions.
> No additional feature or change in behaviour in this patch.
> 
> Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
> ---
>  include/lttng/ringbuffer-config.h                |    4 +++-
>  include/lttng/ust-events.h                       |    6 ++---
>  liblttng-ust/Makefile.am                         |    1 +
>  liblttng-ust/lttng-rb-clients.h                  |   26 ++++++++++++++++++++++
>  liblttng-ust/lttng-ring-buffer-client.h          |   18 ++++++++++++++-
>  liblttng-ust/lttng-ring-buffer-metadata-client.h |   18 ++++++++++++++-
>  6 files changed, 67 insertions(+), 6 deletions(-)
>  create mode 100644 liblttng-ust/lttng-rb-clients.h
> 
> diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
> index 3b7d348..afb1310 100644
> --- a/include/lttng/ringbuffer-config.h
> +++ b/include/lttng/ringbuffer-config.h
> @@ -133,7 +133,8 @@ struct lttng_ust_lib_ring_buffer_client_cb {
>   * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client
>   * has the responsibility to perform wakeups.
>   */

just to be on the safe side (this structure is not packed):

> -#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING	32
> +#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING	\
> +	(32 - sizeof(const struct lttng_ust_lib_ring_buffer_client_cb *))
>  
#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING    20

 (32 - 4 - 8, worse case)

>  enum lttng_ust_lib_ring_buffer_alloc_types {
>  	RING_BUFFER_ALLOC_PER_CPU,
> @@ -204,6 +205,7 @@ struct lttng_ust_lib_ring_buffer_config {
>  	 * callbacks and update the cb pointers.
>  	 */
>  	int client_type;

int _unused1;

  (because int client_type has a structure that contains pointers, so
  we'll have padding added on 64-bit archs) It's better to explicitly
  enforce the padding. (yes, this should have been packed form the
  start. Too late.)

Thanks,

Mathieu

> +	const struct lttng_ust_lib_ring_buffer_client_cb *cb_ptr;
>  	char padding[LTTNG_UST_RING_BUFFER_CONFIG_PADDING];
>  };
>  
> diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
> index f40c044..74a3bc6 100644
> --- a/include/lttng/ust-events.h
> +++ b/include/lttng/ust-events.h
> @@ -569,9 +569,9 @@ int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
>  void lttng_context_vtid_reset(void);
>  void lttng_context_vpid_reset(void);
>  
> -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
> -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
> -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
> +extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
> +extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
> +extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
>  
>  struct lttng_transport *lttng_transport_find(const char *name);
>  
> diff --git a/liblttng-ust/Makefile.am b/liblttng-ust/Makefile.am
> index 1e6401a..5a43cf5 100644
> --- a/liblttng-ust/Makefile.am
> +++ b/liblttng-ust/Makefile.am
> @@ -47,6 +47,7 @@ liblttng_ust_support_la_SOURCES = \
>  	lttng-tracer.h \
>  	lttng-tracer-core.h \
>  	ust-core.c \
> +	lttng-rb-clients.h \
>  	lttng-ring-buffer-client.h \
>  	lttng-ring-buffer-client-discard.c \
>  	lttng-ring-buffer-client-discard-rt.c \
> diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
> new file mode 100644
> index 0000000..c9a1619
> --- /dev/null
> +++ b/liblttng-ust/lttng-rb-clients.h
> @@ -0,0 +1,26 @@
> +#ifndef _LTTNG_RB_CLIENT_H
> +#define _LTTNG_RB_CLIENT_H
> +
> +/*
> + * Copyright (c) 2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; only
> + * version 2.1 of the License.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +struct lttng_ust_client_lib_ring_buffer_client_cb {
> +	struct lttng_ust_lib_ring_buffer_client_cb parent;
> +};
> +
> +#endif /* _LTTNG_RB_CLIENT_H */
> diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h
> index 72b6d2c..383fce0 100644
> --- a/liblttng-ust/lttng-ring-buffer-client.h
> +++ b/liblttng-ust/lttng-ring-buffer-client.h
> @@ -161,6 +161,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
>  }
>  
>  #include "../libringbuffer/api.h"
> +#include "lttng-rb-clients.h"
>  
>  static
>  void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config *config,
> @@ -385,6 +386,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
>  {
>  }
>  
> +static const
> +struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
> +	.parent = {
> +		.ring_buffer_clock_read = client_ring_buffer_clock_read,
> +		.record_header_size = client_record_header_size,
> +		.subbuffer_header_size = client_packet_header_size,
> +		.buffer_begin = client_buffer_begin,
> +		.buffer_end = client_buffer_end,
> +		.buffer_create = client_buffer_create,
> +		.buffer_finalize = client_buffer_finalize,
> +	},
> +};
> +
>  static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
>  	.cb.record_header_size = client_record_header_size,
> @@ -404,9 +418,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.ipi = RING_BUFFER_NO_IPI_BARRIER,
>  	.wakeup = LTTNG_CLIENT_WAKEUP,
>  	.client_type = LTTNG_CLIENT_TYPE,
> +
> +	.cb_ptr = &client_cb.parent,
>  };
>  
> -const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
> +const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
>  
>  static
>  struct lttng_channel *_channel_create(const char *name,
> diff --git a/liblttng-ust/lttng-ring-buffer-metadata-client.h b/liblttng-ust/lttng-ring-buffer-metadata-client.h
> index 89f2620..0d2a1f8 100644
> --- a/liblttng-ust/lttng-ring-buffer-metadata-client.h
> +++ b/liblttng-ust/lttng-ring-buffer-metadata-client.h
> @@ -61,6 +61,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
>  }
>  
>  #include "../libringbuffer/api.h"
> +#include "lttng-rb-clients.h"
>  
>  static uint64_t client_ring_buffer_clock_read(struct channel *chan)
>  {
> @@ -153,6 +154,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf,
>  {
>  }
>  
> +static const
> +struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
> +	.parent = {
> +		.ring_buffer_clock_read = client_ring_buffer_clock_read,
> +		.record_header_size = client_record_header_size,
> +		.subbuffer_header_size = client_packet_header_size,
> +		.buffer_begin = client_buffer_begin,
> +		.buffer_end = client_buffer_end,
> +		.buffer_create = client_buffer_create,
> +		.buffer_finalize = client_buffer_finalize,
> +	},
> +};
> +
>  static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
>  	.cb.record_header_size = client_record_header_size,
> @@ -172,9 +186,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.ipi = RING_BUFFER_NO_IPI_BARRIER,
>  	.wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
>  	.client_type = LTTNG_CLIENT_TYPE,
> +
> +	 .cb_ptr = &client_cb.parent,
>  };
>  
> -const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
> +const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
>  
>  static
>  struct lttng_channel *_channel_create(const char *name,
> -- 
> 1.7.10.4
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [UST PATCH 2/2] LTTng ringbuffer ABI calls for index generation
       [not found] ` <1376678386-18607-2-git-send-email-jdesfossez@efficios.com>
@ 2013-08-16 18:53   ` Mathieu Desnoyers
  0 siblings, 0 replies; 9+ messages in thread
From: Mathieu Desnoyers @ 2013-08-16 18:53 UTC (permalink / raw)
  To: Julien Desfossez; +Cc: lttng-dev

* Julien Desfossez (jdesfossez@efficios.com) wrote:
> These new calls export the data required for the consumer to
> generate the index while tracing :
> - timestamp begin
> - timestamp end
> - events discarded
> - context size
> - packet size
> - stream id

technically good. A few style "nits" below.

> 
> Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
> ---
>  include/lttng/ust-ctl.h                 |   14 ++++
>  liblttng-ust-ctl/ustctl.c               |  125 +++++++++++++++++++++++++++++++
>  liblttng-ust/lttng-rb-clients.h         |   19 +++++
>  liblttng-ust/lttng-ring-buffer-client.h |   91 ++++++++++++++++++++++
>  4 files changed, 249 insertions(+)
> 
> diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h
> index 3c81e50..88112ad 100644
> --- a/include/lttng/ust-ctl.h
> +++ b/include/lttng/ust-ctl.h
> @@ -220,6 +220,20 @@ int ustctl_put_subbuf(struct ustctl_consumer_stream *stream);
>  void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
>  		int producer_active);
>  
> +/* index */
> +int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream,
> +		uint64_t *timestamp_begin);
> +int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream,
> +	uint64_t *timestamp_end);
> +int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream,
> +	uint64_t *events_discarded);
> +int ustctl_get_content_size(struct ustctl_consumer_stream *stream,
> +	uint64_t *content_size);
> +int ustctl_get_packet_size(struct ustctl_consumer_stream *stream,
> +	uint64_t *packet_size);
> +int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
> +		uint64_t *stream_id);
> +
>  /* event registry management */
>  
>  enum ustctl_socket_type {
> diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c
> index 28dee5e..9255416 100644
> --- a/liblttng-ust-ctl/ustctl.c
> +++ b/liblttng-ust-ctl/ustctl.c
> @@ -31,6 +31,7 @@
>  #include "../libringbuffer/backend.h"
>  #include "../libringbuffer/frontend.h"
>  #include "../liblttng-ust/wait.h"
> +#include "../liblttng-ust/lttng-rb-clients.h"
>  
>  /*
>   * Number of milliseconds to retry before failing metadata writes on
> @@ -1461,6 +1462,130 @@ void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
>  		consumer_chan->chan->handle);
>  }
>  
> +static
> +struct lttng_ust_client_lib_ring_buffer_client_cb *get_client_cb(
> +		struct lttng_ust_lib_ring_buffer *buf,
> +		struct lttng_ust_shm_handle *handle)
> +{
> +	struct channel *chan;
> +	const struct lttng_ust_lib_ring_buffer_config *config;
> +	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
> +

I'm tempted to just keep the empty line between declarations and code,
and remove other empty lines.

> +	chan = shmp(handle, buf->backend.chan);
> +	config = &chan->backend.config;
> +
> +	if (!config->cb_ptr)
> +		return NULL;
> +
> +	client_cb = caa_container_of(config->cb_ptr,
> +			struct lttng_ust_client_lib_ring_buffer_client_cb,
> +			parent);
> +
> +	return client_cb;
> +}
> +
> +int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream,
> +		uint64_t *timestamp_begin)
> +{
> +	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
> +	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
> +	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
> +

here too. (and others below)

> +	if (!stream || !timestamp_begin)
> +		return -EINVAL;
> +
> +	client_cb = get_client_cb(buf, handle);
> +	if (!client_cb)
> +		return -ENOSYS;
> +
> +	return client_cb->timestamp_begin(buf, handle, timestamp_begin);
> +}
> +
> +int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream,
> +	uint64_t *timestamp_end)
> +{
> +	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
> +	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
> +	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
> +
> +	if (!stream || !timestamp_end)
> +		return -EINVAL;
> +
> +	client_cb = get_client_cb(buf, handle);
> +	if (!client_cb)
> +		return -ENOSYS;
> +
> +	return client_cb->timestamp_end(buf, handle, timestamp_end);
> +}
> +
> +int ustctl_get_events_discarded(struct ustctl_consumer_stream *stream,
> +	uint64_t *events_discarded)
> +{
> +	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
> +	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
> +	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
> +
> +	if (!stream || !events_discarded)
> +		return -EINVAL;
> +
> +	client_cb = get_client_cb(buf, handle);
> +	if (!client_cb)
> +		return -ENOSYS;
> +
> +	return client_cb->events_discarded(buf, handle, events_discarded);
> +}
> +
> +int ustctl_get_content_size(struct ustctl_consumer_stream *stream,
> +	uint64_t *content_size)
> +{
> +	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
> +	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
> +	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
> +
> +	if (!stream || !content_size)
> +		return -EINVAL;
> +
> +	client_cb = get_client_cb(buf, handle);
> +	if (!client_cb)
> +		return -ENOSYS;
> +
> +	return client_cb->content_size(buf, handle, content_size);
> +}
> +
> +int ustctl_get_packet_size(struct ustctl_consumer_stream *stream,
> +	uint64_t *packet_size)
> +{
> +	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
> +	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
> +	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
> +
> +	if (!stream || !packet_size)
> +		return -EINVAL;
> +
> +	client_cb = get_client_cb(buf, handle);
> +	if (!client_cb)
> +		return -ENOSYS;
> +
> +	return client_cb->packet_size(buf, handle, packet_size);
> +}
> +
> +int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
> +		uint64_t *stream_id)
> +{
> +	struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
> +	struct lttng_ust_lib_ring_buffer *buf = stream->buf;
> +	struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
> +
> +	if (!stream || !stream_id)
> +		return -EINVAL;
> +
> +	client_cb = get_client_cb(buf, handle);
> +	if (!client_cb)
> +		return -ENOSYS;
> +
> +	return client_cb->stream_id(buf, handle, stream_id);
> +}
> +
>  /*
>   * Returns 0 on success, negative error value on error.
>   */
> diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
> index c9a1619..c43aa75 100644
> --- a/liblttng-ust/lttng-rb-clients.h
> +++ b/liblttng-ust/lttng-rb-clients.h
> @@ -21,6 +21,25 @@
>  
>  struct lttng_ust_client_lib_ring_buffer_client_cb {
>  	struct lttng_ust_lib_ring_buffer_client_cb parent;
> +
> +	int (*timestamp_begin) (struct lttng_ust_lib_ring_buffer *buf,
> +			struct lttng_ust_shm_handle *handle,
> +			uint64_t *timestamp_begin);
> +	int (*timestamp_end) (struct lttng_ust_lib_ring_buffer *buf,
> +			struct lttng_ust_shm_handle *handle,
> +			uint64_t *timestamp_end);
> +	int (*events_discarded) (struct lttng_ust_lib_ring_buffer *buf,
> +			struct lttng_ust_shm_handle *handle,
> +			uint64_t *events_discarded);
> +	int (*content_size) (struct lttng_ust_lib_ring_buffer *buf,
> +			struct lttng_ust_shm_handle *handle,
> +			uint64_t *content_size);
> +	int (*packet_size) (struct lttng_ust_lib_ring_buffer *buf,
> +			struct lttng_ust_shm_handle *handle,
> +			uint64_t *packet_size);
> +	int (*stream_id) (struct lttng_ust_lib_ring_buffer *buf,
> +			struct lttng_ust_shm_handle *handle,
> +			uint64_t *stream_id);
>  };
>  
>  #endif /* _LTTNG_RB_CLIENT_H */
> diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h
> index 383fce0..5ce672c 100644
> --- a/liblttng-ust/lttng-ring-buffer-client.h
> +++ b/liblttng-ust/lttng-ring-buffer-client.h
> @@ -386,6 +386,91 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
>  {
>  }
>  
> +static struct packet_header *client_packet_header(struct lttng_ust_lib_ring_buffer *buf,
> +		struct lttng_ust_shm_handle *handle)
> +{
> +	struct channel *chan = shmp(handle, buf->backend.chan);
> +	struct lttng_channel *lttng_chan = channel_get_private(chan);
> +	unsigned long sb_index;
> +	struct lttng_ust_lib_ring_buffer_backend *bufb;
> +	struct packet_header *header;
> +

here too.

> +	bufb = &buf->backend;
> +	sb_index = subbuffer_id_get_index(&lttng_chan->chan->backend.config,
> +			bufb->buf_rsb.id);
> +
> +	header = lib_ring_buffer_offset_address(bufb,
> +			sb_index * lttng_chan->chan->backend.subbuf_size,
> +			handle);
> +
> +	return header;
> +}
> +
> +static int client_timestamp_begin(struct lttng_ust_lib_ring_buffer *buf,
> +		struct lttng_ust_shm_handle *handle,
> +		uint64_t *timestamp_begin)
> +{
> +	struct packet_header *header = client_packet_header(buf, handle);
> +

here, I'm tempted to do the following:

struct packet_header *header;

header = client_packet_header(buf, handle);
*timestamp_begin = header->ctx.timestamp_begin;
return 0;

I don't enforce it strictly anywhere, but it's good IMO not to put
assignments on variable declarations when they are functions calls and
can possibly have side effects. It's then clear to the eye what is
declarations and what is "code".

So, e.g.:

 int myvar = somefct();

   -> ideally change into:

 int myvar;

 myvar = somefct();

However:

 int myvar = 5;

is fine, because the assignment cannot possible have side-effects.

The same applies to other functions below.

Thanks,

Mathieu

> +	*timestamp_begin = header->ctx.timestamp_begin;
> +
> +	return 0;
> +}
> +
> +static int client_timestamp_end(struct lttng_ust_lib_ring_buffer *buf,
> +		struct lttng_ust_shm_handle *handle,
> +		uint64_t *timestamp_end)
> +{
> +	struct packet_header *header = client_packet_header(buf, handle);
> +
> +	*timestamp_end = header->ctx.timestamp_end;
> +
> +	return 0;
> +}
> +
> +static int client_events_discarded(struct lttng_ust_lib_ring_buffer *buf,
> +		struct lttng_ust_shm_handle *handle,
> +		uint64_t *events_discarded)
> +{
> +	struct packet_header *header = client_packet_header(buf, handle);
> +
> +	*events_discarded = header->ctx.events_discarded;
> +
> +	return 0;
> +}
> +
> +static int client_content_size(struct lttng_ust_lib_ring_buffer *buf,
> +		struct lttng_ust_shm_handle *handle,
> +		uint64_t *content_size)
> +{
> +	struct packet_header *header = client_packet_header(buf, handle);
> +
> +	*content_size = header->ctx.content_size;
> +
> +	return 0;
> +}
> +
> +static int client_packet_size(struct lttng_ust_lib_ring_buffer *buf,
> +		struct lttng_ust_shm_handle *handle,
> +		uint64_t *packet_size)
> +{
> +	struct packet_header *header = client_packet_header(buf, handle);
> +
> +	*packet_size = header->ctx.packet_size;
> +
> +	return 0;
> +}
> +
> +static int client_stream_id(struct lttng_ust_lib_ring_buffer *buf,
> +		struct lttng_ust_shm_handle *handle,
> +		uint64_t *stream_id)
> +{
> +	struct packet_header *header = client_packet_header(buf, handle);
> +
> +	*stream_id = header->stream_id;
> +
> +	return 0;
> +}
>  static const
>  struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
>  	.parent = {
> @@ -397,6 +482,12 @@ struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
>  		.buffer_create = client_buffer_create,
>  		.buffer_finalize = client_buffer_finalize,
>  	},
> +	.timestamp_begin = client_timestamp_begin,
> +	.timestamp_end = client_timestamp_end,
> +	.events_discarded = client_events_discarded,
> +	.content_size = client_content_size,
> +	.packet_size = client_packet_size,
> +	.stream_id = client_stream_id,
>  };
>  
>  static const struct lttng_ust_lib_ring_buffer_config client_config = {
> -- 
> 1.7.10.4
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb
       [not found] <1376696166-32632-1-git-send-email-jdesfossez@efficios.com>
@ 2013-08-17  0:17 ` Mathieu Desnoyers
  0 siblings, 0 replies; 9+ messages in thread
From: Mathieu Desnoyers @ 2013-08-17  0:17 UTC (permalink / raw)
  To: Julien Desfossez; +Cc: lttng-dev

* Julien Desfossez (jdesfossez@efficios.com) wrote:
> Prepare the ring-buffer config to have custom callbacks. These custom
> callbacks are not related to the ring-buffer operations but allow
> applications to add custom functions.
> No additional feature or change in behaviour in this patch.
> 
> Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>

Thanks!

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

> ---
>  include/lttng/ringbuffer-config.h                |    4 +++-
>  include/lttng/ust-events.h                       |    6 ++---
>  liblttng-ust/Makefile.am                         |    1 +
>  liblttng-ust/lttng-rb-clients.h                  |   26 ++++++++++++++++++++++
>  liblttng-ust/lttng-ring-buffer-client.h          |   18 ++++++++++++++-
>  liblttng-ust/lttng-ring-buffer-metadata-client.h |   18 ++++++++++++++-
>  6 files changed, 67 insertions(+), 6 deletions(-)
>  create mode 100644 liblttng-ust/lttng-rb-clients.h
> 
> diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
> index 3b7d348..9de9a73 100644
> --- a/include/lttng/ringbuffer-config.h
> +++ b/include/lttng/ringbuffer-config.h
> @@ -133,7 +133,7 @@ struct lttng_ust_lib_ring_buffer_client_cb {
>   * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client
>   * has the responsibility to perform wakeups.
>   */
> -#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING	32
> +#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING	20
>  
>  enum lttng_ust_lib_ring_buffer_alloc_types {
>  	RING_BUFFER_ALLOC_PER_CPU,
> @@ -204,6 +204,8 @@ struct lttng_ust_lib_ring_buffer_config {
>  	 * callbacks and update the cb pointers.
>  	 */
>  	int client_type;
> +	int _unused1;
> +	const struct lttng_ust_lib_ring_buffer_client_cb *cb_ptr;
>  	char padding[LTTNG_UST_RING_BUFFER_CONFIG_PADDING];
>  };
>  
> diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
> index f40c044..74a3bc6 100644
> --- a/include/lttng/ust-events.h
> +++ b/include/lttng/ust-events.h
> @@ -569,9 +569,9 @@ int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
>  void lttng_context_vtid_reset(void);
>  void lttng_context_vpid_reset(void);
>  
> -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
> -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
> -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
> +extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
> +extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
> +extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
>  
>  struct lttng_transport *lttng_transport_find(const char *name);
>  
> diff --git a/liblttng-ust/Makefile.am b/liblttng-ust/Makefile.am
> index 1e6401a..5a43cf5 100644
> --- a/liblttng-ust/Makefile.am
> +++ b/liblttng-ust/Makefile.am
> @@ -47,6 +47,7 @@ liblttng_ust_support_la_SOURCES = \
>  	lttng-tracer.h \
>  	lttng-tracer-core.h \
>  	ust-core.c \
> +	lttng-rb-clients.h \
>  	lttng-ring-buffer-client.h \
>  	lttng-ring-buffer-client-discard.c \
>  	lttng-ring-buffer-client-discard-rt.c \
> diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
> new file mode 100644
> index 0000000..c9a1619
> --- /dev/null
> +++ b/liblttng-ust/lttng-rb-clients.h
> @@ -0,0 +1,26 @@
> +#ifndef _LTTNG_RB_CLIENT_H
> +#define _LTTNG_RB_CLIENT_H
> +
> +/*
> + * Copyright (c) 2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; only
> + * version 2.1 of the License.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +struct lttng_ust_client_lib_ring_buffer_client_cb {
> +	struct lttng_ust_lib_ring_buffer_client_cb parent;
> +};
> +
> +#endif /* _LTTNG_RB_CLIENT_H */
> diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h
> index 72b6d2c..383fce0 100644
> --- a/liblttng-ust/lttng-ring-buffer-client.h
> +++ b/liblttng-ust/lttng-ring-buffer-client.h
> @@ -161,6 +161,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
>  }
>  
>  #include "../libringbuffer/api.h"
> +#include "lttng-rb-clients.h"
>  
>  static
>  void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config *config,
> @@ -385,6 +386,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
>  {
>  }
>  
> +static const
> +struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
> +	.parent = {
> +		.ring_buffer_clock_read = client_ring_buffer_clock_read,
> +		.record_header_size = client_record_header_size,
> +		.subbuffer_header_size = client_packet_header_size,
> +		.buffer_begin = client_buffer_begin,
> +		.buffer_end = client_buffer_end,
> +		.buffer_create = client_buffer_create,
> +		.buffer_finalize = client_buffer_finalize,
> +	},
> +};
> +
>  static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
>  	.cb.record_header_size = client_record_header_size,
> @@ -404,9 +418,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.ipi = RING_BUFFER_NO_IPI_BARRIER,
>  	.wakeup = LTTNG_CLIENT_WAKEUP,
>  	.client_type = LTTNG_CLIENT_TYPE,
> +
> +	.cb_ptr = &client_cb.parent,
>  };
>  
> -const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
> +const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
>  
>  static
>  struct lttng_channel *_channel_create(const char *name,
> diff --git a/liblttng-ust/lttng-ring-buffer-metadata-client.h b/liblttng-ust/lttng-ring-buffer-metadata-client.h
> index 89f2620..0d2a1f8 100644
> --- a/liblttng-ust/lttng-ring-buffer-metadata-client.h
> +++ b/liblttng-ust/lttng-ring-buffer-metadata-client.h
> @@ -61,6 +61,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
>  }
>  
>  #include "../libringbuffer/api.h"
> +#include "lttng-rb-clients.h"
>  
>  static uint64_t client_ring_buffer_clock_read(struct channel *chan)
>  {
> @@ -153,6 +154,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf,
>  {
>  }
>  
> +static const
> +struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
> +	.parent = {
> +		.ring_buffer_clock_read = client_ring_buffer_clock_read,
> +		.record_header_size = client_record_header_size,
> +		.subbuffer_header_size = client_packet_header_size,
> +		.buffer_begin = client_buffer_begin,
> +		.buffer_end = client_buffer_end,
> +		.buffer_create = client_buffer_create,
> +		.buffer_finalize = client_buffer_finalize,
> +	},
> +};
> +
>  static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
>  	.cb.record_header_size = client_record_header_size,
> @@ -172,9 +186,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.ipi = RING_BUFFER_NO_IPI_BARRIER,
>  	.wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
>  	.client_type = LTTNG_CLIENT_TYPE,
> +
> +	 .cb_ptr = &client_cb.parent,
>  };
>  
> -const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
> +const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
>  
>  static
>  struct lttng_channel *_channel_create(const char *name,
> -- 
> 1.7.10.4
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb
@ 2013-08-16 23:36 Julien Desfossez
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Desfossez @ 2013-08-16 23:36 UTC (permalink / raw)
  To: mathieu.desnoyers; +Cc: lttng-dev, Julien Desfossez

Prepare the ring-buffer config to have custom callbacks. These custom
callbacks are not related to the ring-buffer operations but allow
applications to add custom functions.
No additional feature or change in behaviour in this patch.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
---
 include/lttng/ringbuffer-config.h                |    4 +++-
 include/lttng/ust-events.h                       |    6 ++---
 liblttng-ust/Makefile.am                         |    1 +
 liblttng-ust/lttng-rb-clients.h                  |   26 ++++++++++++++++++++++
 liblttng-ust/lttng-ring-buffer-client.h          |   18 ++++++++++++++-
 liblttng-ust/lttng-ring-buffer-metadata-client.h |   18 ++++++++++++++-
 6 files changed, 67 insertions(+), 6 deletions(-)
 create mode 100644 liblttng-ust/lttng-rb-clients.h

diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
index 3b7d348..9de9a73 100644
--- a/include/lttng/ringbuffer-config.h
+++ b/include/lttng/ringbuffer-config.h
@@ -133,7 +133,7 @@ struct lttng_ust_lib_ring_buffer_client_cb {
  * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client
  * has the responsibility to perform wakeups.
  */
-#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING	32
+#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING	20
 
 enum lttng_ust_lib_ring_buffer_alloc_types {
 	RING_BUFFER_ALLOC_PER_CPU,
@@ -204,6 +204,8 @@ struct lttng_ust_lib_ring_buffer_config {
 	 * callbacks and update the cb pointers.
 	 */
 	int client_type;
+	int _unused1;
+	const struct lttng_ust_lib_ring_buffer_client_cb *cb_ptr;
 	char padding[LTTNG_UST_RING_BUFFER_CONFIG_PADDING];
 };
 
diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
index f40c044..74a3bc6 100644
--- a/include/lttng/ust-events.h
+++ b/include/lttng/ust-events.h
@@ -569,9 +569,9 @@ int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
 void lttng_context_vtid_reset(void);
 void lttng_context_vpid_reset(void);
 
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
 
 struct lttng_transport *lttng_transport_find(const char *name);
 
diff --git a/liblttng-ust/Makefile.am b/liblttng-ust/Makefile.am
index 1e6401a..5a43cf5 100644
--- a/liblttng-ust/Makefile.am
+++ b/liblttng-ust/Makefile.am
@@ -47,6 +47,7 @@ liblttng_ust_support_la_SOURCES = \
 	lttng-tracer.h \
 	lttng-tracer-core.h \
 	ust-core.c \
+	lttng-rb-clients.h \
 	lttng-ring-buffer-client.h \
 	lttng-ring-buffer-client-discard.c \
 	lttng-ring-buffer-client-discard-rt.c \
diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
new file mode 100644
index 0000000..c9a1619
--- /dev/null
+++ b/liblttng-ust/lttng-rb-clients.h
@@ -0,0 +1,26 @@
+#ifndef _LTTNG_RB_CLIENT_H
+#define _LTTNG_RB_CLIENT_H
+
+/*
+ * Copyright (c) 2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+struct lttng_ust_client_lib_ring_buffer_client_cb {
+	struct lttng_ust_lib_ring_buffer_client_cb parent;
+};
+
+#endif /* _LTTNG_RB_CLIENT_H */
diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h
index 72b6d2c..383fce0 100644
--- a/liblttng-ust/lttng-ring-buffer-client.h
+++ b/liblttng-ust/lttng-ring-buffer-client.h
@@ -161,6 +161,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
 }
 
 #include "../libringbuffer/api.h"
+#include "lttng-rb-clients.h"
 
 static
 void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config *config,
@@ -385,6 +386,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
 {
 }
 
+static const
+struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
+	.parent = {
+		.ring_buffer_clock_read = client_ring_buffer_clock_read,
+		.record_header_size = client_record_header_size,
+		.subbuffer_header_size = client_packet_header_size,
+		.buffer_begin = client_buffer_begin,
+		.buffer_end = client_buffer_end,
+		.buffer_create = client_buffer_create,
+		.buffer_finalize = client_buffer_finalize,
+	},
+};
+
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
 	.cb.record_header_size = client_record_header_size,
@@ -404,9 +418,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.ipi = RING_BUFFER_NO_IPI_BARRIER,
 	.wakeup = LTTNG_CLIENT_WAKEUP,
 	.client_type = LTTNG_CLIENT_TYPE,
+
+	.cb_ptr = &client_cb.parent,
 };
 
-const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
+const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
 
 static
 struct lttng_channel *_channel_create(const char *name,
diff --git a/liblttng-ust/lttng-ring-buffer-metadata-client.h b/liblttng-ust/lttng-ring-buffer-metadata-client.h
index 89f2620..0d2a1f8 100644
--- a/liblttng-ust/lttng-ring-buffer-metadata-client.h
+++ b/liblttng-ust/lttng-ring-buffer-metadata-client.h
@@ -61,6 +61,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
 }
 
 #include "../libringbuffer/api.h"
+#include "lttng-rb-clients.h"
 
 static uint64_t client_ring_buffer_clock_read(struct channel *chan)
 {
@@ -153,6 +154,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf,
 {
 }
 
+static const
+struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
+	.parent = {
+		.ring_buffer_clock_read = client_ring_buffer_clock_read,
+		.record_header_size = client_record_header_size,
+		.subbuffer_header_size = client_packet_header_size,
+		.buffer_begin = client_buffer_begin,
+		.buffer_end = client_buffer_end,
+		.buffer_create = client_buffer_create,
+		.buffer_finalize = client_buffer_finalize,
+	},
+};
+
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
 	.cb.record_header_size = client_record_header_size,
@@ -172,9 +186,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.ipi = RING_BUFFER_NO_IPI_BARRIER,
 	.wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
 	.client_type = LTTNG_CLIENT_TYPE,
+
+	 .cb_ptr = &client_cb.parent,
 };
 
-const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
+const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
 
 static
 struct lttng_channel *_channel_create(const char *name,
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb
@ 2013-08-16 18:39 Julien Desfossez
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Desfossez @ 2013-08-16 18:39 UTC (permalink / raw)
  To: mathieu.desnoyers; +Cc: lttng-dev, Julien Desfossez

Prepare the ring-buffer config to have custom callbacks. These custom
callbacks are not related to the ring-buffer operations but allow
applications to add custom functions.
No additional feature or change in behaviour in this patch.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
---
 include/lttng/ringbuffer-config.h                |    4 +++-
 include/lttng/ust-events.h                       |    6 ++---
 liblttng-ust/Makefile.am                         |    1 +
 liblttng-ust/lttng-rb-clients.h                  |   26 ++++++++++++++++++++++
 liblttng-ust/lttng-ring-buffer-client.h          |   18 ++++++++++++++-
 liblttng-ust/lttng-ring-buffer-metadata-client.h |   18 ++++++++++++++-
 6 files changed, 67 insertions(+), 6 deletions(-)
 create mode 100644 liblttng-ust/lttng-rb-clients.h

diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
index 3b7d348..afb1310 100644
--- a/include/lttng/ringbuffer-config.h
+++ b/include/lttng/ringbuffer-config.h
@@ -133,7 +133,8 @@ struct lttng_ust_lib_ring_buffer_client_cb {
  * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client
  * has the responsibility to perform wakeups.
  */
-#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING	32
+#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING	\
+	(32 - sizeof(const struct lttng_ust_lib_ring_buffer_client_cb *))
 
 enum lttng_ust_lib_ring_buffer_alloc_types {
 	RING_BUFFER_ALLOC_PER_CPU,
@@ -204,6 +205,7 @@ struct lttng_ust_lib_ring_buffer_config {
 	 * callbacks and update the cb pointers.
 	 */
 	int client_type;
+	const struct lttng_ust_lib_ring_buffer_client_cb *cb_ptr;
 	char padding[LTTNG_UST_RING_BUFFER_CONFIG_PADDING];
 };
 
diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
index f40c044..74a3bc6 100644
--- a/include/lttng/ust-events.h
+++ b/include/lttng/ust-events.h
@@ -569,9 +569,9 @@ int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
 void lttng_context_vtid_reset(void);
 void lttng_context_vpid_reset(void);
 
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
 
 struct lttng_transport *lttng_transport_find(const char *name);
 
diff --git a/liblttng-ust/Makefile.am b/liblttng-ust/Makefile.am
index 1e6401a..5a43cf5 100644
--- a/liblttng-ust/Makefile.am
+++ b/liblttng-ust/Makefile.am
@@ -47,6 +47,7 @@ liblttng_ust_support_la_SOURCES = \
 	lttng-tracer.h \
 	lttng-tracer-core.h \
 	ust-core.c \
+	lttng-rb-clients.h \
 	lttng-ring-buffer-client.h \
 	lttng-ring-buffer-client-discard.c \
 	lttng-ring-buffer-client-discard-rt.c \
diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
new file mode 100644
index 0000000..c9a1619
--- /dev/null
+++ b/liblttng-ust/lttng-rb-clients.h
@@ -0,0 +1,26 @@
+#ifndef _LTTNG_RB_CLIENT_H
+#define _LTTNG_RB_CLIENT_H
+
+/*
+ * Copyright (c) 2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+struct lttng_ust_client_lib_ring_buffer_client_cb {
+	struct lttng_ust_lib_ring_buffer_client_cb parent;
+};
+
+#endif /* _LTTNG_RB_CLIENT_H */
diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h
index 72b6d2c..383fce0 100644
--- a/liblttng-ust/lttng-ring-buffer-client.h
+++ b/liblttng-ust/lttng-ring-buffer-client.h
@@ -161,6 +161,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
 }
 
 #include "../libringbuffer/api.h"
+#include "lttng-rb-clients.h"
 
 static
 void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config *config,
@@ -385,6 +386,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
 {
 }
 
+static const
+struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
+	.parent = {
+		.ring_buffer_clock_read = client_ring_buffer_clock_read,
+		.record_header_size = client_record_header_size,
+		.subbuffer_header_size = client_packet_header_size,
+		.buffer_begin = client_buffer_begin,
+		.buffer_end = client_buffer_end,
+		.buffer_create = client_buffer_create,
+		.buffer_finalize = client_buffer_finalize,
+	},
+};
+
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
 	.cb.record_header_size = client_record_header_size,
@@ -404,9 +418,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.ipi = RING_BUFFER_NO_IPI_BARRIER,
 	.wakeup = LTTNG_CLIENT_WAKEUP,
 	.client_type = LTTNG_CLIENT_TYPE,
+
+	.cb_ptr = &client_cb.parent,
 };
 
-const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
+const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
 
 static
 struct lttng_channel *_channel_create(const char *name,
diff --git a/liblttng-ust/lttng-ring-buffer-metadata-client.h b/liblttng-ust/lttng-ring-buffer-metadata-client.h
index 89f2620..0d2a1f8 100644
--- a/liblttng-ust/lttng-ring-buffer-metadata-client.h
+++ b/liblttng-ust/lttng-ring-buffer-metadata-client.h
@@ -61,6 +61,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
 }
 
 #include "../libringbuffer/api.h"
+#include "lttng-rb-clients.h"
 
 static uint64_t client_ring_buffer_clock_read(struct channel *chan)
 {
@@ -153,6 +154,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf,
 {
 }
 
+static const
+struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
+	.parent = {
+		.ring_buffer_clock_read = client_ring_buffer_clock_read,
+		.record_header_size = client_record_header_size,
+		.subbuffer_header_size = client_packet_header_size,
+		.buffer_begin = client_buffer_begin,
+		.buffer_end = client_buffer_end,
+		.buffer_create = client_buffer_create,
+		.buffer_finalize = client_buffer_finalize,
+	},
+};
+
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
 	.cb.record_header_size = client_record_header_size,
@@ -172,9 +186,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.ipi = RING_BUFFER_NO_IPI_BARRIER,
 	.wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
 	.client_type = LTTNG_CLIENT_TYPE,
+
+	 .cb_ptr = &client_cb.parent,
 };
 
-const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
+const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
 
 static
 struct lttng_channel *_channel_create(const char *name,
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb
       [not found] ` <20130815214936.GA24636@Krystal>
@ 2013-08-15 22:09   ` Mathieu Desnoyers
  0 siblings, 0 replies; 9+ messages in thread
From: Mathieu Desnoyers @ 2013-08-15 22:09 UTC (permalink / raw)
  To: Julien Desfossez; +Cc: lttng-dev

* Mathieu Desnoyers (mathieu.desnoyers@efficios.com) wrote:
> * Julien Desfossez (jdesfossez@efficios.com) wrote:
> > Prepare the ring-buffer config to have custom callbacks. These custom
> > callbacks are not related to the ring-buffer operations but allow
> > applications to add custom functions.
> > No additional feature or change in behaviour in this patch.
> > 
> > Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
> > ---
> >  include/lttng/ringbuffer-config.h                |    1 +
> >  include/lttng/ust-events.h                       |    6 +++---
> >  liblttng-ust/lttng-rb-clients.h                  |    8 ++++++++

Also, this new header file should be added to Makefile.am.

Thanks,

Mathieu

> >  liblttng-ust/lttng-ring-buffer-client.h          |   18 +++++++++++++++++-
> >  liblttng-ust/lttng-ring-buffer-metadata-client.h |   18 +++++++++++++++++-
> >  5 files changed, 46 insertions(+), 5 deletions(-)
> >  create mode 100644 liblttng-ust/lttng-rb-clients.h
> > 
> > diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
> > index 3b7d348..e81b827 100644
> > --- a/include/lttng/ringbuffer-config.h
> > +++ b/include/lttng/ringbuffer-config.h
> > @@ -204,6 +204,7 @@ struct lttng_ust_lib_ring_buffer_config {
> >  	 * callbacks and update the cb pointers.
> >  	 */
> >  	int client_type;
> > +	const struct lttng_ust_lib_ring_buffer_client_cb *cb_ptr;
> >  	char padding[LTTNG_UST_RING_BUFFER_CONFIG_PADDING];
> 
> we need to change the padding size.
> 
> >  };
> >  
> > diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
> > index f40c044..153c0ff 100644
> > --- a/include/lttng/ust-events.h
> > +++ b/include/lttng/ust-events.h
> > @@ -569,9 +569,9 @@ int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
> >  void lttng_context_vtid_reset(void);
> >  void lttng_context_vpid_reset(void);
> >  
> > -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
> > -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
> > -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
> > +extern const struct specialized_lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
> > +extern const struct specialized_lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
> > +extern const struct specialized_lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
> >  
> >  struct lttng_transport *lttng_transport_find(const char *name);
> >  
> > diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
> > new file mode 100644
> > index 0000000..37fd842
> > --- /dev/null
> > +++ b/liblttng-ust/lttng-rb-clients.h
> > @@ -0,0 +1,8 @@
> > +#ifndef _LTTNG_RB_CLIENT_H
> > +#define _LTTNG_RB_CLIENT_H
> 
> missing file copyright/license header.
> 
> > +
> > +struct specialized_lttng_ust_lib_ring_buffer_client_cb {
> 
> maybe we could find another name than "specialized" ?
> 
> Thanks,
> 
> Mathieu
> 
> > +	struct lttng_ust_lib_ring_buffer_client_cb parent;
> > +};
> > +
> > +#endif /* _LTTNG_RB_CLIENT_H */
> > diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h
> > index 72b6d2c..94db97e 100644
> > --- a/liblttng-ust/lttng-ring-buffer-client.h
> > +++ b/liblttng-ust/lttng-ring-buffer-client.h
> > @@ -161,6 +161,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
> >  }
> >  
> >  #include "../libringbuffer/api.h"
> > +#include "lttng-rb-clients.h"
> >  
> >  static
> >  void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config *config,
> > @@ -385,6 +386,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
> >  {
> >  }
> >  
> > +static const
> > +struct specialized_lttng_ust_lib_ring_buffer_client_cb client_cb = {
> > +	.parent = {
> > +		.ring_buffer_clock_read = client_ring_buffer_clock_read,
> > +		.record_header_size = client_record_header_size,
> > +		.subbuffer_header_size = client_packet_header_size,
> > +		.buffer_begin = client_buffer_begin,
> > +		.buffer_end = client_buffer_end,
> > +		.buffer_create = client_buffer_create,
> > +		.buffer_finalize = client_buffer_finalize,
> > +	},
> > +};
> > +
> >  static const struct lttng_ust_lib_ring_buffer_config client_config = {
> >  	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
> >  	.cb.record_header_size = client_record_header_size,
> > @@ -404,9 +418,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
> >  	.ipi = RING_BUFFER_NO_IPI_BARRIER,
> >  	.wakeup = LTTNG_CLIENT_WAKEUP,
> >  	.client_type = LTTNG_CLIENT_TYPE,
> > +
> > +	.cb_ptr = &client_cb.parent,
> >  };
> >  
> > -const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
> > +const struct specialized_lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
> >  
> >  static
> >  struct lttng_channel *_channel_create(const char *name,
> > diff --git a/liblttng-ust/lttng-ring-buffer-metadata-client.h b/liblttng-ust/lttng-ring-buffer-metadata-client.h
> > index 89f2620..5098f21 100644
> > --- a/liblttng-ust/lttng-ring-buffer-metadata-client.h
> > +++ b/liblttng-ust/lttng-ring-buffer-metadata-client.h
> > @@ -61,6 +61,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
> >  }
> >  
> >  #include "../libringbuffer/api.h"
> > +#include "lttng-rb-clients.h"
> >  
> >  static uint64_t client_ring_buffer_clock_read(struct channel *chan)
> >  {
> > @@ -153,6 +154,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf,
> >  {
> >  }
> >  
> > +static const
> > +struct specialized_lttng_ust_lib_ring_buffer_client_cb client_cb = {
> > +	.parent = {
> > +		.ring_buffer_clock_read = client_ring_buffer_clock_read,
> > +		.record_header_size = client_record_header_size,
> > +		.subbuffer_header_size = client_packet_header_size,
> > +		.buffer_begin = client_buffer_begin,
> > +		.buffer_end = client_buffer_end,
> > +		.buffer_create = client_buffer_create,
> > +		.buffer_finalize = client_buffer_finalize,
> > +	},
> > +};
> > +
> >  static const struct lttng_ust_lib_ring_buffer_config client_config = {
> >  	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
> >  	.cb.record_header_size = client_record_header_size,
> > @@ -172,9 +186,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
> >  	.ipi = RING_BUFFER_NO_IPI_BARRIER,
> >  	.wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
> >  	.client_type = LTTNG_CLIENT_TYPE,
> > +
> > +	 .cb_ptr = &client_cb.parent,
> >  };
> >  
> > -const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
> > +const struct specialized_lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
> >  
> >  static
> >  struct lttng_channel *_channel_create(const char *name,
> > -- 
> > 1.7.10.4
> > 
> 
> -- 
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb
       [not found] <1376603188-19344-1-git-send-email-jdesfossez@efficios.com>
@ 2013-08-15 21:49 ` Mathieu Desnoyers
       [not found] ` <20130815214936.GA24636@Krystal>
  1 sibling, 0 replies; 9+ messages in thread
From: Mathieu Desnoyers @ 2013-08-15 21:49 UTC (permalink / raw)
  To: Julien Desfossez; +Cc: lttng-dev

* Julien Desfossez (jdesfossez@efficios.com) wrote:
> Prepare the ring-buffer config to have custom callbacks. These custom
> callbacks are not related to the ring-buffer operations but allow
> applications to add custom functions.
> No additional feature or change in behaviour in this patch.
> 
> Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
> ---
>  include/lttng/ringbuffer-config.h                |    1 +
>  include/lttng/ust-events.h                       |    6 +++---
>  liblttng-ust/lttng-rb-clients.h                  |    8 ++++++++
>  liblttng-ust/lttng-ring-buffer-client.h          |   18 +++++++++++++++++-
>  liblttng-ust/lttng-ring-buffer-metadata-client.h |   18 +++++++++++++++++-
>  5 files changed, 46 insertions(+), 5 deletions(-)
>  create mode 100644 liblttng-ust/lttng-rb-clients.h
> 
> diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
> index 3b7d348..e81b827 100644
> --- a/include/lttng/ringbuffer-config.h
> +++ b/include/lttng/ringbuffer-config.h
> @@ -204,6 +204,7 @@ struct lttng_ust_lib_ring_buffer_config {
>  	 * callbacks and update the cb pointers.
>  	 */
>  	int client_type;
> +	const struct lttng_ust_lib_ring_buffer_client_cb *cb_ptr;
>  	char padding[LTTNG_UST_RING_BUFFER_CONFIG_PADDING];

we need to change the padding size.

>  };
>  
> diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
> index f40c044..153c0ff 100644
> --- a/include/lttng/ust-events.h
> +++ b/include/lttng/ust-events.h
> @@ -569,9 +569,9 @@ int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
>  void lttng_context_vtid_reset(void);
>  void lttng_context_vpid_reset(void);
>  
> -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
> -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
> -extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
> +extern const struct specialized_lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
> +extern const struct specialized_lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
> +extern const struct specialized_lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
>  
>  struct lttng_transport *lttng_transport_find(const char *name);
>  
> diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
> new file mode 100644
> index 0000000..37fd842
> --- /dev/null
> +++ b/liblttng-ust/lttng-rb-clients.h
> @@ -0,0 +1,8 @@
> +#ifndef _LTTNG_RB_CLIENT_H
> +#define _LTTNG_RB_CLIENT_H

missing file copyright/license header.

> +
> +struct specialized_lttng_ust_lib_ring_buffer_client_cb {

maybe we could find another name than "specialized" ?

Thanks,

Mathieu

> +	struct lttng_ust_lib_ring_buffer_client_cb parent;
> +};
> +
> +#endif /* _LTTNG_RB_CLIENT_H */
> diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h
> index 72b6d2c..94db97e 100644
> --- a/liblttng-ust/lttng-ring-buffer-client.h
> +++ b/liblttng-ust/lttng-ring-buffer-client.h
> @@ -161,6 +161,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
>  }
>  
>  #include "../libringbuffer/api.h"
> +#include "lttng-rb-clients.h"
>  
>  static
>  void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config *config,
> @@ -385,6 +386,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
>  {
>  }
>  
> +static const
> +struct specialized_lttng_ust_lib_ring_buffer_client_cb client_cb = {
> +	.parent = {
> +		.ring_buffer_clock_read = client_ring_buffer_clock_read,
> +		.record_header_size = client_record_header_size,
> +		.subbuffer_header_size = client_packet_header_size,
> +		.buffer_begin = client_buffer_begin,
> +		.buffer_end = client_buffer_end,
> +		.buffer_create = client_buffer_create,
> +		.buffer_finalize = client_buffer_finalize,
> +	},
> +};
> +
>  static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
>  	.cb.record_header_size = client_record_header_size,
> @@ -404,9 +418,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.ipi = RING_BUFFER_NO_IPI_BARRIER,
>  	.wakeup = LTTNG_CLIENT_WAKEUP,
>  	.client_type = LTTNG_CLIENT_TYPE,
> +
> +	.cb_ptr = &client_cb.parent,
>  };
>  
> -const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
> +const struct specialized_lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
>  
>  static
>  struct lttng_channel *_channel_create(const char *name,
> diff --git a/liblttng-ust/lttng-ring-buffer-metadata-client.h b/liblttng-ust/lttng-ring-buffer-metadata-client.h
> index 89f2620..5098f21 100644
> --- a/liblttng-ust/lttng-ring-buffer-metadata-client.h
> +++ b/liblttng-ust/lttng-ring-buffer-metadata-client.h
> @@ -61,6 +61,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
>  }
>  
>  #include "../libringbuffer/api.h"
> +#include "lttng-rb-clients.h"
>  
>  static uint64_t client_ring_buffer_clock_read(struct channel *chan)
>  {
> @@ -153,6 +154,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf,
>  {
>  }
>  
> +static const
> +struct specialized_lttng_ust_lib_ring_buffer_client_cb client_cb = {
> +	.parent = {
> +		.ring_buffer_clock_read = client_ring_buffer_clock_read,
> +		.record_header_size = client_record_header_size,
> +		.subbuffer_header_size = client_packet_header_size,
> +		.buffer_begin = client_buffer_begin,
> +		.buffer_end = client_buffer_end,
> +		.buffer_create = client_buffer_create,
> +		.buffer_finalize = client_buffer_finalize,
> +	},
> +};
> +
>  static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
>  	.cb.record_header_size = client_record_header_size,
> @@ -172,9 +186,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
>  	.ipi = RING_BUFFER_NO_IPI_BARRIER,
>  	.wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
>  	.client_type = LTTNG_CLIENT_TYPE,
> +
> +	 .cb_ptr = &client_cb.parent,
>  };
>  
> -const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
> +const struct specialized_lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
>  
>  static
>  struct lttng_channel *_channel_create(const char *name,
> -- 
> 1.7.10.4
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb
@ 2013-08-15 21:46 Julien Desfossez
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Desfossez @ 2013-08-15 21:46 UTC (permalink / raw)
  To: mathieu.desnoyers; +Cc: lttng-dev, Julien Desfossez

Prepare the ring-buffer config to have custom callbacks. These custom
callbacks are not related to the ring-buffer operations but allow
applications to add custom functions.
No additional feature or change in behaviour in this patch.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
---
 include/lttng/ringbuffer-config.h                |    1 +
 include/lttng/ust-events.h                       |    6 +++---
 liblttng-ust/lttng-rb-clients.h                  |    8 ++++++++
 liblttng-ust/lttng-ring-buffer-client.h          |   18 +++++++++++++++++-
 liblttng-ust/lttng-ring-buffer-metadata-client.h |   18 +++++++++++++++++-
 5 files changed, 46 insertions(+), 5 deletions(-)
 create mode 100644 liblttng-ust/lttng-rb-clients.h

diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h
index 3b7d348..e81b827 100644
--- a/include/lttng/ringbuffer-config.h
+++ b/include/lttng/ringbuffer-config.h
@@ -204,6 +204,7 @@ struct lttng_ust_lib_ring_buffer_config {
 	 * callbacks and update the cb pointers.
 	 */
 	int client_type;
+	const struct lttng_ust_lib_ring_buffer_client_cb *cb_ptr;
 	char padding[LTTNG_UST_RING_BUFFER_CONFIG_PADDING];
 };
 
diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
index f40c044..153c0ff 100644
--- a/include/lttng/ust-events.h
+++ b/include/lttng/ust-events.h
@@ -569,9 +569,9 @@ int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
 void lttng_context_vtid_reset(void);
 void lttng_context_vpid_reset(void);
 
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
+extern const struct specialized_lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
+extern const struct specialized_lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
+extern const struct specialized_lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
 
 struct lttng_transport *lttng_transport_find(const char *name);
 
diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
new file mode 100644
index 0000000..37fd842
--- /dev/null
+++ b/liblttng-ust/lttng-rb-clients.h
@@ -0,0 +1,8 @@
+#ifndef _LTTNG_RB_CLIENT_H
+#define _LTTNG_RB_CLIENT_H
+
+struct specialized_lttng_ust_lib_ring_buffer_client_cb {
+	struct lttng_ust_lib_ring_buffer_client_cb parent;
+};
+
+#endif /* _LTTNG_RB_CLIENT_H */
diff --git a/liblttng-ust/lttng-ring-buffer-client.h b/liblttng-ust/lttng-ring-buffer-client.h
index 72b6d2c..94db97e 100644
--- a/liblttng-ust/lttng-ring-buffer-client.h
+++ b/liblttng-ust/lttng-ring-buffer-client.h
@@ -161,6 +161,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
 }
 
 #include "../libringbuffer/api.h"
+#include "lttng-rb-clients.h"
 
 static
 void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config *config,
@@ -385,6 +386,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
 {
 }
 
+static const
+struct specialized_lttng_ust_lib_ring_buffer_client_cb client_cb = {
+	.parent = {
+		.ring_buffer_clock_read = client_ring_buffer_clock_read,
+		.record_header_size = client_record_header_size,
+		.subbuffer_header_size = client_packet_header_size,
+		.buffer_begin = client_buffer_begin,
+		.buffer_end = client_buffer_end,
+		.buffer_create = client_buffer_create,
+		.buffer_finalize = client_buffer_finalize,
+	},
+};
+
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
 	.cb.record_header_size = client_record_header_size,
@@ -404,9 +418,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.ipi = RING_BUFFER_NO_IPI_BARRIER,
 	.wakeup = LTTNG_CLIENT_WAKEUP,
 	.client_type = LTTNG_CLIENT_TYPE,
+
+	.cb_ptr = &client_cb.parent,
 };
 
-const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
+const struct specialized_lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
 
 static
 struct lttng_channel *_channel_create(const char *name,
diff --git a/liblttng-ust/lttng-ring-buffer-metadata-client.h b/liblttng-ust/lttng-ring-buffer-metadata-client.h
index 89f2620..5098f21 100644
--- a/liblttng-ust/lttng-ring-buffer-metadata-client.h
+++ b/liblttng-ust/lttng-ring-buffer-metadata-client.h
@@ -61,6 +61,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
 }
 
 #include "../libringbuffer/api.h"
+#include "lttng-rb-clients.h"
 
 static uint64_t client_ring_buffer_clock_read(struct channel *chan)
 {
@@ -153,6 +154,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf,
 {
 }
 
+static const
+struct specialized_lttng_ust_lib_ring_buffer_client_cb client_cb = {
+	.parent = {
+		.ring_buffer_clock_read = client_ring_buffer_clock_read,
+		.record_header_size = client_record_header_size,
+		.subbuffer_header_size = client_packet_header_size,
+		.buffer_begin = client_buffer_begin,
+		.buffer_end = client_buffer_end,
+		.buffer_create = client_buffer_create,
+		.buffer_finalize = client_buffer_finalize,
+	},
+};
+
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
 	.cb.record_header_size = client_record_header_size,
@@ -172,9 +186,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
 	.ipi = RING_BUFFER_NO_IPI_BARRIER,
 	.wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
 	.client_type = LTTNG_CLIENT_TYPE,
+
+	 .cb_ptr = &client_cb.parent,
 };
 
-const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
+const struct specialized_lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
 
 static
 struct lttng_channel *_channel_create(const char *name,
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-08-17  0:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1376678386-18607-1-git-send-email-jdesfossez@efficios.com>
2013-08-16 18:39 ` [UST PATCH 2/2] LTTng ringbuffer ABI calls for index generation Julien Desfossez
2013-08-16 18:47 ` [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb Mathieu Desnoyers
     [not found] ` <1376678386-18607-2-git-send-email-jdesfossez@efficios.com>
2013-08-16 18:53   ` [UST PATCH 2/2] LTTng ringbuffer ABI calls for index generation Mathieu Desnoyers
     [not found] <1376696166-32632-1-git-send-email-jdesfossez@efficios.com>
2013-08-17  0:17 ` [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb Mathieu Desnoyers
2013-08-16 23:36 Julien Desfossez
  -- strict thread matches above, loose matches on Subject: below --
2013-08-16 18:39 Julien Desfossez
     [not found] <1376603188-19344-1-git-send-email-jdesfossez@efficios.com>
2013-08-15 21:49 ` Mathieu Desnoyers
     [not found] ` <20130815214936.GA24636@Krystal>
2013-08-15 22:09   ` Mathieu Desnoyers
2013-08-15 21:46 Julien Desfossez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.