[lttng-dev] [RFC PATCH lttng-tools 07/18] Add serialized versions of lttng_channel structs

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Thu Apr 18 15:38:41 EDT 2019


----- On Apr 18, 2019, at 12:18 PM, Yannick Lamarre ylamarre at efficios.com wrote:

> Serialized versions of lttng_channel and lttng_channel_extended are
> packed structures to be used in communication protocols for consistent
> sizes across platforms. The serialized versions are stripped of pointers
> and padding.
> 
> Pointers are removed since their size can vary on platforms supporting
> variable sized registers (x86-64).

I don't understand this explanation. I think it's mostly that we have
situations where x86-32 processes interact with x86-64 processes, and
since this is within a communication protocol between processes over
unix socket, it breaks because of pointer size mismatch.

> Padding is also removed since it defeats the purpose of a packed struct.

Not necessarily. Padding was how we extend each command as the protocol evolves.
If we remove padding, how do we plan to extend those in the future ? This commit
documentat how we plan to extend those from now on.

Thanks,

Mathieu


> 
> Signed-off-by: Yannick Lamarre <ylamarre at efficios.com>
> ---
> include/lttng/channel-internal.h | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
> 
> diff --git a/include/lttng/channel-internal.h b/include/lttng/channel-internal.h
> index 030b4701..c956c19d 100644
> --- a/include/lttng/channel-internal.h
> +++ b/include/lttng/channel-internal.h
> @@ -20,11 +20,41 @@
> 
> #include <common/macros.h>
> 
> +struct lttng_channel_attr_serialized {
> +	int overwrite;                      /* -1: session default, 1: overwrite, 0:
> discard */
> +	uint64_t subbuf_size;               /* bytes, power of 2 */
> +	uint64_t num_subbuf;                /* power of 2 */
> +	unsigned int switch_timer_interval; /* usec */
> +	unsigned int read_timer_interval;   /* usec */
> +	uint32_t output; /* enum lttng_event_output */
> +	/* LTTng 2.1 padding limit */
> +	uint64_t tracefile_size;            /* bytes */
> +	uint64_t tracefile_count;           /* number of tracefiles */
> +	/* LTTng 2.3 padding limit */
> +	unsigned int live_timer_interval;   /* usec */
> +	/* LTTng 2.7 padding limit */
> +
> +} LTTNG_PACKED;
> +
> +struct lttng_channel_serialized {
> +	char name[LTTNG_SYMBOL_NAME_LEN];
> +	uint32_t enabled;
> +	struct lttng_channel_attr_serialized attr;
> +
> +} LTTNG_PACKED;
> +
> struct lttng_channel_extended {
> 	uint64_t discarded_events;
> 	uint64_t lost_packets;
> 	uint64_t monitor_timer_interval;
> 	int64_t blocking_timeout;
> +};
> +
> +struct lttng_channel_extended_serialized {
> +	uint64_t discarded_events;
> +	uint64_t lost_packets;
> +	uint64_t monitor_timer_interval;
> +	int64_t blocking_timeout;
> } LTTNG_PACKED;
> 
> #endif /* LTTNG_CHANNEL_INTERNAL_H */
> --
> 2.11.0
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> https://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