Disable this test before the release, as we are working on a solution
that involves redesign of the way libust is controlled (synchronization
with a lttng-tools session daemon). We don't want to flood testers with
known issues.
liburcu symbols have changed (_bp suffix added for the -bp flavor used
by UST), and we now depend on urcu 0.5.5 for struct rcu_head definition.
Therefore, check for synchronize_rcu_bp and call_rcu_bp.
Remove most installed headers, which should be internal. The header
kcompat (kernel-style compatibility header) only makes sense within the
UST package: this should never be exported, nor be included into
instrumented applications.
Move the type-serializer header back into libust/. It is so internal it
does not even belong to include/ust/.
Standardize all the installed headers on non-kcompat style: use uint64_t
instead of u64 for types, open-code likely/unlikely.
The current interface we publish is ust_marker(), tracepoint() and
TRACEPOINT_EVENT() (and associated _NOARGS, CLASS, INSTANCE and
TRACEPOINT_CREATE_PROBES). Besides that, consider any lower-level API
showing the UST internals as, well, internal.
We want to move towards a TRACEPOINT_EVENT-based API only, so start
cleaning up right now.
Prefix with _ or __ all members that are internal to UST. Move all the
non-exported API members (that don't need to be around in program
inclusion) to tracepoint-internal.h (which is not meant to be installed
on the system).
Unit tests can still use the internal API members for now, but should
gradually move to use TRACEPOINT_EVENT as we start implementing the
FIELDS() declaration.
TRACEPOINT_EVENT is changed from the kernel incarnation (TRACE_EVENT):
we take only 3 arguments: proto, args and fields. The "fields" describe
the event layout _and_ targets the data source.
Nils Carlson [Tue, 17 May 2011 13:16:47 +0000 (15:16 +0200)]
New fast-exit test-case
A fast-exit test-case that just writes one marker and exits,
tests that the consumer daemon maps the buffers before the
program exits. Exiting is tested both by normal return
and by commiting suicide (SIGKILL to self).
Signed-off-by: Nils Carlson <nils.carlson@ericsson.com> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Nils Carlson [Mon, 16 May 2011 13:57:15 +0000 (15:57 +0200)]
Make libustctl list only online pids v3
Changes since v2:
Botox.
Changes since v1:
Cosmetic surgery at a european cost
Previously libustctl would list all pids. This patch changes this
so only online pids are listed. This is done by appending on each
socket name the mtime from the proc/<pid> directory. This way a
socket can be checked to see if the appended mtime matches the
mtime of the proc dir for the current pid, thus allowing us to
distinguish between old and new socket files.
Signed-off-by: Nils Carlson <nils.carlson@ericsson.com> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Jason Wessel [Wed, 4 May 2011 19:35:20 +0000 (15:35 -0400)]
armv5 archs require write alignment
Reads and writes to unsigned int 32 bit numbers must be address
aligned or the l2 cache can return junk in the high order 16 bits on
reads.
This patch activates the original work done for alignment in ltt for
the UST code. The config.ac changes will isolate the use of alignment
to the known arch type with the problem.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Jason Wessel [Tue, 26 Apr 2011 21:55:55 +0000 (23:55 +0200)]
add mips support
The recent changes to UST make it trivial to add MIPS support.
The trick for MIPS is that there are many different library formats
and the gcc 4.x compiler will correctly choose the default one so long
as the libust.ldscript.in does not not make a reference to the library
format.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
Jason Wessel [Wed, 27 Apr 2011 20:22:16 +0000 (22:22 +0200)]
support busybox for manual trace tests
The busybox version of find does not support using -L, and it does not
appear to be needed in order to pass the test. In the interest of
being able to run internal UST tests on a busybox based rootfs,
appropriately detect if -L is available as an argument to find and use
it when it is available.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
Jason Wessel [Wed, 27 Apr 2011 20:22:15 +0000 (22:22 +0200)]
ust-consumerd: fix exit race log corruption
In the following scenario on an SMP system the ust-consumerd can end
up not properly closing out file handles which leads to log
corruption:
* usttrace -m -l small_quick_app_lots_of_malloc_and_free
* The app completes and usttrace sees and sends the SIGTERM to ust-consumerd
* The ust-consumerd main thread will exit and the _exit() handlers
kills off the remaining pthreads without everything getting closed out
The solution to the problem is to introduce an active_thread count for
the private ustconsumer_instance. This counter will be zeroed out
when it is safe to completely shutdown the main thread, which will
subsequently run the _exit() handlers.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
Jason Wessel [Wed, 27 Apr 2011 20:22:14 +0000 (22:22 +0200)]
ust-consumerd: fix exit race crashes
The ust-consumerd gets shutdown by the SIGTERM signal and a number of
places in the ust-consumerd did not properly deal with the case where
a system call returns EINTR in errno as a result of a signal to the
process. The failure to handle EINTR properly was leading to some
data corruption in the buffer code and causing some random "victim"
crashes in lowlevel.c
The way all the offending functions were tracked down was to
temporarily add an abort() in the SIGTERM signal handler. Then it was
a matter of looking at what threads were blocked on system calls at
the time outside of the thread that received the signal.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
Remove GDB support temporarily, awaiting a better implementation that
does not require so much asm trickery. Imported the kernel LTTng code
back into UST to use C declarations for the marker structures.
The plan is to move to a SDT-based implementation (using variable
number of arguments).
This patch is required to make the MIPS port work. Tested by Jason
Wessel.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Tested-by: Jason Wessel <jason.wessel@windriver.com>
The pointer section needs to be rw so that the linker can update the
pointers at link-time, thus allowing the code to be compiled with -fPIC.
The previous behavior would cause section flag mismatch, because
TRACEPOINT_LIB declared the ptr with "= NULL", which is not a void *
const, but rather a void *, which forces the element it is assigned to
to become non-const.
> As I prepared the 0.12 release for Debian, I noticed that libust.so was
> not PIC:
>
> $ readelf -d libust/.libs/libust.so.0.0.0 | grep TEXTREL
> 0x0000000000000016 (TEXTREL) 0x0
>
> Since all of the objects in libust are built with -fPIC, I thought
> perhaps there was some assembly added between 0.11 and 0.12 that
> contained text relocations. I bisected the two tags down to the
> offending commit:
>
> eb5d20c68aaf73661ffc02ba8fea3683c0358702
>
> Within that commit, it seems to be a problem in include/ust/marker.h
> with these lines:
>
> @@ -129,7 +124,12 @@ struct marker {
> [...]
> + /*".section __markers_ptrs\n\t"*/ \
> + ".section __markers_ptrs,\"a\",@progbits\n\t" \
>
> If I make the __markers_ptrs section writable, with:
>
> ".section __markers_ptrs,\"aw\"\n\t
>
> TEXTREL goes away and everything seems okay, tests pass. Is this
> a correct solution? I don't understand why the section must be writable
> to avoid relocations, can anyone explain?
Oh.. I think I see. __markers_ptrs contains pointers to another section
that must be populated by the dynamic linker (thus at runtime). If the
section is read-only, the linker cannot update them at load time, so a
relocation table is probably needed.
Reported-by: Jon Bernard <jbernard@debian.org> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Steven just stated clearly that he only accepts relicencing to
LGPLv2.1 (not later). So I think we might have been interpreting his
previous acceptance a little too broadly when specifying "LGPLV2.1+".
Change the licensing text to reflect this.
If some of the contributors specifically said they were OK with "or
later", we could add this back upon rechecking their original acceptance
email. The pointers to the original public emails should have been
present in the relicensing file to make our current job easier, but this
is unfortunately not the case.
Also updated the stringify.h, tracepoint.c, marker.c and trace_event.c
files.
All internal symbols, no API change. Enforce "tracepoint_" or "tp_"
prefixes to local symbols, as well as rename struct probes to struct
tracepoint_probes.
This will allow doing macro tricks at the "tracepoint()" macro expansion
site. This will be useful for integration with SystemTAP probes, which
needs to expand an inline assembly with constraints on the arguments.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> CC: Nils Carlson <nils.carlson@ericsson.com> CC: Steven Rostedt <srostedt@redhat.com> CC: Josh Stone <jistone@redhat.com>
Markers: API change: rename trace_mark() to ust_marker()
Given that the markers will stay as debug-only "quick and dirty"
tracing interface, make them UST-specific. Make it clear by turning the
API to ust_marker().
Jason Wessel [Tue, 12 Apr 2011 19:11:36 +0000 (21:11 +0200)]
Fix up all use of /dev/stderr for portability to busybox /bin/sh
The typical shell on a small embedded target using busybox does
not have support for /dev/stderr. A more portable way to send
output to stderr with echo is to redirect stdout to stderr with
1>&2.
In the usttrace script it did something that was effectively
a NOP. The result of echo "" 2>/dev/stderr is not actually
going to send anything to stderr because the echo is going
to write to stdout. This case was also fixed.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
Given that UST will gradually move to a scheme where channels are
dynamically associated with markers on a per tracing session basis (and
thus associated dynamically rather than fixed statically), it does not
make sense to specify the "channel name" in addition to the marker name
in the trace_mark() arguments.
I'm introducing this API change without changing the underlying
implementation, trying to minimize the impact of API changes by doing
them sooner than later.
Nils Carlson [Mon, 4 Apr 2011 10:49:56 +0000 (12:49 +0200)]
Make only libust and libustconsumer use a signal safe usterr.h
Copy usterr.h to usterr_signal_safe.h and rewrite those parts of
usterr.h that depended on libustsnprintf. This removes the dependency
on libustsnprintf from all parts of ust except libust.
Signed-off-by: Nils Carlson <nils.carlson@ericsson.com> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Nils Carlson [Wed, 30 Mar 2011 14:55:38 +0000 (16:55 +0200)]
Make root see all available pids v2
Changes since v1:
* Fix a whitespace
* Make functions that should be static static
Allow root (geteuid() == 0) to see all pids. This way the super-user
can connect to any program. A step on the way of carefully outlining
what UST does and doesn't.
Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
Rename local variables "m" and "regs" to less conflicting names
Rename "m" local macro variable to "__marker_counter_ptr".
Rename "regs" local macro variable to "__marker_regs".
Initial report:
The following trivial piece of code will result in corrupt events:
void dump_ackerman_current( int m, int n )
{
trace_mark( ackerman, current, "m %d n %d", m, n );
}
This is because in ust/marker.h line 173 the definition of the
__trace_mark_counter macro uses a temporary named m (which shadows the
original m). It might be a good idea to use underscore variable names
inside these macros to make naming conflicts less likely.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reported-by: Paul Wögerer <paul_woegerer@mentor.com>
Nils Carlson [Thu, 10 Mar 2011 09:58:44 +0000 (10:58 +0100)]
Change force_subbuffer switch to be per trace
Change force_subbuffer switch to act on a per trace basis becuase this
is what we want almost all the time. This will simplify periodic flushing
of some traces and other features we might want in the future.
Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
Marker ID is already dumped at:
- trace start (with marker dump)
- when a marker is enabled (probe callback associated with marker).
So this should cover all cases:
- either we have a marker in a lib/program that is already enabled, and start
tracing after a library is loaded, for which the marker dump will catch the
marker id.
- or we have a marker in a lib/program that is not enabled, and start tracing
after a library is loaded. If after that we enable the marker, an event
describing the marker ID will be generated.
- or if have tracing running, and then we enable a marker (connect probe to
marker) for a marker located in a yet-unloaded library. In this case, the
marker ID event is generated when we connect the probe to the marker, even if
the library is not yet loaded.
The cases are similar for the marker format, except that it is valid to have an
unknown marker format when we connect a marker probe. In that case, the format
will be written into the trace by marker_set_format, called upon library load.
finish_consuming_dead_subbuffer: fix data_size read race, reread new consumed count
Make sure finish_consuming_dead_subbuffer always see a data_size that is non
0xffffffff only when the buffer data is entirely readable, else the code rely on
the commit_seq counter which is the proper solution.
The consumed count should be re-read in each test within the loop, otherwise the
mathematic formula to get the amount of data to read does not work wrt
buffer-size wrap-around.
fork: child should issue synchronize_rcu() for urcu-bp garbage collection
After a fork(), the child process should execute synchronize_rcu() before any
new thread can be created. Failure to do so could lead to a deadlock in the
unlikely scenario where a thread ID appearing in the parent is reused in the
child before GC is performed.
Add missing listener threads data vs fork() protection
The following races are problematic:
- fork() occurs concurrently with listener thread receiving commands.
- Mutexes and data structures can be left in incoherent state.
- fork() occurs concurrently with ust library destructor.
- listen_sock can be left in incoherent state in the child.
Protect these resources with their own specific mutex.
listener_thread_data_mutex protects all data/mutexes touched by the listener
thread. It is also held across fork to make sure the child see a coherent
version of these structures.
listen_sock_mutex protects the listen_sock teardown (pthread cancel done at
libust destructor). Is is also held across fork() to protect from concurrent
teardown of listen_sock. We add a check around listen_sock teardown to see if it
has already been deleted (which could happen if the destructor runs concurrently
with fork().
David Goulet [Thu, 3 Mar 2011 15:48:11 +0000 (10:48 -0500)]
Code base to fix the print errors in UST (v4)
Update:
v2: Use commit_seq instead of commit_count to fix a consumerd segfault when
accessing commit_count, since it is not mapped.
v3: Remove commented out code
v4: Remove unused variable
Jason Wessel [Thu, 3 Mar 2011 02:21:07 +0000 (21:21 -0500)]
ustctl: Fix memory allocation problem with compatibility args
The parenthesis were missing to make the malloc math have the correct
precedence. The addition needs to occur before the multiplication.
The result is the same but for clarity also change change char ** to
char * because we are allocating an array of char pointers.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>