> 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>
Jason Wessel [Thu, 24 Feb 2011 20:40:12 +0000 (21:40 +0100)]
Allow backward compatibility to ustctl <= 0.11 for some commands
The rewrite of the ustctl broke all the existing scripts
that make use of ustctl. This allows the original commands,
examples, and external scripts to continue working properly.
Nils Carlson [Fri, 4 Feb 2011 07:24:51 +0000 (08:24 +0100)]
libustctl: use direct socket communication
This patch changes libustctl to be socket instead of pid oriented.
The user is expected to connect to a pid using
ustctl_connect_pid(pid_t) which returns a socket file-descriptor and
then use the socket for the rest of the api. This reduces the amount
of open and closing systemcalls and also makes it possible for a
session daemon to detect process shutdown by the socket closing.
David, this ones for you. :-)
Signed-off-by: Nils Carlson <nils.carlson@ericsson.com> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Yannick Brosseau [Wed, 23 Feb 2011 17:46:22 +0000 (18:46 +0100)]
Fix libustctl_function_tests
After discussions, we concluded that the enable a non existing marker is a valid case, so we
move it to the working case section.
While being there, check that the re-enable a marker set the right errno
Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com> Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
Yannick Brosseau [Mon, 21 Feb 2011 19:36:09 +0000 (20:36 +0100)]
TESTS: Add a delay at the start of the fork test for a more uniform testing.
Add a sleep to leave time for the ustconsumer thread to initialize correctly
before the fork.
Most of the time the consumer was not yet started at the time of the fork so
a bunch of initializations were not done and the fork code path was not
tested properly.
Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com> Acked-by: Nils Carlson <nils.carlson@ericsson.com>
Jason Wessel [Tue, 22 Feb 2011 22:37:25 +0000 (17:37 -0500)]
usttrace: use short signal names for busybox compatibility
The kill command in coreutils will accept the short signal name, but
various versions of busybox will not accept the long signal name. For
compatibility with busybox use the short signal name.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Jason Wessel [Tue, 22 Feb 2011 22:36:03 +0000 (17:36 -0500)]
usttrace: Use /bin/sh instead of /bin/bash for busybox compatibility
The busybox posix like shell does not understand the "function"
directive nor does it understand the syntax for redirecting a file via
a shell expanded variable with $(<$pidfilepath). Busybox also does
not typically provide a link to /bin/bash since busybox does not
provide bash.
It is possible to work around all these limitations in order to allow
user space tracing to work properly in a busybox based environment
with several syntax changes to the usttrace script.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix marker/tracepoint/trace_event lib list: expected to be sorted
Sort library lists.
List operations expect the library lists to be sorted by pointer addresses (this
was needed for iteration on kernel modules without having to hold the mutex
across read system calls). It's usefulness in userspace is debatable, but there
is clearly a bug here, since the code that iterates on the lists still expects
them to be sorted.
Yannick Brosseau [Sun, 20 Feb 2011 15:19:36 +0000 (10:19 -0500)]
tests: fix tap.c use of uninitialized pipe_r_file
[ Edit: updated patch header ]
The _tap_comment_stdout thread can start using pipe_r_file when it
is still uninitialized. Fix it by moving the initialization before the pthread
creation.
Yannick Brosseau [Fri, 18 Feb 2011 21:55:25 +0000 (16:55 -0500)]
Try harder to find a usable lttv in the tests scripts v2
Add many more attempts to auto-detect the path to the lttv executable or
the runlttv script in trace comparison tests.
Also support setting the LTTV env variable to directly set a path the
the lttv executable in addition to the RUNLTTV variable
Fixes odd alignment issues between linker and compiler, caused by compiler
using larger alignment values than expected for structures -- and the linker
adding unexpected padding within the sections. Use the same technique recently
introduced for Linux kernel tracepoints.
UST markers: fix structure alignment for recent gcc
GCC 4.5 (and possibly some late 4.4) choose to align structures on large
multiples, which breaks the __marker section (adding extra padding between
object sections). Increase the structure alignment to fix this issue.
Note that kernel tracepoints have recently been changed to use an array of
pointers (which are pointing to the actual tracepoint structures), thus removing
the requirement for these odd structure alignments.
But given that markers are in "maintainance mode", let's do the quick fix and
just increase the minimum alignment size.
Yannick Brosseau [Thu, 10 Feb 2011 15:51:41 +0000 (10:51 -0500)]
Remove PowerPC specific time reading function
The PPC version of the trace_clock_read64 was using the TB register
which is not constant accross implementations. The currently
measured time base on PPC was not accurate.
So, for now, we rely on the CLOCK_MONOTONIC.
This patch remove a bunch of #ifdef for x86 and PPC, since we now rely on
the same base clock. It also fix the build on PPC that was currently broken