Add a type-safe cds_list iteration adapter. Like those provided for
the lfht, this adapter provides type-safe range-for semantics for
cds_list structures.
The urcu lfht macros often make use of caa_container_of (and other equivalent
variations) which use offsetof. Unfortunately, offsetof is conditionally
supported by compilers for non-POD types.
The tree already has lttng::utils::container_of to work around this
problem. This new utils makes it possible to iterate on the
elements of an lfht that match a given key without using those macros. Those iterations are the
main reason such warnings are emitted. The interface of
lfht_filtered_iteration_adapter also allows the use of ranged-for loops.
Fix: sessiond: missing include causes multiple conflicting definitions
clang-tidy reports that
/root/lttng-tools/src/bin/lttng-sessiond/ust-ctl-internal.hpp:346:3: error: redefinition of 'LTTNG_PACKED' with a different type: 'struct lttng_ust_ctl_integer_type' vs 'struct lttng_ust_ctl_consumer_channel_attr' [clang-diagnostic-error]
346 | } LTTNG_PACKED;
Indeed, that header is missing macros.hpp causing LTTNG_PACKED
to be misinterpreted.
clang-tidy reports an infringement of
cppcoreguidelines-special-member-functions[1] for
_scoped_rcu_read_lock, iterator, session_not_found_error,
and session_not_found_error.
The copy constructor, move constructor, and assignment operators
are deleted when they are not explicitly defined.
sessiond: iterate on ust_app_ht using lfht_iteration_adapter
offsetof conditionally support for non-POD types and is used by
the cds_lfht_for_each_[...] macros. Replace them with
lfht_iteration_adapter which also provides ranged-for semantics.
sessiond: delete_ust_app_channel: iterate on lfht using lfht_iteration_adapter
offsetof conditionally support for non-POD types and is used by
the cds_lfht_for_each_[...] macros. Replace them with
lfht_iteration_adapter which also provides ranged-for semantics.
relayd: use lfht_iteration_adapter to iterate on stream indices
offsetof conditionally support for non-POD types and is used by
the cds_lfht_for_each_[...] macros. Replace them with
lfht_iteration_adapter which also provides ranged-for semantics.
The urcu lfht macros often make use of caa_container_of (and other
equivalent variations) which use offsetof. Unfortunately, offsetof is
conditionally supported by compilers for non-POD types.
The tree already has lttng::utils::container_of to work around this
problem. This new utils makes it possible to iterate on all of the
elements of an lfht without using those macros. Those iterations are the
main reason such warnings are emitted. The interface of
lfht_iteration_adapter also allows the use of ranged-for loops.
sessiond: manage syscall table allocation using std::vector
Transitioning to the use of std::vector to manage the allocation and
resizing of the syscall table allows us to do away with memset() of the
syscall structure. The memset becomes problematic when lttng_ht_node_*
becomes non-POD in a follow-up change.
cds_lfht_add_unique is misused in relay_index_add_unique. The address
of the node is used instead of the address of the key for both the
key parameter and to compute the hash of the index entry's key.
This caused problems in an upcoming change that changes the layout
of the lttng_ht node since the key is no longer the first member
of the node.
Adapt to ABI/control API updates introduced by LTTng-UST commit 24f7193c9b91 ("Introduce extension points for trace hit counters")
Note that this commit reverts back to uint32_t for channel event ids.
UST notification LTTNG_UST_CTL_NOTIFY_CMD_KEY is currently handled as
-LTTNG_UST_ERR_NOSYS (TODO).
The type of the argument to is_max_event_id() is changed to
lttng::sessiond::ust::event_id to match the newly introduced event_id
type definition. Likewise for the registry_channel _next_event_id
member.
Michael Jeanson noticed that f94318611 mistakenly introduces a new
public symbol in liblttng-ctl.so. This change was not intended and is
due to a bad backport of a fix initially developed against the master
branch.
The master branch (and upcoming version) of LTTng-tools is built with
the -fvisibility=hidden. Hence, the initial version of the fix had no
need to hide the utils_create_lock_file symbol.
Since the supported stable releases (2.12 and 2.13) are not built with
those options, that symbol has to be explicitly marked as hidden.
Reported-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I874538317617003eb1c58c2d3b7b0a2bdf905ef7
sessiond: open_packets: use user_space_consumer_channel_keys util
Replace the hand-rolled consumer channel key iteration logic of
ust_app_open_packets by an iteration on the user_space_consumer_channel_keys
returned by the ltt_session.
sessiond: clear_session: use user_space_consumer_channel_keys util
Replace the hand-rolled consumer channel key iteration logic of
ust_app_clear_session by an iteration on the user_space_consumer_channel_keys
returned by the ltt_session.
refactor: session: provide an iterator over consumer data channel keys
The code iterating over the various data channel keys of the userspace domain is
relatively complex and repeated in many places. It is refactored to provide an
iterator that can be used in those various places.
sessiond: ust_app: use RAII to manage ust_app_session locking
Like ltt_session, use the non_copyable_reference util to implement weak locked
reference helpers that are used instead of directly manipulating the
ust_app_session's pthread mutex.
hashtable: replace non-const iterator node accessors by a const version
The various lttng_ht_iter_get_node_* functions are not const-correct which makes
their use difficult in some places. This is mostly due to the fact that
cds_lfht_iter_get_node (from liburcu) is, itself, not const-correct.
These functions are replaced by a single templated function that is
const-correct by virtue of inlining the trivial iterator node accessor of
liburcu.
clang-tidy reports:
'NOLINTBEGIN' comment without a subsequent 'NOLINTEND' comment
If a specific warning is mentionned as part of the NOLINTBEGIN clause, it must
also be mentionned in the matching NOLINTEND clause. Otherwise, clang-tidy
doesn't match them.
sessiond: propagate the use of ltt_session::locked_ref
The mix of managed and unmanaged ltt_session references makes their use
potentially confusing. Move to managed locked references for most of the client
request processing paths.
Introduce ltt_session::locked_ref look-up functions and use them at the various
sites performing session look-ups by id or name.
The users of those look-up functions are refactored to make them exception-safe.
The biggest change is that process_client_msg is now exception-safe. The
functions are also moved inside of the ltt_session class as static methods. This
namespaces them implicitly.
A number of functions that expect a locked ltt_session are modified to accept an
ltt_session::locked_ref, thus enforcing the locking assumptions of the session
at compile time.
Exception: make source location print-out optional
The project-specific exceptions are changed to not include the source location
as part of the exception's message (return of what()) since it is unsuitable in
some contexts (the output of the lttng client for example).
Moreover, the exceptions are modified to provide their own message formatting
instead of relying on the user doing it at the site at which it is thrown since
that formatting is often repetitive. The sites at which the exceptions are
thrown can still augment the exceptions with more context.
The intention of our exceptions is that they still contain the requisite context
to change the print-out based on their members; that context should not be baked
into the message string at the site at which the exception is thrown.
sessiond: transition session_list synchronization from pthread to std
In order to allow the use of RAII to manage the locking in the client command
handler (process_client_msg), the session list's synchronization primitives are
changed to use those of libstd.
The locked_ref semantics garantee that an instance of an is locked and that it
exists (it can't be null). It is currently implemented with a unique_ptr, but
that will most likely change in the future to enforce the non-null requirement.
Clean-up: sessiond: client.cpp: list of inclusions
Correct some inconsistencies in the list of inclusions in client.cpp:
- include headers under common using angle-brackets
- only include the top-level lttng.h lttng-ctl header
vscode: export MI_XSD_PATH and LD_LIBRARY_PATH in gdb wrapper
vscode fails to launch a session daemon using the libtool wrapper on machines
that don't have lttng installed since the XSD can't be loaded.
Export the MI_XSD_PATH to point to the file in the source tree to allow the
daemon to launch.
Moreover, launching the session daemon fails since it can't find
liblttng-ctl.so.0. Adding the library's .libs to LD_LIBRARY_PATH works around
the issue.
Fix: consumerd: consumed size miscomputed during statistics sampling
Issue observed
==============
When specifying a size-based automatic rotation, sessions sometimes continuously
rotate after the first size-based rotation is triggered.
Steps to reproduce:
$ ./lttng create the_test
$ ./lttng enable-channel -u the_channel
$ ./lttng enable-rotation --size=32M
$ ./lttng enable-event -ua --channel the_channel
$ ./lttng start
# Produce more than 32MiB of tracing data and stop the application(s), then
# observe a rotation occuring on every expiration of the channel's monitor timer.
Cause
=====
The consumer daemon samples statistics of the various streams it monitors on
every expiration of their channel's "monitor" timer. One of the statistic it
maintains is the channel's total consumed size.
Once the stats are collected, the consumer sends a channel statistics sample
message to the session daemon. One of the fields of this message is the amount
of data that was consumed for the channel since the last statistics sample was
sent. The session daemon relies on that information to aggregate the consumed
size a session based on the consumed sizes of its various channels.
The consumer maintains a per-channel 'last_consumed_size_sample_sent' which is
used to compute the amount of data consumed since the last statistics sample was
sent to the session daemon. The computation is erroneous since the count sent to
the session daemon is 'the channel's total consumed data amount' minus 'the data
consumed since the last statistics sample'.
Solution
========
The counter maintained on a per-channel basis is now
consumed_size_as_of_last_sample_sent: the total amount of data consumed for that
channel as of the last statistics sample. On every expiration of the monitor
timer, the total amount of data consumed for the channel is determined and the
difference from that counter is sent to the sessiond daemon. The counter is then
updated with the latest computed value.
The test has been modified to loop, waiting for the post-destroy shm
count to drop back to the post-start count. In the case of a failure,
the test will hang forever but doesn't fail spuriously.
Known drawbacks
===============
None.
Change-Id: Id3c8a9f6db83fe888e79b8f06cb8308b4d90da87 Signed-off-by: Kienan Stewart <kstewart@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>