From: Mathieu Desnoyers Date: Wed, 20 Apr 2016 15:19:58 +0000 (-0400) Subject: Allow channel mode override in snapshot sessions X-Git-Tag: v2.9.0-rc1~121 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8d5841ea483139d3ab2f2b4dd39263dad63832b1;p=lttng-tools.git Allow channel mode override in snapshot sessions Allow the lttng cmd line and liblttng-ctl users to override the channel mode in snapshot sessions. Note that liblttng-ctl users expecting that an "overwrite" mode explicitly set at the value "0" (discard) for a snapshot session will now create a channel in discard mode. The DEFAULT_CHANNEL_OVERWRITE used by liblttng-ctl lttng_channel_set_default_attr() is changed to "-1". Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/channel.h b/include/lttng/channel.h index 622ce85e9..732074c3a 100644 --- a/include/lttng/channel.h +++ b/include/lttng/channel.h @@ -33,7 +33,7 @@ extern "C" { */ #define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 12 struct lttng_channel_attr { - int overwrite; /* 1: overwrite, 0: discard */ + 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 */ diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index f35410e3a..88480c4b4 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -214,9 +214,16 @@ int channel_kernel_create(struct ltt_kernel_session *ksession, attr = defattr; } + /* + * Set the overwrite mode for this channel based on the session + * type unless the client explicitly overrides the channel mode. + */ + if (attr->attr.overwrite == DEFAULT_CHANNEL_OVERWRITE) { + attr->attr.overwrite = !!ksession->snapshot_mode; + } + + /* Enforce mmap output for snapshot sessions. */ if (ksession->snapshot_mode) { - /* Force channel attribute for snapshot mode. */ - attr->attr.overwrite = 1; attr->attr.output = LTTNG_EVENT_MMAP; } @@ -318,9 +325,16 @@ int channel_ust_create(struct ltt_ust_session *usess, } } + /* + * Set the overwrite mode for this channel based on the session + * type unless the client explicitly overrides the channel mode. + */ + if (attr->attr.overwrite == DEFAULT_CHANNEL_OVERWRITE) { + attr->attr.overwrite = !!usess->snapshot_mode; + } + + /* Enforce mmap output for snapshot sessions. */ if (usess->snapshot_mode) { - /* Force channel attribute for snapshot mode. */ - attr->attr.overwrite = 1; attr->attr.output = LTTNG_EVENT_MMAP; } diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index 3379a3b27..0ae2b1096 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -439,7 +439,7 @@ static int create_session(void) MSG("Default snapshot output set to: %s", print_str_url); } MSG("Snapshot mode set. Every channel enabled for that session will " - "be set in overwrite mode and mmap output."); + "be set to mmap output, and default to overwrite mode."); } if (opt_shm_path) { MSG("Session %s set to shm_path: %s.", session_name, diff --git a/src/common/defaults.h b/src/common/defaults.h index 59fe8ec46..f05030766 100644 --- a/src/common/defaults.h +++ b/src/common/defaults.h @@ -188,7 +188,7 @@ #define DEFAULT_PYTHON_EVENT_COMPONENT "lttng_python" #define DEFAULT_PYTHON_EVENT_NAME DEFAULT_PYTHON_EVENT_COMPONENT ":*" -#define DEFAULT_CHANNEL_OVERWRITE 0 +#define DEFAULT_CHANNEL_OVERWRITE -1 #define DEFAULT_CHANNEL_TRACEFILE_SIZE CONFIG_DEFAULT_CHANNEL_TRACEFILE_SIZE #define DEFAULT_CHANNEL_TRACEFILE_COUNT CONFIG_DEFAULT_CHANNEL_TRACEFILE_COUNT