David Goulet [Wed, 2 Nov 2011 19:44:27 +0000 (15:44 -0400)]
Preliminary work for full UST support
Add hashtable support for all UST data structure. At this point, enable
channel and event works with the global UST domain. The interaction with
the ust consumer has problems for now thus not working at this stage.
NOTICE: This commit does NOT work with the user space tracer yet. Please
refer to next commit for working version.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Tue, 4 Oct 2011 21:15:32 +0000 (17:15 -0400)]
Add sem_wait timeout on the kconsumerd thread
It's unlikely to happen but is the kconsumerd was not able to send us
the sock ready command, at least the session daemon will not stall
forever. A 30 seconds timeout is added and error is handle after that.
Also adds the handling of the sem_init ret value and adds mutex lock
around the kconsumerd pid in the same function.
There was also a problem on error code handling where LTTCOMM error was
returned by spawn kconsumerd function but handled as if it might be
negative at the end of the call chain. This was preventing to return the
right error code to the client when the kconsumerd failed.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Tue, 4 Oct 2011 20:24:10 +0000 (16:24 -0400)]
Remove session list lock acquisition of the search
The lock/unlock of the session list in the find session by name function
is removed thus the caller must held the lock before calling that search
function.
Also, the path and name are now static size on the stack and not
allocated strings at session creation.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Mon, 3 Oct 2011 19:23:16 +0000 (15:23 -0400)]
Fix session list deadlock
On session destroy, the session list lock is acquired but this call
could be made inside a section where this lock is already acquired. The
call has been changed to using the session pointer and not the name thus
removing a useless list walk.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Mon, 3 Oct 2011 18:46:40 +0000 (14:46 -0400)]
Fix enable syscall and bad value of poll set size
First, when enabling syscall tracing, on success 0 is return so we don't
add this value to the event list or else we were polling on fd 0 which
is not a valid event fd. A normal kernel create event, the fd of that
event is returned from the ioctl which is not the case for syscalls.
Second, the poll size was not reset when updating the kernel poll set so
at each kernel poll update, the value was not coherent with the real
poll size and thus creating unstable behavior (unknown).
This commit MIGHT fix a blocking problem happening when using a custom
channel and enabling syscall on it. This issue was reported by Julien
Desfossez <julien.desfossez@polymtl.ca>.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
ltt-kconsumerd.c: In function ‘on_recv_fd’:
ltt-kconsumerd.c:298: warning: passing argument 2 of
‘kernctl_get_mmap_len’ from incompatible pointer type
../include/lttng-kernel-ctl.h:47: note: expected ‘long unsigned int *’
but argument is of type ‘size_t *’
David Goulet [Thu, 15 Sep 2011 23:24:23 +0000 (19:24 -0400)]
Major code cleanup
Cleanup main.c of the session daemon. The main switch case to handle
client command is made more modular and clearer. Each command has a
function associated with it beginning by 'cmd_*'. Also adds channel.c/.h
and event.c/.h containing helper function to execute client commands.
The reste of the modified code is simple cleanup.
Some minor bugs were fixed also by this cleanup. All and for all, this
makes easier to maintain the session daeamon code base.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Fri, 9 Sep 2011 18:43:13 +0000 (14:43 -0400)]
Add poll/epoll compat layer for session daemon
This is a big modification of the session daemon code base. Every thread
is monitoring file descriptors using a poll set. This commit adds a
compat wrapper for the use of poll(2) or epoll(7) determined at compile
time on if the epoll API is available. Since epoll(7) is Linux specific,
the poll(2) fallback is necessary for portability.
By default, epoll(7) will be used having the --enable-epoll default to yes.
To use the poll(2) API, simply run with --disable-epoll when running
configure.
With this implementation, some fixes are also introduced.
* Two missing notification to the consumer when the default channel is
created.
* Memory and socket file descriptor leak when connect()/close() is
done by the daemon alive check of the lttngctl API.
* Root check (UID=0) on cleanup() before removing LTTNG_RUNDIR.
* Comments here and there.
At this commit, tests were made on the CPU hot plug feature, multiple
UST registration at the same time and git tree tests. All passed for
poll(2) and epoll(7) implementation.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Thu, 8 Sep 2011 14:35:11 +0000 (10:35 -0400)]
Fix missing events for all threads pollfd struct
The thread_quit_pipe event field of the pollfd was not set nor zeroed.
At high rate UST registration and modifying the pollfd set frequently,
the session daemon hang on the poll() call even if the thread_quit_pipe
was closed and explain by poll() "undefined behavior".
Also add a MSG() and ERR() statement after some errors.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Tue, 6 Sep 2011 21:10:42 +0000 (17:10 -0400)]
Fix pollfd update bug in thread_manage apps
When updating the pollfd array, the wrong pollfd size was used so at
multiple UST registration at the same time the socket was not added to
the poll list.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Thu, 1 Sep 2011 17:58:40 +0000 (13:58 -0400)]
Add the notify UST application scheme
This commit introduce the use of a wait shm futex that is used to notify
applications that the session daemon is running and ready to accept
registrations. See shm.c/.h for those calls and the new
futex_wait_update() in futex.c. This scheme is also found in lttng-ust
2.0 and mainly taken from there.
Also, enable-channel of the lttng client was modified to accept UST PID
domain. It's the first phase for testing UST features of the
liblttngctl.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
David Goulet [Sun, 28 Aug 2011 21:29:40 +0000 (17:29 -0400)]
Update and fix UST register and session creation
The handling of the apps command pollfd, in the registration thread and
the update function, was incorrect. The update process, when
unregistring, was overwritting connected socket thus not being able to
monitor them with poll().
This is the first step forward to fully support LTTng UST tracer.
Add create UST session to ustctl and the session daemon. At this
commit, this feature is not used yet.
Move the register done command to ustctl. Adds the ustcomm_send_command
which returns the reply structure from the UST application.
The ustctl and ustcomm are cleaned up.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
Julien Desfossez [Thu, 25 Aug 2011 21:51:38 +0000 (17:51 -0400)]
Init the kconsumerd error socket
The kconsumerd_error_socket must be initialised to a negative value when
we create the context, otherwise we don't know if it is defined or just
random.
David Goulet [Tue, 23 Aug 2011 17:56:15 +0000 (13:56 -0400)]
Add support for UST application registration
This is a big commit ;)
Introduce two new threads and one almost rewritten. The first thread
added is the one that manage UST registration. This thread is *very*
lightweight and, basically, receive the registration request, queue it
in a lock free queue and wake up the dispatch thread (second new thread)
using a N wakers / 1 waiters futex scheme.
This dispatch thread will then dequeue and notify the application thread
(that manages application registration and monitor UST sockets). The
notification consist of sending the dequeued node (command) to the
application thread pipe where the application thread is blocked on
poll().
For now, the registration is handle meaning that the application will
get added to the session daemon internal data structures, the daemon
will send a REGISTER_DONE command to the application and, finally, end
the communication by waiting for the UST reply of the previous command.
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: David Goulet <david.goulet@polymtl.ca>
Julien Desfossez [Tue, 16 Aug 2011 23:25:04 +0000 (19:25 -0400)]
Callbacks on receive and update FD
The user of the lib can now take control over a new FD or the update
operation of an existing FD.
Opening the output tracefile is now the responsiblity of the user
and not the library itself.
[ Edit by Mathieu Desnoyers: comment and teardown cleanups ]