Fix: consumerd: order of metadata cache vs stream lock
The locking order comment in consumer.h is incorrect. First, its
description of locking order is not in sync with the comment found in
consumer-metadata-cache.h. The comment in struct consumer_metadata_cache
only states that the metadata cache lock nests inside the consumer_data
lock, and does not mention the stream lock, which implies that the
metadata cache lock does NOT nest inside the stream lock. But let's
investigate further to confirm:
* lttng_consumer_read_subbuffer() acquires the stream lock, and then
calls lttng_ustconsumer_read_subbuffer() with stream lock held,
and then invokes commin_one_metadata_packet(), which acquires the
metadata cache lock.
* lttng_ustconsumer_sync_metadata() acquires the metadata stream lock,
and calls commit_one_metadata_packet(), which takes the metadata cache
lock.
Therefore, update the comment in consumer.h to state that the metadata
cache lock nests INSIDE the stream lock, and update
consumer_del_metadata_stream() accordingly.
This should take care of fixing the locking order reversal found by
Coverity.
CID 1368314 (#1 of 1): Thread deadlock (ORDER_REVERSAL)
CID 1368319: Program hangs (ORDER_REVERSAL)
Fixes: 5feafd4130 "Fix: protect the channel's metadata stream using the metadata cache lock" Fixes: 1ea6cc572b "Fix: lock nesting order reversed" Fixes: fb549e7ac2 "Fix: reverse channel and metadata cache lock nesting order" Reported-by: Coverity Scan Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: add missing rcu_barrier before daemon teardown
When performing the "cleanup" of sessiond, consumerd, and relayd, we
destroy data structures that may still be concurrently accessed by
call_rcu worker thread.
Ensure no more work is present in the call_rcu worker thread by issuing
a rcu_barrier barrier. Note that this expects call_rcu handlers don't
chain work to other call_rcu handlers.
Fix: support for older versions of Babeltrace in test script
A new context field was introduced in version LTTng 2.8 that is printed
by Babeltrace prior to v1.2.5. This regex thus fails to match the
output. Since the context fields are not used by the script, we create a
non-capturing group for these fields that matches on both old and new
Babeltrace.
This is causing problems on Ubuntu 14.04 Trusty when building
lttng-tools from source and using the Babeltrace package from the
official repository (v1.2.1) to run the test suite.
Also, this patch removes commented and used code in the function but
keeps the names of non-capturing groups for readability.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> CC: Philippe Proulx <pproulx@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: only lock the metadata_cache in userspace consumers
The kernel consumer, which re-uses the consumer_del_metadata_stream
function, has no metadata cache. Therefore, it can't be used to
protect the metadata stream (see 5feafd41).
However, only the userspace consumers invoke
consumer_metadata_cache_write() which the previous fix seeked to
protect against. It is therefore safe to omit this lock in the
kernel consumer case.
Fix: protect the channel's metadata stream using the metadata cache lock
The consumer_thread_data_poll and consumer_thread_metadata_poll
both access the channel's metadata stream.
During a session destruction, consumer_thread_metadata_poll will
destroy all metadata streams. However, the consumer_thread_data_poll
may still invoke a consumer_metadata_cache_write() triggered
by a "ready" subbuffer. Hence, the metadata stream must be protected
from this action by the metadata cache lock.
relay and consumerd 2.7 and 2.8 are expected to negociate compatibility
with the lowest common minor version.
If a consumer daemon 2.8 interacts with a relayd 2.7, it needs to send
the index fields for ctf index 1.0. Same if a relayd 2.8 interacts with
a consumer daemon 2.7: relayd should expect ctf index 1.0 fields, and
generate a ctf index 1.0 index file layout.
If both relayd and consumerd versions are 2.8+, then we can send the ctf
index 1.1 fields over the protocol, and store them in the index files.
Whenever the relayd live viewer server opens and reads an index file,
it needs to use the file's header to figure out the index "element"
size.
[ Should be applied to master, stable-2.9, stable-2.8. ]
Philippe Proulx [Mon, 28 Nov 2016 23:14:55 +0000 (18:14 -0500)]
Remove `metadata` command from various help resources
This command is now deprecated. Its own man page remains available
and warns the user that it's deprecated and suggests to look at
lttng-regenerate(1) instead.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Liguang Li [Mon, 28 Nov 2016 08:37:47 +0000 (16:37 +0800)]
Fix: truncate the metadata file in shm-path
In the shm-path mode, the metadata will be backuped to a metadata
file, when run the lttng command "lttng metadata regenerate" to
resample the wall time following a major NTP correction, the metadata
file will not be truncated and regenerated.
Add the function clear_metadata_file() to truncate and regenerate the
metadata file.
Signed-off-by: Liguang Li <liguang.li@windriver.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Philippe Proulx [Fri, 28 Oct 2016 22:33:19 +0000 (18:33 -0400)]
doc/man: only require asciidoc-attrs.conf when building the man pages
Situations:
* If you want to and can build the man pages:
* If it's a tarball tree:
* Make the man page destinations depend on asciidoc-attrs.conf.
Since it's a generated file, its date is greater than the
date of the prebuilt man pages, therefore the man pages are
built again, which is a good thing because they include the
default values of this build.
* If it's a Git tree:
* Always build the man pages anyway (no prebuilt man pages here).
* If you want to, but cannot build the man pages:
* If it's a tarball tree:
* Make the man page destinations NOT depend on asciidoc-attrs.conf,
because its recent date would ask said destinations to be rebuilt
and this is not possible because we don't have the tools.
However, warn the user at configure time that the prebuilt man
pages will be installed, which means that they will contain the
project's default values, not this build's default values.
* If it's a Git tree:
* Not valid: error at configure time as usual.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Introduce the perf_regression test suite that must be run manually to
check if the support for the Perf-related features are available on the
current machine. This test cannot be run automatically since there are
some platforms where it can fail (VMs, some SoCs, etc).
For now, the test only makes sure that we can trace events with perf
contexts enabled by raw ID in kernel and user-space. The test only works
if libpfm is installed on the system and fails if it is not installed.
Nathan Lynch [Tue, 1 Nov 2016 17:25:47 +0000 (11:25 -0600)]
Tests: accommodate stricter mktemp implementations in tests
Busybox's mktemp command uses mkstemp(3) which requires the last six
characters of the template to be X's. Extend the mktemp templates
used in the test scripts.
Fix: stop lttng-relayd threads on health thread error
The lttng-relayd health thread may fail to initialize for
a variety of reason (notably, a too long unix domain socket
address), which will cause it to never notify that it is
ready.
In such circumstances, the lttng-relayd command, in background or
daemonize mode, will never return as the daemon's "readyness"
will never be signaled.
lttng-ust's ust-ctl.h still refers to struct lttng_ust_calibrate
which causes gcc to emit a "‘struct lttng_ust_calibrate’ is
declared inside a parameter list" warning.
User can provide an url override that will be used during the loading of a
configuration file.
The url format is the same found at lttng-create(1).
This correspond to a --set-url operation on lttng-create.
Note: an url might be invalid for a trace configuration. The override will fail
during the session load (call to lttng_load_session) and simply cancel the
loading.
e.g Loading a live session with a file:// url override will fail.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Issuing fprintf() to stderr (thus write() to the standard error file
descriptor) within the SIGPIPE signal handler is bad: it can trigger
SIGPIPE repeatedly if the listening end has closed its end of the pipe.
Set the SIGPIPE action to SIG_IGN in relayd, sessiond, and consumerd.
This was affecting sessiond and relayd. The consumerd did not print
anything to stderr.
Fix: handle backward compatibility with lttng-modules 2.7
There is no major version bump between lttng-module 2.7 and 2.8 ABI.
Even though we do not guarantee compatibility, do a best effort to
maintain it when possible.
It appears choosing the release names provides plenty of enjoyment to
LTTng developers, thus allowing us to remove those easter eggs.
Incidentally, it will allow me to demo the LTTng project without
carrying this <yellow>Welcome back Dr Tracing!</yellow> message each
time I issue a "lttng" command.