From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers)
Subject: [lttng-dev] [PATCH lttng-tools 2/4] Allow channel mode override in snapshot sessions
Date: Wed, 20 Apr 2016 11:19:58 -0400 [thread overview]
Message-ID: <1461165600-17288-3-git-send-email-mathieu.desnoyers@efficios.com> (raw)
In-Reply-To: <1461165600-17288-1-git-send-email-mathieu.desnoyers@efficios.com>
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 <mathieu.desnoyers at efficios.com>
---
include/lttng/channel.h | 2 +-
src/bin/lttng-sessiond/channel.c | 30 ++++++++++++++++++++++++++----
src/bin/lttng/commands/create.c | 2 +-
src/common/defaults.h | 2 +-
4 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/include/lttng/channel.h b/include/lttng/channel.h
index 622ce85..732074c 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 0119abf..7bb0ff7 100644
--- a/src/bin/lttng-sessiond/channel.c
+++ b/src/bin/lttng-sessiond/channel.c
@@ -214,9 +214,20 @@ 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) {
+ if (ksession->snapshot_mode) {
+ attr->attr.overwrite = 1;
+ } else {
+ attr->attr.overwrite = 0;
+ }
+ }
+
+ /* 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 +329,20 @@ 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) {
+ if (usess->snapshot_mode) {
+ attr->attr.overwrite = 1;
+ } else {
+ attr->attr.overwrite = 0;
+ }
+ }
+
+ /* 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 525464a..d8e4da4 100644
--- a/src/bin/lttng/commands/create.c
+++ b/src/bin/lttng/commands/create.c
@@ -442,7 +442,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 6e343b5..fc48ff9 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 0
#define DEFAULT_CHANNEL_TRACEFILE_COUNT 0
--
2.1.4
next prev parent reply other threads:[~2016-04-20 15:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-20 15:19 [lttng-dev] [PATCH lttng-tools 0/4] Allow discard buffers " Mathieu Desnoyers
2016-04-20 15:19 ` [lttng-dev] [PATCH lttng-tools 1/4] Fix: validate number of subbuffers after tweaking properties Mathieu Desnoyers
2016-04-20 15:19 ` Mathieu Desnoyers [this message]
2016-04-20 15:19 ` [lttng-dev] [PATCH lttng-tools 3/4] tests: test kernel snapshot with discard buffers Mathieu Desnoyers
2016-04-20 15:20 ` [lttng-dev] [PATCH lttng-tools 4/4] tests: test ust " Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461165600-17288-3-git-send-email-mathieu.desnoyers@efficios.com \
--to=mathieu.desnoyers@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox