Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [lttng-dev] [PATCH lttng-tools 00/10] Fix: tracefile rotation rm-after-destroy race
@ 2016-05-18 18:04 Mathieu Desnoyers
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 06/10] Fix: error.h: add missing parenthesis around macro parameter Mathieu Desnoyers
                   ` (9 more replies)
  0 siblings, 10 replies; 16+ messages in thread
From: Mathieu Desnoyers @ 2016-05-18 18:04 UTC (permalink / raw)


Mathieu Desnoyers (10):
  Fix: bad file descriptors on close after rotation error
  Fix: UST should not generate packet at destroy after stop
  Fix: kernel tracing: flush after stop
  Fix: ust-consumer: flush empty packets on snapshot channel
  Fix: bogus mask on error.h PRINT types
  Fix: error.h: add missing parenthesis around macro parameter
  Fix: WARN() should print as WARN level, not ERR
  Add environment variable to allow abort on error
  test: kernel tracing destroy flush behavior with tracefile rotation
  test: UST tracing destroy flush behavior with tracefile rotation

 configure.ac                                       |   1 +
 doc/man/common-cmd-footer.txt                      |   3 +
 doc/man/lttng-relayd.8.txt                         |   3 +
 doc/man/lttng-sessiond.8.txt                       |   2 +
 src/bin/lttng-sessiond/cmd.c                       |  20 +--
 src/bin/lttng-sessiond/consumer.c                  |  32 +++++
 src/bin/lttng-sessiond/consumer.h                  |   1 +
 src/bin/lttng-sessiond/ust-app.c                   | 140 +++++++++++++++++++
 src/common/consumer/consumer.h                     |  11 ++
 src/common/error.c                                 |  28 ++++
 src/common/error.h                                 |  33 +++--
 src/common/sessiond-comm/sessiond-comm.h           |   3 +
 src/common/ust-consumer/ust-consumer.c             |  75 +++++++++-
 src/common/utils.c                                 |   1 +
 tests/fast_regression                              |   1 +
 tests/regression/kernel/Makefile.am                |   3 +-
 .../regression/kernel/test_rotation_destroy_flush  | 153 +++++++++++++++++++++
 tests/regression/ust/Makefile.am                   |   3 +-
 .../ust/rotation-destroy-flush/Makefile.am         |  16 +++
 .../test_rotation_destroy_flush                    | 150 ++++++++++++++++++++
 tests/root_regression                              |   1 +
 21 files changed, 651 insertions(+), 29 deletions(-)
 create mode 100755 tests/regression/kernel/test_rotation_destroy_flush
 create mode 100644 tests/regression/ust/rotation-destroy-flush/Makefile.am
 create mode 100755 tests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush

-- 
2.1.4



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

* [lttng-dev] [PATCH lttng-tools 06/10] Fix: error.h: add missing parenthesis around macro parameter
  2016-05-18 18:04 [lttng-dev] [PATCH lttng-tools 00/10] Fix: tracefile rotation rm-after-destroy race Mathieu Desnoyers
@ 2016-05-18 18:04 ` Mathieu Desnoyers
  2016-05-19  4:13   ` Jérémie Galarneau
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 07/10] Fix: WARN() should print as WARN level, not ERR Mathieu Desnoyers
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Mathieu Desnoyers @ 2016-05-18 18:04 UTC (permalink / raw)


Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 src/common/error.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/common/error.h b/src/common/error.h
index 3ab1d46..ca5af86 100644
--- a/src/common/error.h
+++ b/src/common/error.h
@@ -75,18 +75,18 @@ extern int lttng_opt_mi;
  */
 #define __lttng_print(type, fmt, args...)                                          \
 	do {                                                                       \
-		if (!lttng_opt_quiet&& !lttng_opt_mi &&                            \
-				type == PRINT_MSG) {                               \
+		if (!lttng_opt_quiet && !lttng_opt_mi &&                           \
+				(type) == PRINT_MSG) {                             \
 			fprintf(stdout, fmt, ## args);                             \
 		} else if (!lttng_opt_quiet && !lttng_opt_mi &&                    \
-				(((type & PRINT_DBG) && lttng_opt_verbose == 1) || \
-				((type & (PRINT_DBG | PRINT_DBG2)) &&              \
+				((((type) & PRINT_DBG) && lttng_opt_verbose == 1) || \
+				(((type) & (PRINT_DBG | PRINT_DBG2)) &&            \
 					lttng_opt_verbose == 2) ||                 \
-				((type & (PRINT_DBG | PRINT_DBG2 | PRINT_DBG3)) && \
+				(((type) & (PRINT_DBG | PRINT_DBG2 | PRINT_DBG3)) && \
 					lttng_opt_verbose == 3))) {                \
 			fprintf(stderr, fmt, ## args);                             \
 		} else if (!lttng_opt_quiet &&                                     \
-				(type & (PRINT_WARN | PRINT_ERR | PRINT_BUG))) {   \
+				((type) & (PRINT_WARN | PRINT_ERR | PRINT_BUG))) { \
 			fprintf(stderr, fmt, ## args);                             \
 		}                                                                  \
 	} while (0);
-- 
2.1.4



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

* [lttng-dev] [PATCH lttng-tools 07/10] Fix: WARN() should print as WARN level, not ERR
  2016-05-18 18:04 [lttng-dev] [PATCH lttng-tools 00/10] Fix: tracefile rotation rm-after-destroy race Mathieu Desnoyers
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 06/10] Fix: error.h: add missing parenthesis around macro parameter Mathieu Desnoyers
@ 2016-05-18 18:04 ` Mathieu Desnoyers
  2016-05-19  4:14   ` Jérémie Galarneau
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 08/10] Add environment variable to allow abort on error Mathieu Desnoyers
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Mathieu Desnoyers @ 2016-05-18 18:04 UTC (permalink / raw)


Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 src/common/error.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/common/error.h b/src/common/error.h
index ca5af86..9c9d2a7 100644
--- a/src/common/error.h
+++ b/src/common/error.h
@@ -103,7 +103,7 @@ extern int lttng_opt_mi;
 #define ERR(fmt, args...) \
 	__lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args)
 #define WARN(fmt, args...) \
-	__lttng_print(PRINT_ERR, "Warning: " fmt "\n", ## args)
+	__lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args)
 
 #define BUG(fmt, args...) _ERRMSG("BUG", PRINT_BUG, fmt, ## args)
 
-- 
2.1.4



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

* [lttng-dev] [PATCH lttng-tools 08/10] Add environment variable to allow abort on error
  2016-05-18 18:04 [lttng-dev] [PATCH lttng-tools 00/10] Fix: tracefile rotation rm-after-destroy race Mathieu Desnoyers
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 06/10] Fix: error.h: add missing parenthesis around macro parameter Mathieu Desnoyers
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 07/10] Fix: WARN() should print as WARN level, not ERR Mathieu Desnoyers
@ 2016-05-18 18:04 ` Mathieu Desnoyers
  2016-05-19  4:45   ` Jérémie Galarneau
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 09/10] test: kernel tracing destroy flush behavior with tracefile rotation Mathieu Desnoyers
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Mathieu Desnoyers @ 2016-05-18 18:04 UTC (permalink / raw)


The new environment variable LTTNG_ABORT_ON_ERROR allows each
lttng-tools program to call abort() on PERROR() and ERR() after the
error message has been printed to stderr.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 doc/man/common-cmd-footer.txt |  3 +++
 doc/man/lttng-relayd.8.txt    |  3 +++
 doc/man/lttng-sessiond.8.txt  |  2 ++
 src/common/error.c            | 28 ++++++++++++++++++++++++++++
 src/common/error.h            |  5 +++++
 5 files changed, 41 insertions(+)

diff --git a/doc/man/common-cmd-footer.txt b/doc/man/common-cmd-footer.txt
index d776cc4..8b1b66f 100644
--- a/doc/man/common-cmd-footer.txt
+++ b/doc/man/common-cmd-footer.txt
@@ -19,6 +19,9 @@ ENVIRONMENT VARIABLES
 The genoption:--sessiond-path option has precedence over this
 environment variable.
 
+`LTTNG_ABORT_ON_ERROR`::
+    Abort process after the first error is encountered.
+
 Note that the man:lttng-create(1) command can spawn an LTTng
 session daemon automatically if none is running. See
 man:lttng-sessiond(8) for the environment variables influencing
diff --git a/doc/man/lttng-relayd.8.txt b/doc/man/lttng-relayd.8.txt
index d667be1..d3e5b3e 100644
--- a/doc/man/lttng-relayd.8.txt
+++ b/doc/man/lttng-relayd.8.txt
@@ -159,6 +159,9 @@ ENVIRONMENT VARIABLES
 `LTTNG_RELAYD_HEALTH`::
     Path to relay daemon health's socket.
 
+`LTTNG_ABORT_ON_ERROR`::
+    Abort the relay daemon after the first error is encountered.
+
 
 FILES
 -----
diff --git a/doc/man/lttng-sessiond.8.txt b/doc/man/lttng-sessiond.8.txt
index f4348d8..949d566 100644
--- a/doc/man/lttng-sessiond.8.txt
+++ b/doc/man/lttng-sessiond.8.txt
@@ -275,6 +275,8 @@ The option:--kmod-probes option overrides this variable.
 `LTTNG_SESSION_CONFIG_XSD_PATH`::
     Tracing session configuration XML schema definition (XSD) path.
 
+`LTTNG_ABORT_ON_ERROR`::
+    Abort the session daemon after the first error is encountered.
 
 FILES
 -----
diff --git a/src/common/error.c b/src/common/error.c
index f7e11e1..84bc04f 100644
--- a/src/common/error.c
+++ b/src/common/error.c
@@ -18,14 +18,23 @@
 #define _LGPL_SOURCE
 #include <assert.h>
 #include <inttypes.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include <lttng/lttng-error.h>
 #include <common/common.h>
+#include <common/compat/getenv.h>
 
 #include "error.h"
 
 #define ERROR_INDEX(code) (code - LTTNG_OK)
 
+/*
+ * lttng_opt_abort_on_error: unset: -1, disabled: 0, enabled: 1.
+ * Controlled by the LTTNG_ABORT_ON_ERROR environment variable.
+ */
+static int lttng_opt_abort_on_error = -1;
+
 /* TLS variable that contains the time of one single log entry. */
 DEFINE_URCU_TLS(struct log_time, error_log_time);
 
@@ -196,3 +205,22 @@ const char *error_get_str(int32_t code)
 
 	return error_string_array[ERROR_INDEX(code)];
 }
+
+LTTNG_HIDDEN
+void lttng_abort_on_error(void)
+{
+	if (lttng_opt_abort_on_error < 0) {
+		/* Use lttng_secure_getenv() to query its state. */
+		const char *value;
+
+		value = lttng_secure_getenv("LTTNG_ABORT_ON_ERROR");
+		if (value && !strcmp(value, "1")) {
+			lttng_opt_abort_on_error = 1;
+		} else {
+			lttng_opt_abort_on_error = 0;
+		}
+	}
+	if (lttng_opt_abort_on_error > 0) {
+		abort();
+	}
+}
diff --git a/src/common/error.h b/src/common/error.h
index 9c9d2a7..6c239fe 100644
--- a/src/common/error.h
+++ b/src/common/error.h
@@ -89,6 +89,9 @@ extern int lttng_opt_mi;
 				((type) & (PRINT_WARN | PRINT_ERR | PRINT_BUG))) { \
 			fprintf(stderr, fmt, ## args);                             \
 		}                                                                  \
+		if ((type) & (PRINT_ERR | PRINT_BUG)) {                            \
+			lttng_abort_on_error();                                    \
+		}                                                                  \
 	} while (0);
 
 /* Three level of debug. Use -v, -vv or -vvv for the levels */
@@ -174,4 +177,6 @@ const char *error_get_str(int32_t code);
  */
 const char *log_add_time();
 
+void lttng_abort_on_error(void);
+
 #endif /* _ERROR_H */
-- 
2.1.4



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

* [lttng-dev] [PATCH lttng-tools 09/10] test: kernel tracing destroy flush behavior with tracefile rotation
  2016-05-18 18:04 [lttng-dev] [PATCH lttng-tools 00/10] Fix: tracefile rotation rm-after-destroy race Mathieu Desnoyers
                   ` (2 preceding siblings ...)
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 08/10] Add environment variable to allow abort on error Mathieu Desnoyers
@ 2016-05-18 18:04 ` Mathieu Desnoyers
  2016-05-19  4:45   ` Jérémie Galarneau
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 10/10] test: UST " Mathieu Desnoyers
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Mathieu Desnoyers @ 2016-05-18 18:04 UTC (permalink / raw)


Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 tests/regression/kernel/Makefile.am                |   3 +-
 .../regression/kernel/test_rotation_destroy_flush  | 153 +++++++++++++++++++++
 tests/root_regression                              |   1 +
 3 files changed, 156 insertions(+), 1 deletion(-)
 create mode 100755 tests/regression/kernel/test_rotation_destroy_flush

diff --git a/tests/regression/kernel/Makefile.am b/tests/regression/kernel/Makefile.am
index ca73ed4..a8c397a 100644
--- a/tests/regression/kernel/Makefile.am
+++ b/tests/regression/kernel/Makefile.am
@@ -1,4 +1,5 @@
-EXTRA_DIST = test_event_basic test_all_events test_syscall test_clock_override
+EXTRA_DIST = test_event_basic test_all_events test_syscall \
+		test_clock_override test_rotation_destroy_flush
 
 all-local:
 	@if [ x"$(srcdir)" != x"$(builddir)" ]; then \
diff --git a/tests/regression/kernel/test_rotation_destroy_flush b/tests/regression/kernel/test_rotation_destroy_flush
new file mode 100755
index 0000000..0b0b0ca
--- /dev/null
+++ b/tests/regression/kernel/test_rotation_destroy_flush
@@ -0,0 +1,153 @@
+#!/bin/bash
+#
+# Copyright (C) - 2013 Christian Babeux <christian.babeux at efficios.com>
+# Copyright (C) - 2014, 2016 Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# This program 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 General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+TEST_DESC="Kernel tracer - Rotation destroy flush"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../..
+SESSION_NAME="rotation_destroy_flush"
+
+NR_ITER=10
+NUM_TESTS=$((13*$NR_ITER))
+EVENT_NAME="lttng_test_filter_event"
+CHANNEL_NAME="testchan"
+PAGE_SIZE=$(getconf PAGE_SIZE)
+SIZE_LIMIT=$PAGE_SIZE
+
+TESTCMD="echo -n 10000 > /proc/lttng-test-filter-event"
+
+# Ensure the daemons invoke abort on error.
+export LTTNG_ABORT_ON_ERROR=1
+
+source $TESTDIR/utils/utils.sh
+
+function signal_cleanup()
+{
+	diag "*** Exiting ***"
+	rmmod lttng-test
+	stop_lttng_sessiond
+	exit 1
+}
+
+function enable_kernel_lttng_channel_size_limit ()
+{
+	sess_name="$1"
+	channel_name="$2"
+	tracefile_size_limit="$3"
+
+	test_name="Enable channel $channel_name "
+	test_name+="for session $sess_name: "
+	test_name+="$tracefile_size_limit bytes tracefile limit"
+
+	$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel \
+	    -k $channel_name -s $sess_name \
+	    -C $tracefile_size_limit >/dev/null 2>&1
+
+	ok $? "$test_name"
+}
+
+function enable_kernel_lttng_event_per_channel ()
+{
+	sess_name="$1"
+	event_name="$2"
+	channel_name="$3"
+
+	test_name="Enable event $event_name "
+	test_name+="for session $sess_name "
+	test_name+="in channel $channel_name"
+
+	$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" \
+	    -s $sess_name -k -c $channel_name >/dev/null 2>&1
+
+	ok $? "$test_name"
+}
+
+function test_rotation_destroy_flush_single()
+{
+	start_lttng_sessiond
+	modprobe lttng-test
+
+	create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+	enable_kernel_lttng_channel_size_limit \
+		$SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
+	enable_kernel_lttng_event_per_channel \
+		$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+	start_lttng_tracing_ok $SESSION_NAME
+	eval ${TESTCMD}
+	# stop and destroy
+	stop_lttng_tracing_ok $SESSION_NAME
+	destroy_lttng_session_ok $SESSION_NAME
+
+	rm -rf $TRACE_PATH
+
+	create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+	enable_kernel_lttng_channel_size_limit \
+		$SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
+	enable_kernel_lttng_event_per_channel \
+		$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+	start_lttng_tracing_ok $SESSION_NAME
+	eval ${TESTCMD}
+	# destroy only
+	destroy_lttng_session_ok $SESSION_NAME
+
+	rm -rf $TRACE_PATH
+
+	rmmod lttng-test
+	stop_lttng_sessiond
+}
+
+function test_rotation_destroy_flush()
+{
+	for a in $(seq 1 ${NR_ITER}); do
+		diag "Iteration ${a}/${NR_ITER}"
+		test_rotation_destroy_flush_single
+	done
+}
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+TESTS=(
+	"test_rotation_destroy_flush"
+)
+
+TEST_COUNT=${#TESTS[@]}
+i=0
+
+if [ "$(id -u)" == "0" ]; then
+	isroot=1
+else
+	isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+{
+	trap signal_cleanup SIGTERM SIGINT
+
+	while [ "$i" -lt "$TEST_COUNT" ]; do
+
+		TRACE_PATH=$(mktemp -d)
+
+		# Execute test
+		${TESTS[$i]}
+
+		let "i++"
+	done
+}
diff --git a/tests/root_regression b/tests/root_regression
index 4655c09..2981dc6 100644
--- a/tests/root_regression
+++ b/tests/root_regression
@@ -2,6 +2,7 @@ regression/kernel/test_all_events
 regression/kernel/test_event_basic
 regression/kernel/test_syscall
 regression/kernel/test_clock_override
+regression/kernel/test_rotation_destroy_flush
 regression/tools/live/test_kernel
 regression/tools/live/test_lttng_kernel
 regression/tools/streaming/test_high_throughput_limits
-- 
2.1.4



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

* [lttng-dev] [PATCH lttng-tools 10/10] test: UST tracing destroy flush behavior with tracefile rotation
  2016-05-18 18:04 [lttng-dev] [PATCH lttng-tools 00/10] Fix: tracefile rotation rm-after-destroy race Mathieu Desnoyers
                   ` (3 preceding siblings ...)
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 09/10] test: kernel tracing destroy flush behavior with tracefile rotation Mathieu Desnoyers
@ 2016-05-18 18:04 ` Mathieu Desnoyers
  2016-05-19  4:46   ` Jérémie Galarneau
       [not found] ` <1463594659-10964-2-git-send-email-mathieu.desnoyers@efficios.com>
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 16+ messages in thread
From: Mathieu Desnoyers @ 2016-05-18 18:04 UTC (permalink / raw)


Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 configure.ac                                       |   1 +
 tests/fast_regression                              |   1 +
 tests/regression/ust/Makefile.am                   |   3 +-
 .../ust/rotation-destroy-flush/Makefile.am         |  16 +++
 .../test_rotation_destroy_flush                    | 150 +++++++++++++++++++++
 5 files changed, 170 insertions(+), 1 deletion(-)
 create mode 100644 tests/regression/ust/rotation-destroy-flush/Makefile.am
 create mode 100755 tests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush

diff --git a/configure.ac b/configure.ac
index 20d0680..0c1f976 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1002,6 +1002,7 @@ AC_CONFIG_FILES([
 	tests/regression/ust/getcpu-override/Makefile
 	tests/regression/ust/clock-override/Makefile
 	tests/regression/ust/type-declarations/Makefile
+	tests/regression/ust/rotation-destroy-flush/Makefile
 	tests/stress/Makefile
 	tests/unit/Makefile
 	tests/unit/ini_config/Makefile
diff --git a/tests/fast_regression b/tests/fast_regression
index aa0c043..0c4f079 100644
--- a/tests/fast_regression
+++ b/tests/fast_regression
@@ -27,5 +27,6 @@ regression/ust/java-log4j/test_java_log4j
 regression/ust/python-logging/test_python_logging
 regression/ust/getcpu-override/test_getcpu_override
 regression/ust/clock-override/test_clock_override
+regression/ust/rotation-destroy-flush/test_rotation_destroy_flush
 regression/ust/test_event_basic
 regression/ust/test_event_tracef
diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am
index 1b87cc9..7686251 100644
--- a/tests/regression/ust/Makefile.am
+++ b/tests/regression/ust/Makefile.am
@@ -2,7 +2,8 @@ if HAVE_LIBLTTNG_UST_CTL
 SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \
 		overlap buffers-pid linking daemon exit-fast fork libc-wrapper \
 		periodical-metadata-flush java-jul java-log4j python-logging \
-		getcpu-override clock-override type-declarations
+		getcpu-override clock-override type-declarations \
+		rotation-destroy-flush
 
 if HAVE_OBJCOPY
 SUBDIRS += baddr-statedump ust-dl
diff --git a/tests/regression/ust/rotation-destroy-flush/Makefile.am b/tests/regression/ust/rotation-destroy-flush/Makefile.am
new file mode 100644
index 0000000..14b869e
--- /dev/null
+++ b/tests/regression/ust/rotation-destroy-flush/Makefile.am
@@ -0,0 +1,16 @@
+noinst_SCRIPTS = test_rotation_destroy_flush
+EXTRA_DIST = test_rotation_destroy_flush
+
+all-local:
+	@if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+		for script in $(EXTRA_DIST); do \
+			cp -f $(srcdir)/$$script $(builddir); \
+		done; \
+	fi
+
+clean-local:
+	@if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+		for script in $(EXTRA_DIST); do \
+			rm -f $(builddir)/$$script; \
+		done; \
+	fi
diff --git a/tests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush b/tests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush
new file mode 100755
index 0000000..a7a9377
--- /dev/null
+++ b/tests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush
@@ -0,0 +1,150 @@
+#!/bin/bash
+#
+# Copyright (C) - 2015 Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
+# Copyright (C) - 2016 Mathieu Desnoyers <mathieu.desnoyers at 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; 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
+TEST_DESC="UST - Rotation destroy flush"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../../..
+SESSION_NAME="rotation_destroy_flush"
+
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+TESTAPP_NAME="gen-ust-events"
+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
+NUM_EVENT=1000000
+EVENT_NAME="tp:tptest"
+CHANNEL_NAME="testchan"
+PAGE_SIZE=$(getconf PAGE_SIZE)
+SIZE_LIMIT=$PAGE_SIZE
+
+NR_ITER=10
+NUM_TESTS=$((15*$NR_ITER))
+
+# Ensure the daemons invoke abort on error.
+export LTTNG_ABORT_ON_ERROR=1
+
+source $TESTDIR/utils/utils.sh
+
+# MUST set TESTDIR before calling those functions
+function run_app()
+{
+	$TESTAPP_BIN $NUM_EVENT
+	ok $? "Application done"
+}
+
+function signal_cleanup()
+{
+	diag "*** Exiting ***"
+	stop_lttng_sessiond
+	exit 1
+}
+
+function enable_ust_lttng_channel_size_limit ()
+{
+	sess_name="$1"
+	channel_name="$2"
+	tracefile_size_limit="$3"
+
+	test_name="Enable channel $channel_name "
+	test_name+="for session $sess_name: "
+	test_name+="$tracefile_size_limit bytes tracefile limit"
+
+	$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel \
+	    -u $channel_name -s $sess_name --buffers-pid \
+	    -C $tracefile_size_limit >/dev/null 2>&1
+
+	ok $? "$test_name"
+}
+
+function enable_ust_lttng_event_per_channel ()
+{
+	sess_name="$1"
+	event_name="$2"
+	channel_name="$3"
+
+	test_name="Enable event $event_name "
+	test_name+="for session $sess_name "
+	test_name+="in channel $channel_name"
+
+	$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" \
+	    -s $sess_name -u -c $channel_name >/dev/null 2>&1
+
+	ok $? "$test_name"
+}
+
+function test_rotation_destroy_flush_single()
+{
+	start_lttng_sessiond
+
+	create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+	enable_ust_lttng_channel_size_limit \
+		$SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
+	enable_ust_lttng_event_per_channel \
+		$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+	start_lttng_tracing_ok $SESSION_NAME
+	run_app
+	# stop and destroy
+	stop_lttng_tracing_ok $SESSION_NAME
+	destroy_lttng_session_ok $SESSION_NAME
+
+	rm -rf $TRACE_PATH
+
+	create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+	enable_ust_lttng_channel_size_limit \
+		$SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
+	enable_ust_lttng_event_per_channel \
+		$SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+	start_lttng_tracing_ok $SESSION_NAME
+	run_app
+	# destroy only
+	destroy_lttng_session_ok $SESSION_NAME
+
+	rm -rf $TRACE_PATH
+
+	stop_lttng_sessiond
+}
+
+function test_rotation_destroy_flush()
+{
+	for a in $(seq 1 ${NR_ITER}); do
+		diag "Iteration ${a}/${NR_ITER}"
+		test_rotation_destroy_flush_single
+	done
+}
+
+
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+TESTS=(
+	"test_rotation_destroy_flush"
+)
+
+TEST_COUNT=${#TESTS[@]}
+i=0
+
+while [ "$i" -lt "$TEST_COUNT" ]; do
+
+	trap signal_cleanup SIGTERM SIGINT
+
+	TRACE_PATH=$(mktemp -d)
+
+	# Execute test
+	${TESTS[$i]}
+
+	let "i++"
+done
-- 
2.1.4



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

* [lttng-dev] [PATCH lttng-tools 01/10] Fix: bad file descriptors on close after rotation error
       [not found] ` <1463594659-10964-2-git-send-email-mathieu.desnoyers@efficios.com>
@ 2016-05-19  2:57   ` Jérémie Galarneau
  0 siblings, 0 replies; 16+ messages in thread
From: Jérémie Galarneau @ 2016-05-19  2:57 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1014 bytes --]

Merged, thanks!

Jérémie

On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> Ensure we don't try to close output stream file descriptors twice when a
> trace file rotation error occurs (once at tracefile rotation, once when
> closing the stream). Set the fd value to -1 after the first close to
> ensure we don't try to close it again.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  src/common/utils.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/common/utils.c b/src/common/utils.c
> index df55dc9..fdd8802 100644
> --- a/src/common/utils.c
> +++ b/src/common/utils.c
> @@ -850,6 +850,7 @@ int utils_rotate_stream_file(char *path_name, char *file_name, uint64_t size,
>                 PERROR("Closing tracefile");
>                 goto error;
>         }
> +       *stream_fd = -1;
>
>         if (count > 0) {
>                 /*
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


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

* [lttng-dev] [PATCH lttng-tools 02/10] Fix: UST should not generate packet at destroy after stop
       [not found] ` <1463594659-10964-3-git-send-email-mathieu.desnoyers@efficios.com>
@ 2016-05-19  4:09   ` Jérémie Galarneau
  0 siblings, 0 replies; 16+ messages in thread
From: Jérémie Galarneau @ 2016-05-19  4:09 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 15243 bytes --]

On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> In the following scenario:
> - create, enable events (ust),
> - start
> - ...
> - stop (await for data_pending to complete)
> - destroy
> - rm the trace directory
>
> We would expect that the "rm" operation would not conflict with the
> consumer daemon trying to output data into the trace files, since the
> "stop" operation ensured that there was no data_pending.
>
> However, the "destroy" operation currently generates an extra packet
> after the data_pending check (the "on_stream_hangup"). This causes the
> consumer daemon to try to perform trace file rotation concurrently with
> the trace directory removal in the scenario above, which triggers
> errors. The main reason why this empty packet is generated by "destroy"
> is to deal with trace start/stop scenario which would otherwise generate
> a completely empty stream.
>
> Therefore, introduce the concept of a "quiescent stream". It is
> initialized at false on stream creation (first packet is empty). When
> tracing is started, it is set to false (for cases of start/stop/start).
> When tracing is stopped, if the stream is not quiescent, perform a
> "final" flush (which will generate an empty packet if the current packet
> was empty), and set quiescent to true.  On "destroy" stream and on
> application hangup: if the stream is not quiescent, perform a "final"
> flush, and set the quiescent state to true.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  src/bin/lttng-sessiond/consumer.c        |  32 +++++++
>  src/bin/lttng-sessiond/consumer.h        |   1 +
>  src/bin/lttng-sessiond/ust-app.c         | 142 +++++++++++++++++++++++++++++++
>  src/common/consumer/consumer.h           |  13 +++
>  src/common/sessiond-comm/sessiond-comm.h |   3 +
>  src/common/ust-consumer/ust-consumer.c   |  67 ++++++++++++++-
>  6 files changed, 256 insertions(+), 2 deletions(-)
>
> diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c
> index bd019dd..2da3723 100644
> --- a/src/bin/lttng-sessiond/consumer.c
> +++ b/src/bin/lttng-sessiond/consumer.c
> @@ -1185,6 +1185,38 @@ end:
>  }
>
>  /*
> + * Send a clear quiescent command to consumer using the given channel key.
> + *
> + * Return 0 on success else a negative value.
> + */
> +int consumer_clear_quiescent_channel(struct consumer_socket *socket, uint64_t key)
> +{
> +       int ret;
> +       struct lttcomm_consumer_msg msg;
> +
> +       assert(socket);
> +
> +       DBG2("Consumer clear quiescent channel key %" PRIu64, key);
> +
> +       memset(&msg, 0, sizeof(msg));
> +       msg.cmd_type = LTTNG_CONSUMER_CLEAR_QUIESCENT_CHANNEL;
> +       msg.u.clear_quiescent_channel.key = key;
> +
> +       pthread_mutex_lock(socket->lock);
> +       health_code_update();
> +
> +       ret = consumer_send_msg(socket, &msg);
> +       if (ret < 0) {
> +               goto end;
> +       }
> +
> +end:
> +       health_code_update();
> +       pthread_mutex_unlock(socket->lock);
> +       return ret;
> +}
> +
> +/*
>   * Send a close metadata command to consumer using the given channel key.
>   * Called with registry lock held.
>   *
> diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h
> index 75a40f8..08b57eb 100644
> --- a/src/bin/lttng-sessiond/consumer.h
> +++ b/src/bin/lttng-sessiond/consumer.h
> @@ -284,6 +284,7 @@ int consumer_push_metadata(struct consumer_socket *socket,
>                 uint64_t metadata_key, char *metadata_str, size_t len,
>                 size_t target_offset, uint64_t version);
>  int consumer_flush_channel(struct consumer_socket *socket, uint64_t key);
> +int consumer_clear_quiescent_channel(struct consumer_socket *socket, uint64_t key);
>  int consumer_get_discarded_events(uint64_t session_id, uint64_t channel_key,
>                 struct consumer_output *consumer, uint64_t *discarded);
>  int consumer_get_lost_packets(uint64_t session_id, uint64_t channel_key,
> diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c
> index 1bb183d..bf0569e 100644
> --- a/src/bin/lttng-sessiond/ust-app.c
> +++ b/src/bin/lttng-sessiond/ust-app.c
> @@ -4650,6 +4650,140 @@ int ust_app_flush_session(struct ltt_ust_session *usess)
>         return ret;
>  }
>
> +static
> +int ust_app_clear_quiescent_app_session(struct ust_app *app,
> +               struct ust_app_session *ua_sess)
> +{
> +       int ret, retval = 0;
> +       struct lttng_ht_iter iter;
> +       struct ust_app_channel *ua_chan;
> +       struct consumer_socket *socket;
> +
> +       DBG("Clearing stream quiescent state for ust app pid %d", app->pid);
> +
> +       rcu_read_lock();
> +
> +       if (!app->compatible) {
> +               goto end_not_compatible;
> +       }
> +
> +       pthread_mutex_lock(&ua_sess->lock);
> +
> +       if (ua_sess->deleted) {
> +               goto end_deleted;
> +       }
> +
> +       health_code_update();
> +
> +       socket = consumer_find_socket_by_bitness(app->bits_per_long,
> +                       ua_sess->consumer);

Added error checking (logging) for "!socket" here.

> +
> +       /* Clear quiescent state. */
> +       switch (ua_sess->buffer_type) {
> +       case LTTNG_BUFFER_PER_PID:
> +               cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan,
> +                               node.node) {
> +                       health_code_update();
> +                       ret = consumer_clear_quiescent_channel(socket, ua_chan->key);
> +                       if (ret) {
> +                               ERR("Error clearing quiescent state for consumer channel");
> +                               retval = -1;

Combined ret and retval.

> +                               continue;
> +                       }
> +               }
> +               break;
> +       case LTTNG_BUFFER_PER_UID:
> +       default:
> +               assert(0);
> +               break;
> +       }
> +
> +       health_code_update();
> +
> +end_deleted:
> +       pthread_mutex_unlock(&ua_sess->lock);
> +
> +end_not_compatible:
> +       rcu_read_unlock();
> +       health_code_update();
> +       return retval;
> +}
> +
> +/*
> + * Clear quiescent state in each stream for all applications for a
> + * specific UST session.
> + * Called with UST session lock held.
> + */
> +static
> +int ust_app_clear_quiescent_session(struct ltt_ust_session *usess)
> +
> +{
> +       int ret = 0;
> +
> +       DBG("Clearing stream quiescent state for all ust apps");
> +
> +       rcu_read_lock();
> +
> +       switch (usess->buffer_type) {
> +       case LTTNG_BUFFER_PER_UID:
> +       {
> +               struct buffer_reg_uid *reg;
> +               struct lttng_ht_iter iter;
> +
> +               /*
> +                * Clear quiescent for all per UID buffers associated to
> +                * that session.
> +                */
> +               cds_list_for_each_entry(reg, &usess->buffer_reg_uid_list, lnode) {
> +                       struct buffer_reg_channel *reg_chan;
> +                       struct consumer_socket *socket;
> +
> +                       /* Get associated consumer socket.*/
> +                       socket = consumer_find_socket_by_bitness(reg->bits_per_long,
> +                                       usess->consumer);
> +                       if (!socket) {
> +                               /* Ignore request if no consumer is found for the session. */
> +                               continue;
> +                       }
> +
> +                       cds_lfht_for_each_entry(reg->registry->channels->ht, &iter.iter,
> +                                       reg_chan, node.node) {
> +                               /*
> +                                * The following call will print error values so the return
> +                                * code is of little importance because whatever happens, we
> +                                * have to try them all.
> +                                */
> +                               (void) consumer_clear_quiescent_channel(socket, reg_chan->consumer_key);
> +                       }
> +               }
> +               break;
> +       }
> +       case LTTNG_BUFFER_PER_PID:
> +       {
> +               struct ust_app_session *ua_sess;
> +               struct lttng_ht_iter iter;
> +               struct ust_app *app;
> +
> +               cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
> +                       ua_sess = lookup_session_by_app(usess, app);
> +                       if (ua_sess == NULL) {
> +                               continue;
> +                       }
> +                       (void) ust_app_clear_quiescent_app_session(app, ua_sess);
> +               }
> +               break;
> +       }
> +       default:
> +               ret = -1;
> +               assert(0);
> +               break;
> +       }
> +
> +       rcu_read_unlock();
> +       health_code_update();
> +       return ret;
> +}
> +
>  /*
>   * Destroy a specific UST session in apps.
>   */
> @@ -4708,6 +4842,14 @@ int ust_app_start_trace_all(struct ltt_ust_session *usess)
>
>         rcu_read_lock();
>
> +       /*
> +        * In a start-stop-start use-case, we need to clear the quiescent state
> +        * of each channel set by the prior stop command, thus ensuring that a
> +        * following stop or destroy is sure to grab a timestamp_end near those
> +        * operations, even if the packet is empty.
> +        */
> +       (void) ust_app_clear_quiescent_session(usess);
> +
>         cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
>                 ret = ust_app_start_trace(usess, app);
>                 if (ret < 0) {
> diff --git a/src/common/consumer/consumer.h b/src/common/consumer/consumer.h
> index 59764e1..d2f225a 100644
> --- a/src/common/consumer/consumer.h
> +++ b/src/common/consumer/consumer.h
> @@ -60,6 +60,7 @@ enum lttng_consumer_command {
>         LTTNG_CONSUMER_STREAMS_SENT,
>         LTTNG_CONSUMER_DISCARDED_EVENTS,
>         LTTNG_CONSUMER_LOST_PACKETS,
> +       LTTNG_CONSUMER_CLEAR_QUIESCENT_CHANNEL,
>  };
>
>  /* State of each fd in consumer */
> @@ -250,6 +251,18 @@ struct lttng_consumer_stream {
>         int hangup_flush_done;
>
>         /*
> +        * Whether the stream is in a "complete" state, e.g. no
> +        * partially written sub-buffer.
> +        * Initialized at false on stream creation (first packet is empty).
> +        * "start" tracing: set to false.
> +        * "stop" tracing: if !quiescent -> flush FINAL, set to true.
> +        * "destroy" stream/application hangup: if !quiescent -> flush
> +        * FINAL, set to true.
> +        * Update and read are protected by the stream lock.

I fleshed this out a bit more since I don't want to go through that
gymnastic again ;-)


The rest of the patch looks good, merged!

Thanks!
Jérémie

> +        */
> +       bool quiescent;
> +
> +       /*
>          * metadata_timer_lock protects flags waiting_on_metadata and
>          * missed_metadata_flush.
>          */
> diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h
> index e7fd69d..0983865 100644
> --- a/src/common/sessiond-comm/sessiond-comm.h
> +++ b/src/common/sessiond-comm/sessiond-comm.h
> @@ -501,6 +501,9 @@ struct lttcomm_consumer_msg {
>                         uint64_t key;   /* Channel key. */
>                 } LTTNG_PACKED flush_channel;
>                 struct {
> +                       uint64_t key;   /* Channel key. */
> +               } LTTNG_PACKED clear_quiescent_channel;
> +               struct {
>                         char pathname[PATH_MAX];
>                         /* Indicate if the snapshot goes on the relayd or locally. */
>                         uint32_t use_relayd;
> diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c
> index a113ef1..91ffdce 100644
> --- a/src/common/ust-consumer/ust-consumer.c
> +++ b/src/common/ust-consumer/ust-consumer.c
> @@ -767,7 +767,54 @@ static int flush_channel(uint64_t chan_key)
>
>                 health_code_update();
>
> -               ustctl_flush_buffer(stream->ustream, 1);
> +               pthread_mutex_lock(&stream->lock);
> +               if (!stream->quiescent) {
> +                       stream->quiescent = true;
> +                       ustctl_flush_buffer(stream->ustream, 0);
> +               }
> +               pthread_mutex_unlock(&stream->lock);
> +       }
> +error:
> +       rcu_read_unlock();
> +       return ret;
> +}
> +
> +/*
> + * Clear quiescent state from channel's streams using the given key to
> + * retrieve the channel.
> + *
> + * Return 0 on success else an LTTng error code.
> + */
> +static int clear_quiescent_channel(uint64_t chan_key)
> +{
> +       int ret = 0;
> +       struct lttng_consumer_channel *channel;
> +       struct lttng_consumer_stream *stream;
> +       struct lttng_ht *ht;
> +       struct lttng_ht_iter iter;
> +
> +       DBG("UST consumer clear quiescent channel key %" PRIu64, chan_key);
> +
> +       rcu_read_lock();
> +       channel = consumer_find_channel(chan_key);
> +       if (!channel) {
> +               ERR("UST consumer clear quiescent channel %" PRIu64 " not found", chan_key);
> +               ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
> +               goto error;
> +       }
> +
> +       ht = consumer_data.stream_per_chan_id_ht;
> +
> +       /* For each stream of the channel id, clear quiescent state. */
> +       cds_lfht_for_each_entry_duplicate(ht->ht,
> +                       ht->hash_fct(&channel->key, lttng_ht_seed), ht->match_fct,
> +                       &channel->key, &iter.iter, stream, node_channel_id.node) {
> +
> +               health_code_update();
> +
> +               pthread_mutex_lock(&stream->lock);
> +               stream->quiescent = false;
> +               pthread_mutex_unlock(&stream->lock);
>         }
>  error:
>         rcu_read_unlock();
> @@ -1582,6 +1629,17 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
>
>                 goto end_msg_sessiond;
>         }
> +       case LTTNG_CONSUMER_CLEAR_QUIESCENT_CHANNEL:
> +       {
> +               int ret;
> +
> +               ret = clear_quiescent_channel(msg.u.clear_quiescent_channel.key);
> +               if (ret != 0) {
> +                       ret_code = ret;
> +               }
> +
> +               goto end_msg_sessiond;
> +       }
>         case LTTNG_CONSUMER_PUSH_METADATA:
>         {
>                 int ret;
> @@ -1951,7 +2009,12 @@ void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream *stream)
>         assert(stream);
>         assert(stream->ustream);
>
> -       ustctl_flush_buffer(stream->ustream, 0);
> +       pthread_mutex_lock(&stream->lock);
> +       if (!stream->quiescent) {
> +               stream->quiescent = true;
> +               ustctl_flush_buffer(stream->ustream, 0);
> +       }
> +       pthread_mutex_unlock(&stream->lock);
>         stream->hangup_flush_done = 1;
>  }
>
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


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

* [lttng-dev] [PATCH lttng-tools 03/10] Fix: kernel tracing: flush after stop
       [not found] ` <1463594659-10964-4-git-send-email-mathieu.desnoyers@efficios.com>
@ 2016-05-19  4:09   ` Jérémie Galarneau
  0 siblings, 0 replies; 16+ messages in thread
From: Jérémie Galarneau @ 2016-05-19  4:09 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2380 bytes --]

Good catch, merged!

Thanks,
Jérémie

On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> We should flush the last packet after stop, not before. Otherwise, we
> may end up with events written immediately after the flush, which
> defeats the purpose of flushing.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  src/bin/lttng-sessiond/cmd.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c
> index 16d8ba2..d57edcd 100644
> --- a/src/bin/lttng-sessiond/cmd.c
> +++ b/src/bin/lttng-sessiond/cmd.c
> @@ -2437,7 +2437,15 @@ int cmd_stop_trace(struct ltt_session *session)
>         if (ksession && ksession->active) {
>                 DBG("Stop kernel tracing");
>
> -               /* Flush metadata if exist */
> +               ret = kernel_stop_session(ksession);
> +               if (ret < 0) {
> +                       ret = LTTNG_ERR_KERN_STOP_FAIL;
> +                       goto error;
> +               }
> +
> +               kernel_wait_quiescent(kernel_tracer_fd);
> +
> +               /* Flush metadata after stopping (if exists) */
>                 if (ksession->metadata_stream_fd >= 0) {
>                         ret = kernel_metadata_flush_buffer(ksession->metadata_stream_fd);
>                         if (ret < 0) {
> @@ -2445,7 +2453,7 @@ int cmd_stop_trace(struct ltt_session *session)
>                         }
>                 }
>
> -               /* Flush all buffers before stopping */
> +               /* Flush all buffers after stopping */
>                 cds_list_for_each_entry(kchan, &ksession->channel_list.head, list) {
>                         ret = kernel_flush_buffer(kchan);
>                         if (ret < 0) {
> @@ -2453,14 +2461,6 @@ int cmd_stop_trace(struct ltt_session *session)
>                         }
>                 }
>
> -               ret = kernel_stop_session(ksession);
> -               if (ret < 0) {
> -                       ret = LTTNG_ERR_KERN_STOP_FAIL;
> -                       goto error;
> -               }
> -
> -               kernel_wait_quiescent(kernel_tracer_fd);
> -
>                 ksession->active = 0;
>         }
>
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


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

* [lttng-dev] [PATCH lttng-tools 04/10] Fix: ust-consumer: flush empty packets on snapshot channel
       [not found] ` <1463594659-10964-5-git-send-email-mathieu.desnoyers@efficios.com>
@ 2016-05-19  4:12   ` Jérémie Galarneau
  0 siblings, 0 replies; 16+ messages in thread
From: Jérémie Galarneau @ 2016-05-19  4:12 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1578 bytes --]

Merged, thanks!

Jérémie

On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> Snapshot operation on a non-stopped stream should use a "final" flush to
> ensure empty packets are flushed, so we gather timestamps at the moment
> where the snapshot is taken. This is important for streams that have a
> low amount of activity, which might be on an empty packet when the
> snapshot is triggered.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  src/common/ust-consumer/ust-consumer.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c
> index 91ffdce..c631904 100644
> --- a/src/common/ust-consumer/ust-consumer.c
> +++ b/src/common/ust-consumer/ust-consumer.c
> @@ -1111,7 +1111,13 @@ static int snapshot_channel(uint64_t key, char *path, uint64_t relayd_id,
>                         }
>                 }
>
> -               ustctl_flush_buffer(stream->ustream, 1);
> +               /*
> +                * If tracing is active, we want to perform a "full" buffer flush.
> +                * Else, if quiescent, it has already been done by the prior stop.
> +                */
> +               if (!stream->quiescent) {
> +                       ustctl_flush_buffer(stream->ustream, 0);
> +               }
>
>                 ret = lttng_ustconsumer_take_snapshot(stream);
>                 if (ret < 0) {
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


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

* [lttng-dev] [PATCH lttng-tools 05/10] Fix: bogus mask on error.h PRINT types
       [not found] ` <1463594659-10964-6-git-send-email-mathieu.desnoyers@efficios.com>
@ 2016-05-19  4:12   ` Jérémie Galarneau
  0 siblings, 0 replies; 16+ messages in thread
From: Jérémie Galarneau @ 2016-05-19  4:12 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1584 bytes --]

Good catch, merged!

Thanks!
Jérémie

On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> PRINT_ERR maps to 0x1, PRINT_WARN maps to 0x2, which is fine so far to
> use as masks, but PRINT_BUG maps to 0x3, which is the same as both
> PRINT_ERR and PRINT_WARN, and does not make sense to use in masks with
> __lttng_print:
>
>   (type & (PRINT_WARN | PRINT_ERR | PRINT_BUG))
>
> Fix this by ensuring PRINT_BUG has its own mask, and express all
> constants as shifts to eliminate the risk of re-introducing a similar
> bug in the future.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  src/common/error.h | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/src/common/error.h b/src/common/error.h
> index f2a31df..3ab1d46 100644
> --- a/src/common/error.h
> +++ b/src/common/error.h
> @@ -57,13 +57,13 @@ extern int lttng_opt_verbose;
>  extern int lttng_opt_mi;
>
>  /* Error type. */
> -#define PRINT_ERR   0x1
> -#define PRINT_WARN  0x2
> -#define PRINT_BUG   0x3
> -#define PRINT_MSG   0x4
> -#define PRINT_DBG   0x10
> -#define PRINT_DBG2  0x20
> -#define PRINT_DBG3  0x30
> +#define PRINT_ERR   (1 << 0)
> +#define PRINT_WARN  (1 << 1)
> +#define PRINT_BUG   (1 << 2)
> +#define PRINT_MSG   (1 << 3)
> +#define PRINT_DBG   (1 << 4)
> +#define PRINT_DBG2  (1 << 5)
> +#define PRINT_DBG3  (1 << 6)
>
>  /*
>   * Macro for printing message depending on command line option and verbosity.
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


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

* [lttng-dev] [PATCH lttng-tools 06/10] Fix: error.h: add missing parenthesis around macro parameter
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 06/10] Fix: error.h: add missing parenthesis around macro parameter Mathieu Desnoyers
@ 2016-05-19  4:13   ` Jérémie Galarneau
  0 siblings, 0 replies; 16+ messages in thread
From: Jérémie Galarneau @ 2016-05-19  4:13 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2510 bytes --]

Merged, thanks!

Jérémie

On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  src/common/error.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/src/common/error.h b/src/common/error.h
> index 3ab1d46..ca5af86 100644
> --- a/src/common/error.h
> +++ b/src/common/error.h
> @@ -75,18 +75,18 @@ extern int lttng_opt_mi;
>   */
>  #define __lttng_print(type, fmt, args...)                                          \
>         do {                                                                       \
> -               if (!lttng_opt_quiet&& !lttng_opt_mi &&                            \
> -                               type == PRINT_MSG) {                               \
> +               if (!lttng_opt_quiet && !lttng_opt_mi &&                           \
> +                               (type) == PRINT_MSG) {                             \
>                         fprintf(stdout, fmt, ## args);                             \
>                 } else if (!lttng_opt_quiet && !lttng_opt_mi &&                    \
> -                               (((type & PRINT_DBG) && lttng_opt_verbose == 1) || \
> -                               ((type & (PRINT_DBG | PRINT_DBG2)) &&              \
> +                               ((((type) & PRINT_DBG) && lttng_opt_verbose == 1) || \
> +                               (((type) & (PRINT_DBG | PRINT_DBG2)) &&            \
>                                         lttng_opt_verbose == 2) ||                 \
> -                               ((type & (PRINT_DBG | PRINT_DBG2 | PRINT_DBG3)) && \
> +                               (((type) & (PRINT_DBG | PRINT_DBG2 | PRINT_DBG3)) && \
>                                         lttng_opt_verbose == 3))) {                \
>                         fprintf(stderr, fmt, ## args);                             \
>                 } else if (!lttng_opt_quiet &&                                     \
> -                               (type & (PRINT_WARN | PRINT_ERR | PRINT_BUG))) {   \
> +                               ((type) & (PRINT_WARN | PRINT_ERR | PRINT_BUG))) { \
>                         fprintf(stderr, fmt, ## args);                             \
>                 }                                                                  \
>         } while (0);
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


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

* [lttng-dev] [PATCH lttng-tools 07/10] Fix: WARN() should print as WARN level, not ERR
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 07/10] Fix: WARN() should print as WARN level, not ERR Mathieu Desnoyers
@ 2016-05-19  4:14   ` Jérémie Galarneau
  0 siblings, 0 replies; 16+ messages in thread
From: Jérémie Galarneau @ 2016-05-19  4:14 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 901 bytes --]

Good catch (again)! Merged.

Thanks,
Jérémie

On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  src/common/error.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/common/error.h b/src/common/error.h
> index ca5af86..9c9d2a7 100644
> --- a/src/common/error.h
> +++ b/src/common/error.h
> @@ -103,7 +103,7 @@ extern int lttng_opt_mi;
>  #define ERR(fmt, args...) \
>         __lttng_print(PRINT_ERR, "Error: " fmt "\n", ## args)
>  #define WARN(fmt, args...) \
> -       __lttng_print(PRINT_ERR, "Warning: " fmt "\n", ## args)
> +       __lttng_print(PRINT_WARN, "Warning: " fmt "\n", ## args)
>
>  #define BUG(fmt, args...) _ERRMSG("BUG", PRINT_BUG, fmt, ## args)
>
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


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

* [lttng-dev] [PATCH lttng-tools 08/10] Add environment variable to allow abort on error
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 08/10] Add environment variable to allow abort on error Mathieu Desnoyers
@ 2016-05-19  4:45   ` Jérémie Galarneau
  0 siblings, 0 replies; 16+ messages in thread
From: Jérémie Galarneau @ 2016-05-19  4:45 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4740 bytes --]

Merged with some documentation changes, thanks!

Jérémie

On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> The new environment variable LTTNG_ABORT_ON_ERROR allows each
> lttng-tools program to call abort() on PERROR() and ERR() after the
> error message has been printed to stderr.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  doc/man/common-cmd-footer.txt |  3 +++
>  doc/man/lttng-relayd.8.txt    |  3 +++
>  doc/man/lttng-sessiond.8.txt  |  2 ++
>  src/common/error.c            | 28 ++++++++++++++++++++++++++++
>  src/common/error.h            |  5 +++++
>  5 files changed, 41 insertions(+)
>
> diff --git a/doc/man/common-cmd-footer.txt b/doc/man/common-cmd-footer.txt
> index d776cc4..8b1b66f 100644
> --- a/doc/man/common-cmd-footer.txt
> +++ b/doc/man/common-cmd-footer.txt
> @@ -19,6 +19,9 @@ ENVIRONMENT VARIABLES
>  The genoption:--sessiond-path option has precedence over this
>  environment variable.
>
> +`LTTNG_ABORT_ON_ERROR`::
> +    Abort process after the first error is encountered.
> +
>  Note that the man:lttng-create(1) command can spawn an LTTng
>  session daemon automatically if none is running. See
>  man:lttng-sessiond(8) for the environment variables influencing
> diff --git a/doc/man/lttng-relayd.8.txt b/doc/man/lttng-relayd.8.txt
> index d667be1..d3e5b3e 100644
> --- a/doc/man/lttng-relayd.8.txt
> +++ b/doc/man/lttng-relayd.8.txt
> @@ -159,6 +159,9 @@ ENVIRONMENT VARIABLES
>  `LTTNG_RELAYD_HEALTH`::
>      Path to relay daemon health's socket.
>
> +`LTTNG_ABORT_ON_ERROR`::
> +    Abort the relay daemon after the first error is encountered.
> +
>
>  FILES
>  -----
> diff --git a/doc/man/lttng-sessiond.8.txt b/doc/man/lttng-sessiond.8.txt
> index f4348d8..949d566 100644
> --- a/doc/man/lttng-sessiond.8.txt
> +++ b/doc/man/lttng-sessiond.8.txt
> @@ -275,6 +275,8 @@ The option:--kmod-probes option overrides this variable.
>  `LTTNG_SESSION_CONFIG_XSD_PATH`::
>      Tracing session configuration XML schema definition (XSD) path.
>
> +`LTTNG_ABORT_ON_ERROR`::
> +    Abort the session daemon after the first error is encountered.
>
>  FILES
>  -----
> diff --git a/src/common/error.c b/src/common/error.c
> index f7e11e1..84bc04f 100644
> --- a/src/common/error.c
> +++ b/src/common/error.c
> @@ -18,14 +18,23 @@
>  #define _LGPL_SOURCE
>  #include <assert.h>
>  #include <inttypes.h>
> +#include <stdlib.h>
> +#include <string.h>
>
>  #include <lttng/lttng-error.h>
>  #include <common/common.h>
> +#include <common/compat/getenv.h>
>
>  #include "error.h"
>
>  #define ERROR_INDEX(code) (code - LTTNG_OK)
>
> +/*
> + * lttng_opt_abort_on_error: unset: -1, disabled: 0, enabled: 1.
> + * Controlled by the LTTNG_ABORT_ON_ERROR environment variable.
> + */
> +static int lttng_opt_abort_on_error = -1;
> +
>  /* TLS variable that contains the time of one single log entry. */
>  DEFINE_URCU_TLS(struct log_time, error_log_time);
>
> @@ -196,3 +205,22 @@ const char *error_get_str(int32_t code)
>
>         return error_string_array[ERROR_INDEX(code)];
>  }
> +
> +LTTNG_HIDDEN
> +void lttng_abort_on_error(void)
> +{
> +       if (lttng_opt_abort_on_error < 0) {
> +               /* Use lttng_secure_getenv() to query its state. */
> +               const char *value;
> +
> +               value = lttng_secure_getenv("LTTNG_ABORT_ON_ERROR");
> +               if (value && !strcmp(value, "1")) {
> +                       lttng_opt_abort_on_error = 1;
> +               } else {
> +                       lttng_opt_abort_on_error = 0;
> +               }
> +       }
> +       if (lttng_opt_abort_on_error > 0) {
> +               abort();
> +       }
> +}
> diff --git a/src/common/error.h b/src/common/error.h
> index 9c9d2a7..6c239fe 100644
> --- a/src/common/error.h
> +++ b/src/common/error.h
> @@ -89,6 +89,9 @@ extern int lttng_opt_mi;
>                                 ((type) & (PRINT_WARN | PRINT_ERR | PRINT_BUG))) { \
>                         fprintf(stderr, fmt, ## args);                             \
>                 }                                                                  \
> +               if ((type) & (PRINT_ERR | PRINT_BUG)) {                            \
> +                       lttng_abort_on_error();                                    \
> +               }                                                                  \
>         } while (0);
>
>  /* Three level of debug. Use -v, -vv or -vvv for the levels */
> @@ -174,4 +177,6 @@ const char *error_get_str(int32_t code);
>   */
>  const char *log_add_time();
>
> +void lttng_abort_on_error(void);
> +
>  #endif /* _ERROR_H */
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


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

* [lttng-dev] [PATCH lttng-tools 09/10] test: kernel tracing destroy flush behavior with tracefile rotation
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 09/10] test: kernel tracing destroy flush behavior with tracefile rotation Mathieu Desnoyers
@ 2016-05-19  4:45   ` Jérémie Galarneau
  0 siblings, 0 replies; 16+ messages in thread
From: Jérémie Galarneau @ 2016-05-19  4:45 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 6462 bytes --]

Merged, thanks!

Jérémie

On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  tests/regression/kernel/Makefile.am                |   3 +-
>  .../regression/kernel/test_rotation_destroy_flush  | 153 +++++++++++++++++++++
>  tests/root_regression                              |   1 +
>  3 files changed, 156 insertions(+), 1 deletion(-)
>  create mode 100755 tests/regression/kernel/test_rotation_destroy_flush
>
> diff --git a/tests/regression/kernel/Makefile.am b/tests/regression/kernel/Makefile.am
> index ca73ed4..a8c397a 100644
> --- a/tests/regression/kernel/Makefile.am
> +++ b/tests/regression/kernel/Makefile.am
> @@ -1,4 +1,5 @@
> -EXTRA_DIST = test_event_basic test_all_events test_syscall test_clock_override
> +EXTRA_DIST = test_event_basic test_all_events test_syscall \
> +               test_clock_override test_rotation_destroy_flush
>
>  all-local:
>         @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
> diff --git a/tests/regression/kernel/test_rotation_destroy_flush b/tests/regression/kernel/test_rotation_destroy_flush
> new file mode 100755
> index 0000000..0b0b0ca
> --- /dev/null
> +++ b/tests/regression/kernel/test_rotation_destroy_flush
> @@ -0,0 +1,153 @@
> +#!/bin/bash
> +#
> +# Copyright (C) - 2013 Christian Babeux <christian.babeux at efficios.com>
> +# Copyright (C) - 2014, 2016 Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> +#
> +# This program is free software; you can redistribute it and/or modify it
> +# under the terms of the GNU General Public License, version 2 only, as
> +# published by the Free Software Foundation.
> +#
> +# This program 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 General Public License for
> +# more details.
> +#
> +# You should have received a copy of the GNU General Public License along with
> +# this program; if not, write to the Free Software Foundation, Inc., 51
> +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> +
> +TEST_DESC="Kernel tracer - Rotation destroy flush"
> +
> +CURDIR=$(dirname $0)/
> +TESTDIR=$CURDIR/../..
> +SESSION_NAME="rotation_destroy_flush"
> +
> +NR_ITER=10
> +NUM_TESTS=$((13*$NR_ITER))
> +EVENT_NAME="lttng_test_filter_event"
> +CHANNEL_NAME="testchan"
> +PAGE_SIZE=$(getconf PAGE_SIZE)
> +SIZE_LIMIT=$PAGE_SIZE
> +
> +TESTCMD="echo -n 10000 > /proc/lttng-test-filter-event"
> +
> +# Ensure the daemons invoke abort on error.
> +export LTTNG_ABORT_ON_ERROR=1
> +
> +source $TESTDIR/utils/utils.sh
> +
> +function signal_cleanup()
> +{
> +       diag "*** Exiting ***"
> +       rmmod lttng-test
> +       stop_lttng_sessiond
> +       exit 1
> +}
> +
> +function enable_kernel_lttng_channel_size_limit ()
> +{
> +       sess_name="$1"
> +       channel_name="$2"
> +       tracefile_size_limit="$3"
> +
> +       test_name="Enable channel $channel_name "
> +       test_name+="for session $sess_name: "
> +       test_name+="$tracefile_size_limit bytes tracefile limit"
> +
> +       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel \
> +           -k $channel_name -s $sess_name \
> +           -C $tracefile_size_limit >/dev/null 2>&1
> +
> +       ok $? "$test_name"
> +}
> +
> +function enable_kernel_lttng_event_per_channel ()
> +{
> +       sess_name="$1"
> +       event_name="$2"
> +       channel_name="$3"
> +
> +       test_name="Enable event $event_name "
> +       test_name+="for session $sess_name "
> +       test_name+="in channel $channel_name"
> +
> +       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" \
> +           -s $sess_name -k -c $channel_name >/dev/null 2>&1
> +
> +       ok $? "$test_name"
> +}
> +
> +function test_rotation_destroy_flush_single()
> +{
> +       start_lttng_sessiond
> +       modprobe lttng-test
> +
> +       create_lttng_session_ok $SESSION_NAME $TRACE_PATH
> +       enable_kernel_lttng_channel_size_limit \
> +               $SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
> +       enable_kernel_lttng_event_per_channel \
> +               $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
> +       start_lttng_tracing_ok $SESSION_NAME
> +       eval ${TESTCMD}
> +       # stop and destroy
> +       stop_lttng_tracing_ok $SESSION_NAME
> +       destroy_lttng_session_ok $SESSION_NAME
> +
> +       rm -rf $TRACE_PATH
> +
> +       create_lttng_session_ok $SESSION_NAME $TRACE_PATH
> +       enable_kernel_lttng_channel_size_limit \
> +               $SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
> +       enable_kernel_lttng_event_per_channel \
> +               $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
> +       start_lttng_tracing_ok $SESSION_NAME
> +       eval ${TESTCMD}
> +       # destroy only
> +       destroy_lttng_session_ok $SESSION_NAME
> +
> +       rm -rf $TRACE_PATH
> +
> +       rmmod lttng-test
> +       stop_lttng_sessiond
> +}
> +
> +function test_rotation_destroy_flush()
> +{
> +       for a in $(seq 1 ${NR_ITER}); do
> +               diag "Iteration ${a}/${NR_ITER}"
> +               test_rotation_destroy_flush_single
> +       done
> +}
> +
> +# MUST set TESTDIR before calling those functions
> +plan_tests $NUM_TESTS
> +
> +print_test_banner "$TEST_DESC"
> +
> +TESTS=(
> +       "test_rotation_destroy_flush"
> +)
> +
> +TEST_COUNT=${#TESTS[@]}
> +i=0
> +
> +if [ "$(id -u)" == "0" ]; then
> +       isroot=1
> +else
> +       isroot=0
> +fi
> +
> +skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
> +{
> +       trap signal_cleanup SIGTERM SIGINT
> +
> +       while [ "$i" -lt "$TEST_COUNT" ]; do
> +
> +               TRACE_PATH=$(mktemp -d)
> +
> +               # Execute test
> +               ${TESTS[$i]}
> +
> +               let "i++"
> +       done
> +}
> diff --git a/tests/root_regression b/tests/root_regression
> index 4655c09..2981dc6 100644
> --- a/tests/root_regression
> +++ b/tests/root_regression
> @@ -2,6 +2,7 @@ regression/kernel/test_all_events
>  regression/kernel/test_event_basic
>  regression/kernel/test_syscall
>  regression/kernel/test_clock_override
> +regression/kernel/test_rotation_destroy_flush
>  regression/tools/live/test_kernel
>  regression/tools/live/test_lttng_kernel
>  regression/tools/streaming/test_high_throughput_limits
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


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

* [lttng-dev] [PATCH lttng-tools 10/10] test: UST tracing destroy flush behavior with tracefile rotation
  2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 10/10] test: UST " Mathieu Desnoyers
@ 2016-05-19  4:46   ` Jérémie Galarneau
  0 siblings, 0 replies; 16+ messages in thread
From: Jérémie Galarneau @ 2016-05-19  4:46 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 8173 bytes --]

Merged, thanks!

Jérémie

On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers
<mathieu.desnoyers at efficios.com> wrote:
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
>  configure.ac                                       |   1 +
>  tests/fast_regression                              |   1 +
>  tests/regression/ust/Makefile.am                   |   3 +-
>  .../ust/rotation-destroy-flush/Makefile.am         |  16 +++
>  .../test_rotation_destroy_flush                    | 150 +++++++++++++++++++++
>  5 files changed, 170 insertions(+), 1 deletion(-)
>  create mode 100644 tests/regression/ust/rotation-destroy-flush/Makefile.am
>  create mode 100755 tests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush
>
> diff --git a/configure.ac b/configure.ac
> index 20d0680..0c1f976 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1002,6 +1002,7 @@ AC_CONFIG_FILES([
>         tests/regression/ust/getcpu-override/Makefile
>         tests/regression/ust/clock-override/Makefile
>         tests/regression/ust/type-declarations/Makefile
> +       tests/regression/ust/rotation-destroy-flush/Makefile
>         tests/stress/Makefile
>         tests/unit/Makefile
>         tests/unit/ini_config/Makefile
> diff --git a/tests/fast_regression b/tests/fast_regression
> index aa0c043..0c4f079 100644
> --- a/tests/fast_regression
> +++ b/tests/fast_regression
> @@ -27,5 +27,6 @@ regression/ust/java-log4j/test_java_log4j
>  regression/ust/python-logging/test_python_logging
>  regression/ust/getcpu-override/test_getcpu_override
>  regression/ust/clock-override/test_clock_override
> +regression/ust/rotation-destroy-flush/test_rotation_destroy_flush
>  regression/ust/test_event_basic
>  regression/ust/test_event_tracef
> diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am
> index 1b87cc9..7686251 100644
> --- a/tests/regression/ust/Makefile.am
> +++ b/tests/regression/ust/Makefile.am
> @@ -2,7 +2,8 @@ if HAVE_LIBLTTNG_UST_CTL
>  SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \
>                 overlap buffers-pid linking daemon exit-fast fork libc-wrapper \
>                 periodical-metadata-flush java-jul java-log4j python-logging \
> -               getcpu-override clock-override type-declarations
> +               getcpu-override clock-override type-declarations \
> +               rotation-destroy-flush
>
>  if HAVE_OBJCOPY
>  SUBDIRS += baddr-statedump ust-dl
> diff --git a/tests/regression/ust/rotation-destroy-flush/Makefile.am b/tests/regression/ust/rotation-destroy-flush/Makefile.am
> new file mode 100644
> index 0000000..14b869e
> --- /dev/null
> +++ b/tests/regression/ust/rotation-destroy-flush/Makefile.am
> @@ -0,0 +1,16 @@
> +noinst_SCRIPTS = test_rotation_destroy_flush
> +EXTRA_DIST = test_rotation_destroy_flush
> +
> +all-local:
> +       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
> +               for script in $(EXTRA_DIST); do \
> +                       cp -f $(srcdir)/$$script $(builddir); \
> +               done; \
> +       fi
> +
> +clean-local:
> +       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
> +               for script in $(EXTRA_DIST); do \
> +                       rm -f $(builddir)/$$script; \
> +               done; \
> +       fi
> diff --git a/tests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush b/tests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush
> new file mode 100755
> index 0000000..a7a9377
> --- /dev/null
> +++ b/tests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush
> @@ -0,0 +1,150 @@
> +#!/bin/bash
> +#
> +# Copyright (C) - 2015 Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
> +# Copyright (C) - 2016 Mathieu Desnoyers <mathieu.desnoyers at 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; 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
> +TEST_DESC="UST - Rotation destroy flush"
> +
> +CURDIR=$(dirname $0)/
> +TESTDIR=$CURDIR/../../..
> +SESSION_NAME="rotation_destroy_flush"
> +
> +TESTAPP_PATH="$TESTDIR/utils/testapp"
> +TESTAPP_NAME="gen-ust-events"
> +TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
> +NUM_EVENT=1000000
> +EVENT_NAME="tp:tptest"
> +CHANNEL_NAME="testchan"
> +PAGE_SIZE=$(getconf PAGE_SIZE)
> +SIZE_LIMIT=$PAGE_SIZE
> +
> +NR_ITER=10
> +NUM_TESTS=$((15*$NR_ITER))
> +
> +# Ensure the daemons invoke abort on error.
> +export LTTNG_ABORT_ON_ERROR=1
> +
> +source $TESTDIR/utils/utils.sh
> +
> +# MUST set TESTDIR before calling those functions
> +function run_app()
> +{
> +       $TESTAPP_BIN $NUM_EVENT
> +       ok $? "Application done"
> +}
> +
> +function signal_cleanup()
> +{
> +       diag "*** Exiting ***"
> +       stop_lttng_sessiond
> +       exit 1
> +}
> +
> +function enable_ust_lttng_channel_size_limit ()
> +{
> +       sess_name="$1"
> +       channel_name="$2"
> +       tracefile_size_limit="$3"
> +
> +       test_name="Enable channel $channel_name "
> +       test_name+="for session $sess_name: "
> +       test_name+="$tracefile_size_limit bytes tracefile limit"
> +
> +       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel \
> +           -u $channel_name -s $sess_name --buffers-pid \
> +           -C $tracefile_size_limit >/dev/null 2>&1
> +
> +       ok $? "$test_name"
> +}
> +
> +function enable_ust_lttng_event_per_channel ()
> +{
> +       sess_name="$1"
> +       event_name="$2"
> +       channel_name="$3"
> +
> +       test_name="Enable event $event_name "
> +       test_name+="for session $sess_name "
> +       test_name+="in channel $channel_name"
> +
> +       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" \
> +           -s $sess_name -u -c $channel_name >/dev/null 2>&1
> +
> +       ok $? "$test_name"
> +}
> +
> +function test_rotation_destroy_flush_single()
> +{
> +       start_lttng_sessiond
> +
> +       create_lttng_session_ok $SESSION_NAME $TRACE_PATH
> +       enable_ust_lttng_channel_size_limit \
> +               $SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
> +       enable_ust_lttng_event_per_channel \
> +               $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
> +       start_lttng_tracing_ok $SESSION_NAME
> +       run_app
> +       # stop and destroy
> +       stop_lttng_tracing_ok $SESSION_NAME
> +       destroy_lttng_session_ok $SESSION_NAME
> +
> +       rm -rf $TRACE_PATH
> +
> +       create_lttng_session_ok $SESSION_NAME $TRACE_PATH
> +       enable_ust_lttng_channel_size_limit \
> +               $SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
> +       enable_ust_lttng_event_per_channel \
> +               $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
> +       start_lttng_tracing_ok $SESSION_NAME
> +       run_app
> +       # destroy only
> +       destroy_lttng_session_ok $SESSION_NAME
> +
> +       rm -rf $TRACE_PATH
> +
> +       stop_lttng_sessiond
> +}
> +
> +function test_rotation_destroy_flush()
> +{
> +       for a in $(seq 1 ${NR_ITER}); do
> +               diag "Iteration ${a}/${NR_ITER}"
> +               test_rotation_destroy_flush_single
> +       done
> +}
> +
> +
> +plan_tests $NUM_TESTS
> +
> +print_test_banner "$TEST_DESC"
> +
> +TESTS=(
> +       "test_rotation_destroy_flush"
> +)
> +
> +TEST_COUNT=${#TESTS[@]}
> +i=0
> +
> +while [ "$i" -lt "$TEST_COUNT" ]; do
> +
> +       trap signal_cleanup SIGTERM SIGINT
> +
> +       TRACE_PATH=$(mktemp -d)
> +
> +       # Execute test
> +       ${TESTS[$i]}
> +
> +       let "i++"
> +done
> --
> 2.1.4
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com


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

end of thread, other threads:[~2016-05-19  4:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-18 18:04 [lttng-dev] [PATCH lttng-tools 00/10] Fix: tracefile rotation rm-after-destroy race Mathieu Desnoyers
2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 06/10] Fix: error.h: add missing parenthesis around macro parameter Mathieu Desnoyers
2016-05-19  4:13   ` Jérémie Galarneau
2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 07/10] Fix: WARN() should print as WARN level, not ERR Mathieu Desnoyers
2016-05-19  4:14   ` Jérémie Galarneau
2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 08/10] Add environment variable to allow abort on error Mathieu Desnoyers
2016-05-19  4:45   ` Jérémie Galarneau
2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 09/10] test: kernel tracing destroy flush behavior with tracefile rotation Mathieu Desnoyers
2016-05-19  4:45   ` Jérémie Galarneau
2016-05-18 18:04 ` [lttng-dev] [PATCH lttng-tools 10/10] test: UST " Mathieu Desnoyers
2016-05-19  4:46   ` Jérémie Galarneau
     [not found] ` <1463594659-10964-2-git-send-email-mathieu.desnoyers@efficios.com>
2016-05-19  2:57   ` [lttng-dev] [PATCH lttng-tools 01/10] Fix: bad file descriptors on close after rotation error Jérémie Galarneau
     [not found] ` <1463594659-10964-3-git-send-email-mathieu.desnoyers@efficios.com>
2016-05-19  4:09   ` [lttng-dev] [PATCH lttng-tools 02/10] Fix: UST should not generate packet at destroy after stop Jérémie Galarneau
     [not found] ` <1463594659-10964-4-git-send-email-mathieu.desnoyers@efficios.com>
2016-05-19  4:09   ` [lttng-dev] [PATCH lttng-tools 03/10] Fix: kernel tracing: flush " Jérémie Galarneau
     [not found] ` <1463594659-10964-5-git-send-email-mathieu.desnoyers@efficios.com>
2016-05-19  4:12   ` [lttng-dev] [PATCH lttng-tools 04/10] Fix: ust-consumer: flush empty packets on snapshot channel Jérémie Galarneau
     [not found] ` <1463594659-10964-6-git-send-email-mathieu.desnoyers@efficios.com>
2016-05-19  4:12   ` [lttng-dev] [PATCH lttng-tools 05/10] Fix: bogus mask on error.h PRINT types Jérémie Galarneau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox