David Goulet [Thu, 30 Sep 2010 18:52:55 +0000 (20:52 +0200)]
Fix missing data pointer
This applies to tracepoint using a marker (trace_mark_tp)
At commit 9dec086e052cf7f583a3afaa3aab48a6de8d38ac,
the tracepoint_probe_register/unregister_noupdate function has been
changed with the addition of a void data pointer. In set_marker(),
the call to that function was not updated with this new parameter.
The effect was that on a second register_trace with an already
registered probe, the data ptr was corrupted with false data and
thus the probe checking failed to validate duplicates. So, the same
data was reproduced for a single trace call. Same behavior for
unregistering the marker, it was not found.
NOTE : For now, this pointer is NULL because we don't have at this
point tracing session.
Signed-off-by: David Goulet <david.goulet@polymtl.ca> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
David Goulet [Tue, 28 Sep 2010 13:05:49 +0000 (15:05 +0200)]
New naming convention for internal macros
This is the first patch introducing the new naming convention
for the UST tracer. To prevent namespace pollution, _ust_ prefix
is added to internal macros which are visible in the global header.
For this patch, only the container_of macro is renamed and the
redundant definition in kcompat/simple.h is removed.
Signed-off-by: David Goulet <david.goulet@polymtl.ca> Acked-by: Nils Carlson <nils.carlson@ericsson.com>
Nils Carlson [Mon, 27 Sep 2010 08:54:48 +0000 (10:54 +0200)]
Re-write ustcomm parts of UST v2
Changes since v1:
Updated after comments from David Goulet and resulting insights.
* Add a continue after a failed accept
* Fix some malloc issues
* Fix some coding style in the patch
* make del_named_sock free the memory, even if all else fails.
Notice: valgrind test-case currently broken. Needs an exception.
Description:
This is a very big patch, and so it requires a bit of explaining.
This patch is a step on the way of accomplishing serveral goals I have in this
area:
1. Use enums for commands and eliminate text-based commands. This does not mean
that we will stop processing strings for trace/channel and marker names;
just that the long series of if statements with token and string matching
will be replaced with a switch statement. To this end I have created a
ustcomm_header struct that contains the length of the data-field and some
other fields. This allows us to first receive the header, allocate memory
for the data and then receive the data; eliminating all scanning of messages.
2. Reduce the complexity of the implementation. To put it simply, I don't like
callbacks. They reduce transparency and make it difficult to follow the
flow of the code; so I have eliminated multipoll replacing it with a normal
epoll. I have also replaced almost all the different server, connection and
source structs with one, called ustcomm_sock.
3. Make ustd scale better. Currently ustd scales terribly. We allocate one
thread per-cpu per-channel per-process, five applications each with three
channels on a four cpu machine leads to 5*3*4=60 threads. Part of the reason
for this multitude of threads was that we used a ustcomm_request call
(consisting of a send and a receive) to wait for a subbuffer to be written.
The sequence for a subbuffer to be written was as follows:
Ustd calls send with a 'get_subbuffer' command, and then recv in one of
the threads and hangs on the recv on the socket.
Upon filling the subbuffer the traced app writes '1' to a pipe.
The ust_thread inside the app which was listening to the other end of the
pipe wakes up when the '1' is written. The callback from multipoll calls
a send which sends a reply to the ustd thread over the socket.
The ustd thread wakes up and reads the message, continuing along in its
execution.
I replace this with a bit of a different mechanism, which should allow us
to eventually reduce the number of threads to one per cpu:
Ustd requests a buffer_fd which causes the ustd_thread inside the app
to send the file-descriptor for the read en of the pipe to ustd.
The ustd thread now does a read on the pipe, halting its execution until
the app fills the subbuffer and writes '1' to the pipe, waking up the ustd
thread.
Ustd now makes the 'get_subbuffer' call which the ust_thread inside the
app responds to with information about the subbuffer. Writes it and then
goes back to the read call, hanging on the pipe.
So we are still stuck on the multitude of threads, but we are in much better
position to move forward. Replacing the read with an epoll statement and then
pointing the epoll event data at the buffer struct containing the current
buffer to whitch the pipe belongs should be relatively easy. We can then
instead of spawning a new thread for each buffer just allocate the
buffer_info struct and assign it to one of the per-cpu threads in ustd to
poll on.
4. Replace poll with epoll which scales better, especially for
events << (nr of fds). This is complete.
5. Allow UST to handle arbitrarily long unix socket names. This is done by
carefull allocation of the socketaddr_un struct with a dynamic length.
Truncating is ugly and dangerous.
There is a lot of work still left to be done. This is only the first of a
number of patches that I expect in this area. If someone feels like tackling
ustd head on to reduce the number of threads that would be great.
I have kept Pierre-Marc's form of error handling for the I/O wrapping functions
because I want to propagate return codes up to the apps that are using them
so they can close file-descriptors and free associated resources. If somebody
knows of a better approach please make yourself heard.
Signed-off-by: Nils Carlson <nils.carlson@ericsson.com> Acked-by: David Goulet <david.goulet@polymtl.ca>
Nils Carlson [Fri, 10 Sep 2010 08:49:49 +0000 (10:49 +0200)]
Add functions and command line for listing trace_events v3
Changes from version 2: Fix a comment.
Changes from version 1: Fix silly things per Davids comments,
realise that we are looping over pids and therefore need to set
all pointers to NULL and all counters to zero each time.
David Goulet [Thu, 9 Sep 2010 16:48:16 +0000 (18:48 +0200)]
Set the exit status of ustctl main function v3
Each possible command checks the return value and, on error,
print on stderr and set the retval. This makes ustctl return
an EXIT_FAILURE on any command that fails.
Signed-off-by: David Goulet <david.goulet@polymtl.ca> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Nils Carlson [Tue, 31 Aug 2010 13:45:08 +0000 (15:45 +0200)]
Update test-case for tracepoints and add a new test-case
Update the test-case for probes to handle a new data pointer
in the probe function. Also add a new test-case that stress-tests
probe registration and unregistration.
Nils Carlson [Tue, 31 Aug 2010 13:10:59 +0000 (15:10 +0200)]
Add a data pointer to all tracepoint probe callbacks
RCU now dereferences an array of probe structs containing data pointers and
function pointers, and passes the data pointer as the first argument to the
probe.
Due to this change void prototypes are no longer allowed, which has incurred
changes to libust-initializer.c .
This patch also fixes a problem where non-existent tracepoints are present
in the __tracepoints section and with a name pointer pointing at NULL.
Alexis Hallé [Wed, 4 Aug 2010 15:18:16 +0000 (11:18 -0400)]
remove dependency on ustcomm.h where possible
ustcomm structures are replaced with pointers so the compiler doesn't
have to know the contents of the structures. This is done so ustcmd.h
and libustd.h can be installed on a system without needing to install
ustcomm.h.
This makes libustd a library containing the core functionality of
the daemon, and ustd a simple client application using this library,
interacting with it via a set of callbacks supplied to it.
David Goulet [Thu, 24 Jun 2010 16:32:29 +0000 (12:32 -0400)]
Fix directory creation mode. Unless umask is set to 0 the default umask of the system, commonly 022, will be used and thus it becomes impossible to get the 777 mode.
David Goulet [Wed, 23 Jun 2010 21:17:39 +0000 (17:17 -0400)]
UST marker.h
Modification nécessaire pour faire des custom probes avec trace_mark_tp.
Sous la recommandation de Michel et Mathieu, il était mieux d'utiliser
cela pour les tests de profilage que des trace_mark ou des tracepoints.
Ceci étant dit, les résultats avec un test de profilage que j'ai monté,
contenant 3 tracepoints, le average perevent était de ~65ns.
Maintenant, résultats préliminaires avec les custom probes sur le même
test suite que les trace_mark et tracepoints :
Average time per event : 0.0000000159 (sec), 0.00002
(msec), 0.01587 (usec), 15.86718 (nsec)
Best time [RUN 5] : 0.0000000154 (sec), 0.00002
(msec), 0.01536 (usec), 15.35519 (nsec)
Worst time [RUN 6] : 0.0000000166 (sec), 0.00002
(msec), 0.01659 (usec), 16.59236 (nsec)
Standard Deviation : 0.0000000004 (sec), 0.00000
(msec), 0.00038 (usec), 0.38116 (nsec)
Quand même! ;)
Bref, je continue mais si tu veux commenter ou proposer des tests, fait
moi signe.
A plus
David
From e1fc903e0cedfc21895b2ad952bb6127d0b3b853 Mon Sep 17 00:00:00 2001
From: David Goulet <david.goulet@polymtl.ca>
Date: Wed, 23 Jun 2010 17:04:45 -0400
Subject: [PATCH] Fixed __trace_mark_tp_counter with the usage of
DEFINE_MARKER_TP macro. Down to 5 arguments instead of 7
and added registers struct missing. Now, custom probes
can be used within UST with trace_mark_tp function
Alexis Hallé [Fri, 28 May 2010 17:10:37 +0000 (13:10 -0400)]
add environment variables to set subbuffer options
UST_SUBBUF_SIZE and UST_SUBBUF_NUM control respectively the size and
number of subbuffers. Options -S and -N in the usttrace script also
control these parameters.
Not doing this can result in a situation where all the other application
threads have a signal blocked, and the listener thread, not having it blocked,
lets the signal handler execute. Therefore, in order to be as transparent as
possible to the application, we have to block signals.