Fix: bad file descriptors on close after rotation error
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/10 Fix: bad file descriptors on close after rotation error
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.
--- src/common/utils.c | 1 + 1 file changed, 1 insertion(+)
src/common/utils.c +1 -0
@@ -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 ) {/*
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 2/10 Fix: UST should not generate packet at destroy after stop
In reply to a message not in the archiveIn 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.
--- 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(-)
src/bin/lttng-sessiond/consumer.c +32 -0
@@ -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. *
src/bin/lttng-sessiond/consumer.h +1 -0
@@ -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,
src/bin/lttng-sessiond/ust-app.c +142 -0
154 lines not on this page · raw message
src/common/consumer/consumer.h +13 -0
@@ -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. +*/ +bool quiescent; + +/* * metadata_timer_lock protects flags waiting_on_metadata and * missed_metadata_flush. */
src/common/sessiond-comm/sessiond-comm.h +3 -0
@@ -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;
src/common/ust-consumer/ust-consumer.c +65 -2
85 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 3/10 Fix: kernel tracing: flush after stop
In reply to a message not in the archiveWe 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.
--- src/bin/lttng-sessiond/cmd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
src/bin/lttng-sessiond/cmd.c +10 -10
@@ -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 ; }
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 4/10 Fix: ust-consumer: flush empty packets on snapshot channel
In reply to a message not in the archiveSnapshot 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.
--- src/common/ust-consumer/ust-consumer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
src/common/ust-consumer/ust-consumer.c +7 -1
@@ -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 ) {
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 5/10 Fix: bogus mask on error.h PRINT types
In reply to a message not in the archivePRINT_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.
--- src/common/error.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
src/common/error.h +7 -7
@@ -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.
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 6/10 Fix: error.h: add missing parenthesis around macro parameter
In reply to a message not in the archive--- src/common/error.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
src/common/error.h +6 -6
@@ -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);
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 7/10 Fix: WARN() should print as WARN level, not ERR
In reply to a message not in the archive--- src/common/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/common/error.h +1 -1
@@ -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)
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 8/10 Add environment variable to allow abort on error
In reply to a message not in the archiveThe 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.
--- 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(+)
doc/man/common-cmd-footer.txt +3 -0
@@ -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
doc/man/lttng-relayd.8.txt +3 -0
@@ -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 -----
doc/man/lttng-sessiond.8.txt +2 -0
@@ -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 -----
src/common/error.c +28 -0
@@ -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 (); + } +}
src/common/error.h +5 -0
@@ -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 */
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 9/10 test: kernel tracing destroy flush behavior with tracefile rotation
In reply to a message not in the archive--- 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
tests/regression/kernel/Makefile.am +2 -1
@@ -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 \
tests/regression/kernel/test_rotation_destroy_flush new file +153 -0
153 lines not on this page · raw message
tests/root_regression +1 -0
@@ -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
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 10/10 test: UST tracing destroy flush behavior with tracefile rotation
In reply to a message not in the archive--- 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
configure.ac +1 -0
@@ -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
tests/fast_regression +1 -0
@@ -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
tests/regression/ust/Makefile.am +2 -1
@@ -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
tests/regression/ust/rotation-destroy-flush/Makefile.am new file +16 -0
@@ -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
tests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush new file +150 -0
150 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jérémie Galarneau
AppliedMerged, thanks!
Jérémie
Quoted 25 lines · Mathieu Desnoyers
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 <[email protected]>--- src/common/utils.c | 1 + 1 file changed, 1 insertion(+)src/common/utils.c +1
-1@@ -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
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH lttng-tools 02/10] Fix: UST should not generate packet at destroy after stop
Quoted 119 lines · Mathieu Desnoyers
In the following scenario:
- create, enable events (ust),
- start
- ...
- stop (await fordata_pendingto complete)
- destroy
- rm the trace directoryWe 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_pendingcheck (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 <[email protected]>--- 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(-)src/bin/lttng-sessiond/consumer.c +32
-0@@ -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. * src/bin/lttng-sessiond/consumer.h +1
-0@@ -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,src/bin/lttng-sessiond/ust-app.c +17
-0@@ -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; + } +
src/bin/lttng-sessiond/ust-app.c int ust_app_flush_session(struct ltt_ust_session *usess) · line 4679
Quoted 10 lines
src/bin/lttng-sessiond/ust-app.c +10
-0+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.
src/bin/lttng-sessiond/ust-app.c int ust_app_flush_session(struct ltt_ust_session *usess) · line 4690
Quoted 11 lines
src/bin/lttng-sessiond/ust-app.c +11
-0+ +/* 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.
Quoted 128 lines
src/bin/lttng-sessiond/ust-app.c +104
-0+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 ) {src/common/consumer/consumer.h +1
-0@@ -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;
src/common/consumer/consumer.h struct lttng_consumer_stream { · line 261
Quoted 10 lines
src/common/consumer/consumer.h +8
-0/* +* 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
Quoted 116 lines
src/common/consumer/consumer.h +4
-0+*/ +bool quiescent; + +/* * metadata_timer_lock protects flags waiting_on_metadata and * missed_metadata_flush. */ src/common/sessiond-comm/sessiond-comm.h +3
-0@@ -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;src/common/ust-consumer/ust-consumer.c +65
-3@@ -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
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH lttng-tools 03/10] Fix: kernel tracing: flush after stop
Good catch, merged!
Thanks,
Jérémie
Quoted 57 lines · Mathieu Desnoyers
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 <[email protected]>--- src/bin/lttng-sessiond/cmd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)src/bin/lttng-sessiond/cmd.c +10
-11@@ -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
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jérémie Galarneau
AppliedRe: [PATCH lttng-tools 04/10] Fix: ust-consumer: flush empty packets on snapshot channel
Merged, thanks!
Jérémie
Quoted 33 lines · Mathieu Desnoyers
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 <[email protected]>--- src/common/ust-consumer/ust-consumer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)src/common/ust-consumer/ust-consumer.c +7
-2@@ -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
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH lttng-tools 05/10] Fix: bogus mask on error.h PRINT types
Good catch, merged!
Thanks!
Jérémie
Quoted 44 lines · Mathieu Desnoyers
PRINT_ERRmaps to0x1,PRINT_WARNmaps to0x2, which is fine so far to use as masks, butPRINT_BUGmaps to0x3, which is the same as bothPRINT_ERRandPRINT_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_BUGhas 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 <[email protected]>--- src/common/error.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)src/common/error.h +7
-8@@ -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
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jérémie Galarneau
AppliedRe: [PATCH lttng-tools 06/10] Fix: error.h: add missing parenthesis around macro parameter
Merged, thanks!
Jérémie
Quoted 37 lines · Mathieu Desnoyers
Signed-off-by Mathieu Desnoyers <[email protected]>--- src/common/error.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)src/common/error.h +6
-7@@ -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
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH lttng-tools 07/10] Fix: WARN() should print as WARN level, not ERR
Good catch (again)! Merged.
Thanks,
Jérémie
Quoted 21 lines · Mathieu Desnoyers
Signed-off-by Mathieu Desnoyers <[email protected]>--- src/common/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/common/error.h +1
-2@@ -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
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH lttng-tools 08/10] Add environment variable to allow abort on error
Merged with some documentation changes, thanks!
Jérémie
Quoted 129 lines · Mathieu Desnoyers
The new environment variable
LTTNG_ABORT_ON_ERRORallows each lttng-tools program to callabort()onPERROR()andERR()after the error message has been printed to stderr.Signed-off-by Mathieu Desnoyers <[email protected]>--- 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(+)doc/man/common-cmd-footer.txt +3
-0@@ -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 influencingdoc/man/lttng-relayd.8.txt +3
-0@@ -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 -----doc/man/lttng-sessiond.8.txt +2
-0@@ -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 -----src/common/error.c +28
-0@@ -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 (); + } +}src/common/error.h +5
-1@@ -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
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): 1463594659-10964-10-git-send-email-mathieu.desnoyers@efficios.com
Jérémie Galarneau
AppliedRe: [PATCH lttng-tools 09/10] test: kernel tracing destroy flush behavior with tracefile rotation
Merged, thanks!
Jérémie
Quoted 193 lines · Mathieu Desnoyers
Signed-off-by Mathieu Desnoyers <[email protected]>--- 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_flushtests/regression/kernel/Makefile.am +2
-1@@ -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 \tests/regression/kernel/test_rotation_destroy_flush new file +153
-0@@ -0,0 +1,153 @@ +#!/bin/bash +# +# Copyright (C) - 2013 Christian Babeux <[email protected]> +# Copyright (C) - 2014, 2016 Mathieu Desnoyers <[email protected]> +# +# 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 +}tests/root_regression +1
-1@@ -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
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): 1463594659-10964-11-git-send-email-mathieu.desnoyers@efficios.com
Jérémie Galarneau
AppliedRe: [PATCH lttng-tools 10/10] test: UST tracing destroy flush behavior with tracefile rotation
Merged, thanks!
Jérémie
Quoted 229 lines · Mathieu Desnoyers
Signed-off-by Mathieu Desnoyers <[email protected]>--- 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_flushconfigure.ac +1
-0@@ -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/Makefiletests/fast_regression +1
-0@@ -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_traceftests/regression/ust/Makefile.am +2
-1@@ -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-dltests/regression/ust/rotation-destroy-flush/Makefile.am new file +16
-0@@ -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; \ + fitests/regression/ust/rotation-destroy-flush/test_rotation_destroy_flush new file +150
-1@@ -0,0 +1,150 @@ +#!/bin/bash +# +# Copyright (C) - 2015 Jonathan Rajotte <[email protected]> +# Copyright (C) - 2016 Mathieu Desnoyers <[email protected]> +# +# 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
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev