Francis Deslauriers [Wed, 27 Jun 2018 19:23:59 +0000 (15:23 -0400)]
Cleanup: move session saving of K(ret)probe and function tracing to dedicated functions
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Wed, 27 Jun 2018 15:35:42 +0000 (11:35 -0400)]
Implement ELF function offset extraction function
Add lttng_elf_get_symbol_offset function to compute the offset of
given symbol in a given binary.
This function parses the ELF file backing the file descriptor received.
We first find the symbol table section to cross-reference it with the
string table section to find the symbol with the name matching the named
received from the caller. Once we finds the symbol, we use its virtual
address to find the offset of the function from the beginning of the
file on disk.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Wed, 27 Jun 2018 14:47:41 +0000 (10:47 -0400)]
Add utils_expand_path_keep_symlink fonction
This function mimics the behaviour of utils_expand_path() but omits to
expand symbolic links. This is useful to keep the full path to a
user-provided path, which can contain a symlink.
We will use this of the lttng-save of sessions containing
userspace-probe.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 27 Jun 2017 21:21:35 +0000 (17:21 -0400)]
Fix: kernel adds creds on recv with SO_PASSCRED unix socket option
When a Unix socket is configured with the SO_PASSCRED option, the caller
of recv() will receive a credential control message even if the sender
did not manually include it.
This caused problem with the old implementation of the
lttcomm_recv_fds_unix_sock function since it was expecting only one
control message for the fd passing. With the SO_PASSCRED, the kernel
will add a credential(SCM_CREDENTIALS) control message before the fd
passing(SCM_RIGHTS) control message (function scm_recv() [1]).
As a fix, make the receiver have a large enough before to include both
types of message and ignore the credential control message.
[1]: include/net/scm.h:111
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 17 Oct 2017 21:22:43 +0000 (17:22 -0400)]
lttng-ctl: implement listing of userspace probe locations
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 17 Oct 2017 21:24:41 +0000 (17:24 -0400)]
Add invalid userspace probe location error
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 17 Oct 2017 21:22:02 +0000 (17:22 -0400)]
Fix: memory is not zeroed on first set_capacity
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 17 Oct 2017 21:18:14 +0000 (17:18 -0400)]
Add a util to create a buffer view from a raw buffer
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 17 Oct 2017 03:48:21 +0000 (23:48 -0400)]
Fix: dynamic buffer mishandles setting capacity to 0
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 16 Oct 2017 19:40:42 +0000 (15:40 -0400)]
lttng-ctl: send userspace probe location on enable_event
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 16 Oct 2017 16:18:17 +0000 (12:18 -0400)]
lttng-ctl: locate extended event attributes at reception
Locate the lttng_event's extended attributes at the time of
reception instead of locating them on access. This is mostly
preparation work for the addition of userspace probe locations
to the protocol.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Sun, 15 Oct 2017 21:06:49 +0000 (17:06 -0400)]
Add utils to send file descriptors to the sessiond
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Sun, 15 Oct 2017 20:31:07 +0000 (16:31 -0400)]
lttng-ctl: add accessors of userspace probe location to lttng_event
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Sun, 15 Oct 2017 20:14:29 +0000 (16:14 -0400)]
lttng-ctl: add userspace probe location interface
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Jérémie Galarneau [Tue, 17 Oct 2017 21:21:10 +0000 (17:21 -0400)]
Add lttng_dynamic_buffer_get_capacity_left util
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 17 Oct 2017 21:18:36 +0000 (17:18 -0400)]
Add ALIGN_TO util to macros.h
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Sun, 15 Oct 2017 20:12:35 +0000 (16:12 -0400)]
lttng-ctl: add an lttng_event_extended distinct from communication structures
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Sun, 15 Oct 2017 20:07:29 +0000 (16:07 -0400)]
lttng-ctl: move lttng_event functions to a new file
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 24 Aug 2018 18:09:52 +0000 (14:09 -0400)]
Tests: possible NULL dereference in rotation notification test
Reported-by: Coverity Scan (1395166 Dereference after null check)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 24 Aug 2018 18:06:55 +0000 (14:06 -0400)]
Clean-up: remove dead code from rotation test
Reported-by: Coverity Scan (1395165 Logically dead code)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 24 Aug 2018 01:51:25 +0000 (21:51 -0400)]
Fix: size of concrete class used in memcpy of base class
session rotation condition and evaluation objects' base
class is initialized from a template to set the various
method's function pointers to the functions implementing
their interface.
The memcpy() erroneously uses the "derived" class' size through
sizeof(*obj) rather than the size of the base class through
sizeof(obj->parent).
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:26:07 +0000 (13:26 -0400)]
Tests: add a session rotation ongoing/completed notification test
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 24 Aug 2018 01:13:48 +0000 (21:13 -0400)]
Clean-up: remove useless check of event name
'name' in the lttng_event structure is a fixed-size array, which
will cause this condition to always evaluate to true.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 24 Aug 2018 01:10:28 +0000 (21:10 -0400)]
Fix: mix of lttng_error_code and cmd_error_code enums
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 24 Aug 2018 00:35:58 +0000 (20:35 -0400)]
Add notification session rotation hooks
Add hooks to inform the notification subsystem of session rotation
state changes (ongoing or completed). This allows the notification
system to track the rotation state and inform clients that are
subscribed to those conditions.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 23 Aug 2018 23:08:40 +0000 (19:08 -0400)]
Implement rotation command handlers in notification system
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 23 Aug 2018 23:06:15 +0000 (19:06 -0400)]
Fix: return 0 on successful location serialization
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 23 Aug 2018 23:05:52 +0000 (19:05 -0400)]
Fix: return size from location deserialization function
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 23 Aug 2018 23:03:54 +0000 (19:03 -0400)]
Add a trace archive location accessor to the session API
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 23 Aug 2018 22:55:38 +0000 (18:55 -0400)]
Fix: notification channel not released on error path
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 21 Aug 2018 19:48:36 +0000 (15:48 -0400)]
Implement rotation ongoing/completed commands
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Sat, 18 Aug 2018 03:10:22 +0000 (23:10 -0400)]
Fix: remove session_info from sessions_ht on destruction
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 19:37:54 +0000 (15:37 -0400)]
Bind newly registered triggers to session or channel objects
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:26:04 +0000 (13:26 -0400)]
Docs: clarify the contents of channel_infos_ht
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:26:01 +0000 (13:26 -0400)]
Add a hashing function for session rotation conditions
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:58 +0000 (13:25 -0400)]
Build a list of triggers applying to a given session on creation
A hash table associating session names (which are unique) to
a lttng_session_trigger_list object is added to the notification
subsystem. This hash table is populated on the creation of a
session and a list is initialized with matching triggers known
at that time.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:56 +0000 (13:25 -0400)]
Add a comment clarifying the ownership of triggers
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:53 +0000 (13:25 -0400)]
Fix: use condition's type to compute its hash
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:51 +0000 (13:25 -0400)]
Cleanup: enforce const-correctness in notification thread
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:49 +0000 (13:25 -0400)]
Fix: add session_info object to sessions_ht
The notification subsystem currently does not add the session_info
structures it uses to account for session consumed sizes to its
sessions_ht. This means that a new internal session is created
for every channel, resulting in an incorrect accounting of
session consumed sizes, and thus delayed rotations.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:46 +0000 (13:25 -0400)]
Add session rotation ongoing/completed notification commands
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:44 +0000 (13:25 -0400)]
Add session rotation ongoing/completed conditions
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:41 +0000 (13:25 -0400)]
Fix: use the correct condition type in logging statements
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:39 +0000 (13:25 -0400)]
Add a by-address equality short-circuit to condition comparison
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:36 +0000 (13:25 -0400)]
Fix: assume that conditions are valid before being compared
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:33 +0000 (13:25 -0400)]
Cleanup: remove superfluous argument to consumed size create
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:27 +0000 (13:25 -0400)]
Docs: prefer 'release' to 'free' in API documentation
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:21 +0000 (13:25 -0400)]
Add trace archive location serialization/deserialization methods
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 17:25:16 +0000 (13:25 -0400)]
Tests: add notap versions of start/stop tracing helpers
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 22 Aug 2018 20:26:27 +0000 (16:26 -0400)]
Tests: typo in notification test case description
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 21 Aug 2018 20:56:19 +0000 (16:56 -0400)]
Use the dynamic buffer to serialize notification objects
The objects of the notification/trigger APIs are currently
serialized by calling their serialization functions with a NULL
buffer, returning the expected size, and then calling the
serialization function with a sufficiently-large buffer.
This code predates the dynamic buffer utility which can now be
used to perform serialization operations in one pass.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 21:32:46 +0000 (17:32 -0400)]
Fix: consumers don't honor protocol on rotate pending relay command
The payload of a command should not be sent to the sessiond if
its execution failed. The sessiond reports an error as soon as
the return code of the command is returned and will never consume
the payload, resulting in a protocol error down the line.
Moreover, the ust-consumer's implementation doesn't check for
errors as it stores the return value of
lttng_consumer_rotate_pending_relay() to an unsigned variable and
checks for negative values.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 21:14:06 +0000 (17:14 -0400)]
Fix: client_list_element leak on failure to evaluate a condition
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 20:45:09 +0000 (16:45 -0400)]
Fix: possible NULL dereference in uri_parse_str_urls()
The data_url parsing of uri_parse_str_urls assumes that a ctrl
URL was provided to check that both URLs point to the same
destination. A check for 'ctrl_uris != NULL' is added, but this
function needs to be refactored at some point at it is not clear
what its role is (i.e. it's probably doing too much).
Reported-by: Coverity Scan (1378214 Explicit null dereferenced)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 20:37:46 +0000 (16:37 -0400)]
Typo fix in uri parsing error logging
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 19:54:57 +0000 (15:54 -0400)]
Fix: unchecked return value of cds_lfht_destroy
The sessiond should assert that cds_lfht_destroy returns 0 when
tearing down the 'pending rotate channel' hash table as a non-zero
value would indicate a leak.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 19:50:48 +0000 (15:50 -0400)]
Fix: clean-up sessiond condig structure on initialization error
The sessiond configuration structure's initialization may fail,
leaving some fields allocated and others to NULL. On error, the
structure should be cleaned-up to prevent a leak.
This allows the rest of the code to assume that all configuration
options are not NULL.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 19:22:53 +0000 (15:22 -0400)]
Fix: unchecked return value in sessiond path configuration
The return values of the functions setting the sessiond's
base paths are not checked.
Reported-by: Coverity Scan (1382768 and 1382769, Unused value)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 19:17:05 +0000 (15:17 -0400)]
Fix: path leak on formatting error
'tmp_path' is leaked if 'snprintf()' reports an error.
Reported-by: Coverity Scan (1387044 Resource leak)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 19:12:13 +0000 (15:12 -0400)]
Fix: use of uninitialized 'nb_pipes_fd'
nb_pipes_fd can be used uninitialized in the consumers' data polling
threads if 'consumer_data.need_update' is false.
In practice, this is not a problem as 'consumer_data.need_update'
is true on the first execution of the thread's loop.
Reported-by: Coverity Scan (1387046 Uninitialized scalar variable)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 19:05:13 +0000 (15:05 -0400)]
Clean-up: useless assert that unsigned value is >= 0
Reported-by: Coverity Scan (1387048 Macro compares unsigned to 0)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 18:57:04 +0000 (14:57 -0400)]
Test fix: size schedule leaked in a schedule API test case
Reported-by: Coverity Scan (1395071 and 1395073 Resource leak)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 20 Aug 2018 18:51:45 +0000 (14:51 -0400)]
Fix: unreported error on rotate timer stop failure
A missing 'goto end' causes errors occuring when stopping
the sessiond's rotate timer to be ignored as the switch-case's
case breaks and the 'ret' value is set to LTTNG_OK.
Reported-by: Coverity Scan (1395074 Unused value)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 02:41:49 +0000 (22:41 -0400)]
save/load: support session rotation schedule descriptors
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 00:48:28 +0000 (20:48 -0400)]
mi: serialize relay rotation locations
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 Aug 2018 00:47:42 +0000 (20:47 -0400)]
Fix: use negative code for errors in enum
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 16 Aug 2018 20:01:11 +0000 (16:01 -0400)]
Add rotate-client to .gitignore
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 15 Aug 2018 20:42:43 +0000 (16:42 -0400)]
Docs: adapt the rotation client example to the API changes
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 8 Aug 2018 21:48:24 +0000 (17:48 -0400)]
Remove generic error reporting from the lttng client
Unsuccessful command results are reported by the lttng client
which often results in strange error messages of the form:
Error: Could not rotate ...
Error: Command error
Considering that most commands correctly report their errors,
it is safe to remove those generic error reports.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 7 Aug 2018 18:33:27 +0000 (14:33 -0400)]
Test: session rotation schedule API
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 6 Aug 2018 20:36:12 +0000 (16:36 -0400)]
rotation-api: introduce rotation schedule descriptors
The current rotation API is limited in that it imposes two types
of automatic rotation. This change introduces rotation schedules,
a more generic concept, that will eventually allow an arbitrary
number of rotation schedules to be set on a session.
Moreover, the API's design is now more aligned with the APIs
that were recently added (i.e. use of opaque descriptors for
commands that may require more parameters at some point).
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 1 Aug 2018 20:49:46 +0000 (16:49 -0400)]
rotation-api: pass session name explicitly
The session name is currently passed to the rotation API commands
through the attribute descriptors. However, the session name is
an attribute that is always required and passing it explicitly
allows users to perform immediate rotations without allocating
an immediate rotation attribute descriptor.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 20 Jul 2018 22:41:49 +0000 (18:41 -0400)]
Set consumer's verbosity to the max level on --verbose-consumer
The consumer's verbosity is set to '1' when --verbose-consumer
is used when launching the session daemon. This means that all
DBG2/3() statements are ignored.
This commit always sets the consumer's verbosity to the maximal
level.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 10 Jul 2018 18:36:44 +0000 (14:36 -0400)]
Fix: Tests: use -no-pie linker option only when available
Issue
=====
To keep the userspace callstack tests simple, we want to prevent the
testapp to be linked as a Position Independent Execution (PIE) binary as
it is simpler to resolve the addresses of functions. Some distributions
now ship GCC built with the --enable-default-pie option which turns on
PIE by default. To prevent that, we use the -no-pie linker flag when
building the gen-syscall-events-callstack testapp. The issue is that
this flag is not available on older version of GCC thus triggering an
error when building the project.
gcc: error: unrecognized command line option ‘-no-pie’
Solution
========
Test for the availability of the -no-pie option at the configure time
and enable it only when found. If the option is unavailable we assume
that the -pie option is not enabled by default thus removing the need to
prevent its usage with -no-pie in the first place.
Known drawbacks
===============
None
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 13 Jun 2018 00:13:48 +0000 (20:13 -0400)]
Fix: check for removal of session's shm_path in destroy()
When a session is created with an explicit shm_path,
the consumer daemon will create its shared memory files
at that location and will *not* unlink them. This is normal
as the intention of that feature is to make it possible
to retrieve the content of those files should a crash occur.
To ensure the content of those files can be used, the
sessiond daemon will replicate the content of the metadata
cache in a metadata file.
On clean-up, it is expected that the consumer daemon will
unlink the shared memory files and that the session daemon
will unlink the metadata file. Then, the session's directory
in the shm path can be removed.
Unfortunately, a flaw in the design of the sessiond's and
consumerd's tear down of channels makes it impossible to
determine when the sessiond _and_ the consumerd have both
destroyed their representation of a channel. For one, the
unlinking, close, and rmdir happen in deferred 'call_rcu'
callbacks in both daemons.
However, it is also impossible for the sessiond to know when
the consumer daemon is done destroying its channel(s) since
it occurs as a reaction to the closing of the channel's file
descriptor. There is no resulting communication initiated
from the consumerd to the sessiond to confirm that the
operation is completed (and was successful).
Until this is all fixed, the session daemon checks for the
removal of the session's shm path which makes it possible
to safely advertise a session as having been destroyed.
Prior to this fix, it was not possible to reliably save
a session making use of the --shm-path option, destroy it,
and load it again. This is because the creation of the
session would fail upon seeing the session's shm path
already in existence.
Note that none of the error paths in the check for the
directory's existence return an error. This is normal
as there isn't much that can be done. The session will
be destroyed properly, except that we can't offer the
guarantee that the same session can be re-created.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 12 Jun 2018 21:16:32 +0000 (17:16 -0400)]
Document the contents of the shm_path fields of the ust session registry
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 5 Jun 2018 16:06:53 +0000 (12:06 -0400)]
Implement MI and save/load support for callstack contexts
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Thu, 8 Jun 2017 21:15:06 +0000 (17:15 -0400)]
Tests: Add callstack contexts tests
Tests callstack-user and callstack-kernel contexts by tracing with those
contexts an application that calls multiple functions in chain before
executing a system call.
callstack-user addresses are tested against the output of coreutils'
addr2line.
callstack-kernel addresses are tested against the addresses of kernel
symbols available in the /proc/kallsyms procfile.
Both these tests need to be run by root because those contexts are made
available by the kernel tracer. The callstack-kernel test also need to
access /proc/kallsyms.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Giraldeau [Wed, 17 Jul 2013 21:06:23 +0000 (17:06 -0400)]
Add kernel and userspace callstack event context
LTTng callstack context. The callstack context can be added to any kernel
channel. It records either the kernel or the userspace callstack, up to a
max depth. The context is a CTF sequence, such that it uses only the space
required for the number of callstack entries.
The symbol name resolution is left to the trace reader.
Signed-off-by: Francis Giraldeau <francis.giraldeau@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 5 Jun 2018 14:57:48 +0000 (10:57 -0400)]
Fix: missing context enum values in session xml schema
Handling of the following enum are added:
LTTNG_EVENT_CONTEXT_INTERRUPTIBLE
LTTNG_EVENT_CONTEXT_PREEMPTIBLE
LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE
LTTNG_EVENT_CONTEXT_MIGRATABLE
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Philippe Proulx [Mon, 25 Sep 2017 19:18:41 +0000 (15:18 -0400)]
lttng-enable-event(1): update the Filter expression section
This patch documents new features of filter expressions:
* Bracket and dot notations to get nested fields.
* New bitwise operators.
* Custom operator precedence table.
* Formal rules for how integers are represented for the sake of
the evaluation (casted to signed/unsigned 64-bit integers depending
on the operator).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Mon, 25 Sep 2017 20:22:57 +0000 (16:22 -0400)]
Filter: document ust app ctx limitation
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Mon, 25 Sep 2017 13:50:49 +0000 (09:50 -0400)]
Filter: add FILTER_OP_RETURN_S64 instruction
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Fri, 22 Sep 2017 21:38:13 +0000 (17:38 -0400)]
Filter: make bitwise and, or, xor higher prio than relational expressions
It seems that the usual use-case for bitwise ops are to apply them on
values rather than on the result of equality/inequality. Therefore, move
away from the C operator precedence order, and ensure bitwise and, or,
xor are higher priority than relational expressions (equality and
inequality).
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Fri, 22 Sep 2017 21:14:16 +0000 (17:14 -0400)]
Filter: Update shifting tests
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Fri, 22 Sep 2017 00:53:01 +0000 (20:53 -0400)]
Add () for bitwise and comparator tests
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Fri, 22 Sep 2017 00:13:17 +0000 (20:13 -0400)]
Filter: Implement rshift, lshift, bit not operators
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Thu, 21 Sep 2017 20:29:10 +0000 (16:29 -0400)]
Filters: generate backward compatible "get field" and "get context" instructions
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Tue, 4 Jul 2017 20:28:54 +0000 (16:28 -0400)]
Filter: index array, sequences, implement bitwise binary operators
Add load expressions, and produce bytecode allowing indexing of array
and sequence of integers, as well as bitwise binary operators &, |, ^.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Thu, 22 Jun 2017 20:17:54 +0000 (16:17 -0400)]
Implement support for brackets in filter expressions
Extends the bytecode with new instructions.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Anders Wallin [Thu, 17 May 2018 20:50:41 +0000 (22:50 +0200)]
Tests: add session auto-loading test cases
lttng-sessiond can auto load sessions at startup;
- with "--load" option to lttng-sessiond, load one file
or all sessions files in that directory
- from session files in $LTTNG_HOME/.lttng/sessions/auto/
- from session files in $sysconfdir/lttng/sessions/auto
This test case validates the two first scenarios.
Signed-off-by: Anders Wallin <wallinux@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Tue, 5 Jun 2018 16:11:20 +0000 (12:11 -0400)]
Replace deprecated readdir_r() with readdir()
readdir_r() has been deprecated since glibc 2.24 [1].
We used readdir_r() in load_session_from_path() to be thread-safe
since this function is part of liblttng-ust-ctl. However, according
to readdir()'s man page, it's thread-safe as long as the directory
stream it operates on is not shared across threads :
In the current POSIX.1 specification (POSIX.1-2008), readdir(3) is
not required to be thread-safe. However, in modern
implementations (including the glibc implementation), concurrent
calls to readdir(3) that specify different directory streams are
thread-safe. Therefore, the use of readdir_r() is generally
unnecessary in multithreaded programs. In cases where multiple
threads must read from the same directory stream, using readdir(3)
with external synchronization is still preferable to the use of
readdir_r(), for the reasons given in the points above.
In our use-case where we open the directory stream in the same function,
we know it won't be shared across threads and thus it's safe to use
readdir(). Here is the relevevant bit from the POSIX.1 [2] spec :
The returned pointer, and pointers within the structure, might be
invalidated or the structure or the storage areas might be overwritten
by a subsequent call to readdir() on the same directory stream. They shall
not be affected by a call to readdir() on a different directory stream.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=19056
[2] http://pubs.opengroup.org/onlinepubs/
9699919799/functions/readdir.html
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Mon, 28 May 2018 21:31:48 +0000 (17:31 -0400)]
Bash completion: ignore namespace for xmllint parsing
xmllint cli does not "easily" support namespace.
One can use the local_name() xpath function and other "trick".
The simplest trick for bash completion is to ignore the namespace
altogether.
Replacing "xmlns" by "ignore" does the job.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 5 Jun 2018 15:38:08 +0000 (11:38 -0400)]
Use https in links to the lttng.org website
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 10 May 2018 21:31:10 +0000 (17:31 -0400)]
Log the session to which a ROTATE_PENDING command applies
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 10 May 2018 21:14:39 +0000 (17:14 -0400)]
Initialize relay_stream chunk_id to its session's current trace archive id
Initializing the relayd's streams with a stream_chunk_id allows the
relayd to differentiate between a stream created before the first
rotation (at chunk id == 0) vs. a stream that has been created
after the last (or pending) rotation.
Before this fix, the relayd can fail to identify that a rotation
has been completed.
This is caused by the fact that a stream's chunk id is initialized
to 0 and updated by the RELAYD_ROTATE_STREAM command to the
id of the chunk that is currently being rotated.
The 'stream->current_chunk_id.value < chunk_id' check performed
by the RELAYD_ROTATE_PENDING will cause rotations to never
complete for streams that are created between the launch of a
rotation and the check for its completion.
For example, when the relayd is checking whether the rotation id
'3' is completed, it may see streams with the default value of
their chunk id set to '0' and determine that a rotation is still
pending.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 10 May 2018 19:00:34 +0000 (15:00 -0400)]
Pass the consumerd stream's trace archive id to the relayd
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 9 May 2018 01:41:08 +0000 (21:41 -0400)]
Fix: propagate archive id to the consumer daemon on stream creation
This is the first of a series of fixes addressing a number of problems
with the way session rotation completions handled.
Those issues can result in:
- A stop never completing,
- A rotation never completing,
- A rotation being marked as completed while the consumerd/relayd
are still writing to the completed chunk's trace archive,
resulting in a temporarily corrupted trace.
This first commit performs a relatively simple modification
to ensure that the session's current archive id is propagated to the
consumer daemon.
Detailed description of the problems
---
At the core of the problem is the fact that in per-pid buffering, we
are not guaranteed that the sessiond will be able to see an
application's channel(s) if it was torn down before (or even during)
the rotation.
When an application is torn down, it is removed from the ust_app_ht.
That doesn't mean its buffers were received by the relayd or even
consumed by the consumerd. The session daemon issues a "flush channel"
command, but there is no guarantee/synchronization to ensure the
buffers have been consumed.
The current design assumes that the sessiond knows all the channels to
rotate and that we can monitor those channels for the completion of
a rotation. Given that an application can disappear or appear while
we iterate on the ust_app_ht, this assumption does not hold. We also
don't want to prevent/delay applications from registering or exiting
just because a rotation is ongoing.
* Problem 1 *
A rename can happen before the relay has received all data for a given
chunk, leading to the data pending issue explained previously.
Rename should be performed as the last action after the rotation
has been completed since data can still be in-flight,
causing the creation of indexes upon its arrival on the relayd's end.
See: https://github.com/lttng/lttng-tools/blob/
cea6c68/src/bin/lttng-sessiond/rotation-thread.c#L392
Currently, the rotation thread waits for all channels (known to the
sessiond at the start of the rotation) to have reached their rotation
point. More specifically, the consumer will write to the
channel_rotation pipe everytime a channel's subbuffers have been read
up to the point of the rotation position. This does not guarantee that
the data has been commited to disk on the relay's end.
At that point, the command to rename the destination folder is sent to
the relayd and the sessiond checks for the pending rotation
periodically (every 200ms) if the output was to a relayd.
That check is assumed not to be needed when tracing locally since
reaching the rotation point implies the contents being written to
disk.
This scheme is not safe. If the sessiond sees no channel to iterate
on, it will issue the rename command immediately. If an application's
buffers were being flushed by the consumerd, the relayd will receive
the data, attempt to create index files, and fail since the folder has
been moved.
From an architectural standpoint, the rename command also leaves the
'path' of streams that were unknown to the sessiond pointing to a path
that does not exist anymore.
* Problem 2 *
In per-pid tracing mode, an application can appear after the rotation
was initiated and cause the rotate pending check to never complete.
A RELAYD_ROTATE_PENDING command is applied to a unique session id and
a chunk id.
When handling a RELAYD_ROTATE_PENDING commands, the relayd will perform
the following check:
- Iterate on every stream known at that point:
- Check if the stream is rotating (stream->rotate_at_seq_num != -1ULL)
- If the stream is not rotating, "stream->chunk_id < chunk_id" is checked.
- If true, the rotation is considered incomplete.
See: https://github.com/lttng/lttng-tools/blob/
cea6c68/src/bin/lttng-relayd/main.c#L2850
Given that streams, at their creation, are initialized with their
current "chunk_id" set to 0, the rotation will never be considered
complete if a stream is created between a ROTATE_STREAM and
ROTATE_PENDING command.
This can happen whenever an application is registered during a rotation.
* Problem 3 *
Since the sessiond can't accurately monitor the channels that have to
be rotated, the "rotation completed" notification (and state, if
queried with the lttng_rotation_handle_get_state() interface) is not
reliable.
A client could see that the rotation is marked as completed and
attempt to read a trace archive that has not been completely written.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 4 Jun 2018 21:28:56 +0000 (17:28 -0400)]
Typo in ust consumer log message (channek -> channel)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Thu, 10 May 2018 15:02:25 +0000 (11:02 -0400)]
Use dynamic payload for the add stream realyd command
Move away from static constant defined char array.
Keep backward compatibility.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.046418 seconds and 5 git commands to generate.