[lttng-dev] [UST PATCH 1/2] Specialize lttng_ust_lib_ring_buffer_client_cb

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Thu Aug 15 18:09:44 EDT 2013


* Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
> * Julien Desfossez (jdesfossez at 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 at 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 at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

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



More information about the lttng-dev mailing list