From dthibault at drdc-rddc.gc.ca Fri Mar 1 14:26:57 2013 From: dthibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Fri, 1 Mar 2013 19:26:57 +0000 Subject: [lttng-dev] babeltrace output format Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD022E1A@VAL-E-01.valcartier.drdc-rddc.gc.ca> Is anyone else bothered by the slight irregularity of babeltrace's output? Here is the same trace record printed using various babeltrace settings. In all cases I used '-f trace:hostname --no-delta', varying only the '-n' part: -n scope [11:02:08.064705355] edge-vb-u12 exit_syscall: stream.packet.context = { 0 }, stream.event.context = { 1, 943, "whoopsie", 943, 109 }, event.fields = 8 -n payload [11:02:08.064705355] edge-vb-u12 exit_syscall: { 0 }, { 1, 943, "whoopsie", 943, 109 }, { ret = 8 } -n none [11:02:08.064705355] edge-vb-u12 exit_syscall: { 0 }, { 1, 943, "whoopsie", 943, 109 }, 8 -n all timestamp = 11:02:08.064705355, trace:hostname = edge-vb-u12, name = exit_syscall, stream.packet.context = { cpu_id = 0 }, stream.event.context = { ppid = 1, tid = 943, procname = "whoopsie", pid = 943, perf_major_faults = 109 }, event.fields = { ret = 8 } Now compare just the payload part: -n scope event.fields = 8 -n payload { ret = 8 } -n none 8 -n all event.fields = { ret = 8 } It turns out the payload is bracketed by {} except when it has size zero or one and its contents are unlabelled. Indeed, with an empty payload I can get a trailing "{ }" or "" (that is to say, the record ends with a comma) depending on the labelling. However, notice that for the stream.packet.context this does not happen, maybe because the underlying structure has actually six fields instead of the lone one normally shown (you can get all six printed using --verbose): -n scope stream.packet.context = { 0 }, -n payload { 0 }, -n none { 0 }, -n all stream.packet.context = { cpu_id = 0 }, -v { timestamp_begin = 4196192044293, timestamp_end = 4196224429641, content_size = 2096768, packet_size = 2097152, events_discarded = 0, cpu_id = 0 }, This variability could make babeltrace's text output more difficult to parse than necessary, since one would have to handle the occasionally-disappearing curly brackets. Is this worth filing a bug over? Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC? G3J 1X5 CANADA Vox?: (418) 844-4000 x4245 Fax?: (418) 844-4538 NAC?: 918V QSDJ Gouvernement du Canada?/ Government of Canada From christoph at debian.org Sat Mar 2 15:07:01 2013 From: christoph at debian.org (Christoph Egger) Date: Sat, 02 Mar 2013 12:07:01 -0800 Subject: [lttng-dev] Package liburcu fix for kfreebsd-amd64 and kfreebsd-i386 In-Reply-To: <20130222134515.GA22069@Krystal> (sfid-20130222_145406_989084_516874D5) (Mathieu Desnoyers's message of "Fri, 22 Feb 2013 08:45:15 -0500") References: <20130222134515.GA22069@Krystal> Message-ID: <87bob1ftwa.fsf@mitoraj.siccegge.de> Mathieu Desnoyers writes: > I noticed failures to build for the liburcu Debian package for > kfreebsd-amd64 and kfreebsd-i386. I just pushed a commit into the master > branch that should solve the build errors encountered. Would it be > possible to test a build of Userspace RCU master branch against those > two architectures ? If it works fine, then I could backport this commit > into the stable-0.7 branch. Where do I get this master branch? debcheckout doesn't. Also, please direct this request to the porter list (Cc-ed) giving more people a chance to repond. Christoph From mathieu.desnoyers at efficios.com Sun Mar 3 02:05:49 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Sun, 3 Mar 2013 02:05:49 -0500 Subject: [lttng-dev] Package liburcu fix for kfreebsd-amd64 and kfreebsd-i386 In-Reply-To: <87bob1ftwa.fsf@mitoraj.siccegge.de> References: <20130222134515.GA22069@Krystal> <87bob1ftwa.fsf@mitoraj.siccegge.de> Message-ID: <20130303070549.GA7315@Krystal> * Christoph Egger (christoph at debian.org) wrote: > Mathieu Desnoyers writes: > > I noticed failures to build for the liburcu Debian package for > > kfreebsd-amd64 and kfreebsd-i386. I just pushed a commit into the master > > branch that should solve the build errors encountered. Would it be > > possible to test a build of Userspace RCU master branch against those > > two architectures ? If it works fine, then I could backport this commit > > into the stable-0.7 branch. > > Where do I get this master branch? debcheckout doesn't. Also, please > direct this request to the porter list (Cc-ed) giving more people a > chance to repond. You can get it from: git clone git://git.lttng.org/userspace-rcu.git or use the gitweb interface: https://git.lttng.org/?p=userspace-rcu.git;a=summary Thanks! Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From david.bryant at quantum.com Sun Mar 3 18:51:45 2013 From: david.bryant at quantum.com (David Bryant) Date: Mon, 04 Mar 2013 10:21:45 +1030 Subject: [lttng-dev] static versus dynamic linking (TRACEPOINT_PROBE_DYNAMIC_LINKAGE) Message-ID: <5133E211.8070909@quantum.com> Hello, I'm trying to decide whether to use static or dynamic tracepoint probe linkage. What are the factors that I should consider? Are there any licensing related issues? For example, is closed-source software allowed to use static linking? Is it purely an organisational feature, i.e., allowing a program to be cleanly severed from its probes when they are not in use? (This is a bit of a re-post, but I didn't get any response last time...) Thanks, Dave From Paul_Woegerer at mentor.com Mon Mar 4 02:57:39 2013 From: Paul_Woegerer at mentor.com (Woegerer, Paul) Date: Mon, 4 Mar 2013 08:57:39 +0100 Subject: [lttng-dev] static versus dynamic linking (TRACEPOINT_PROBE_DYNAMIC_LINKAGE) In-Reply-To: <5133E211.8070909@quantum.com> References: <5133E211.8070909@quantum.com> Message-ID: <513453F3.6040506@mentor.com> On 03/04/2013 12:51 AM, David Bryant wrote: > Hello, > > I'm trying to decide whether to use static or dynamic tracepoint probe > linkage. What are the factors that I should consider? IMHO, whenever you are about to emit tracepoints from shared objects it's desirable to have the tracepoint provider being a shared object itself. You will likely want to share the tracepoint provider if you have e.g. two shared objects that both emit events from the same tracepoint provider. Also consider dlopend shared objects. When you unload them via dlclose it would trigger the static dtors to deregister its tracepoints (in the static tracepoint probe linkage case). If your application then goes on and tries to emit events of that kind elsewhere it will not work anymore. Using dynamic tracepoint providers passes this "application wide reference counting problem" to the dynamic linker which will not run dtors that deregister tracepoints as long as some other part of your application is still referring to it. -- Paul Woegerer | SW Development Engineer http://go.mentor.com/sourceryanalyzer Mentor Embedded(tm) | Prinz Eugen Stra?e 72/2/4, Vienna, 1040 Austria Nucleus? | Linux? | Android(tm) | Services | UI | Multi-OS Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. From amit.balboul at shinesec.com Mon Mar 4 12:02:14 2013 From: amit.balboul at shinesec.com (Amit Balboul) Date: Mon, 4 Mar 2013 19:02:14 +0200 Subject: [lttng-dev] Changes in the lttng-tools cause issues in build Message-ID: Hi all, I recently pulled the updated sources from the lttng-tools repository, having the latest *commit e58727c84472f69d641d94efaf90e728cda84a6b.* * * When I tried to re-build it I'm having some issues in compilation. (I'm building for Android but those issues are not related to it). Some I managed to workaroud, but some, like for example ust-registry.h:70: error: field 'header_type' has incomplete type are just an enigma. I assume this is not some configuration issue since grep-ing ustctl_channel_header in the source doesn't result any useful match (just some uses of it). Am I missing something here? Amit. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgoulet at efficios.com Mon Mar 4 12:06:22 2013 From: dgoulet at efficios.com (David Goulet) Date: Mon, 04 Mar 2013 12:06:22 -0500 Subject: [lttng-dev] Changes in the lttng-tools cause issues in build In-Reply-To: References: Message-ID: <5134D48E.1020406@efficios.com> Hi Amit, Have you tried to bootstrap the repository again with a make distclean ? Second thing, this "header_type" is an enum from LTTng-UST and you should make sure that you have the HEAD of master to build with the master of tools. Let me know if you solved the issue. Thanks! David Amit Balboul: > Hi all, > > I recently pulled the updated sources from the lttng-tools repository, > having the latest *commit e58727c84472f69d641d94efaf90e728cda84a6b.* > * > * > When I tried to re-build it I'm having some issues in compilation. > (I'm building for Android but those issues are not related to it). > Some I managed to workaroud, but some, like for example > > ust-registry.h:70: error: field 'header_type' has incomplete type > > are just an enigma. I assume this is not some configuration issue since > grep-ing ustctl_channel_header in the source doesn't result any useful > match (just some uses of it). > > Am I missing something here? > > Amit. > > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From nikitha.annaji at vayavyalabs.com Tue Mar 5 08:41:52 2013 From: nikitha.annaji at vayavyalabs.com (Nikitha Annaji) Date: Tue, 5 Mar 2013 19:11:52 +0530 Subject: [lttng-dev] Babeltrace v1.0.3 Message-ID: Hi, I was using the babeltrace version v1.0.0-rc1 and it use to produce the text log when we give the ctf input, but when i switched Babeltrace to the newer version it is started giving this error : babeltrace: symbol lookup error: babeltrace: undefined symbol: opt_clock_cycles . Can you please tell me what should be done so that i will not get this error again. Thanks & Regards Nikitha Annaji From jeremie.galarneau at efficios.com Tue Mar 5 13:38:18 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Tue, 5 Mar 2013 13:38:18 -0500 Subject: [lttng-dev] Babeltrace v1.0.3 In-Reply-To: References: Message-ID: Hi Nikitha, I'd be glad to help you but I need more details. On which platform are you getting this error? Are you using a pre-compiled package from your distribution or did you build babeltrace yourself? If you compiled it yourself, which configuration options did you use? Regards, J?r?mie On Tue, Mar 5, 2013 at 8:41 AM, Nikitha Annaji wrote: > Hi, > I was using the babeltrace version v1.0.0-rc1 and it use to produce > the text log when we give the ctf input, > but when i switched Babeltrace to the newer version it is started > giving this error : babeltrace: symbol lookup error: babeltrace: > undefined symbol: opt_clock_cycles . Can you please tell me what > should be done so that i will not get this error again. > > Thanks & Regards > Nikitha Annaji > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From Daniel.Thibault at drdc-rddc.gc.ca Tue Mar 5 15:40:53 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Tue, 5 Mar 2013 20:40:53 +0000 Subject: [lttng-dev] make lttng-ust Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD025F4E@VAL-E-01.valcartier.drdc-rddc.gc.ca> The last few times I rebuilt the lttng-ust package, make's log contains some ominous complaints, although it seems to nevertheless complete normally. Here's an excerpt: ########## Begin ########## CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/config/missing --run aclocal-1.11 -I config cd . && /bin/bash /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/config/missing --run automake-1.11 --foreign CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/config/missing --run autoconf /bin/bash ./config.status --recheck running CONFIG_SHELL=/bin/bash /bin/bash ./configure --with-java-jdk=/usr/lib/jvm/java-1.7.0-openjdk-amd64 --with-jni-interface LDFLAGS=-L/usr/local/lib --no-create --no-recursion checking build system type... x86_64-unknown-linux-gnu [...] checking for jni.h... yes configure: creating ./config.status Version name: Basse Messe Light coloured German ale whose style was named after the city Cologne (Koln) where it was first brewed. It is a rather simple beer with lightly fruity aromas and a delicate hoppy fragrance. The beer has a pronounced malty taste with a subtle bitter aftertaste LTTng-UST will be built with the following options: Java support (JNI): Enabled sdt.h integration: Disabled Type 'make' to compile. /bin/bash ./config.status config.status: creating Makefile [...] config.status: executing libtool commands (CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/config/missing --run autoheader) rm -f stamp-h1 touch config.h.in cd . && /bin/bash ./config.status config.h config.status: creating config.h config.status: config.h is unchanged make all-recursive make[1]: entrant dans le r?pertoire ? /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac ? Making all in . [...] Making all in libringbuffer make[2]: entrant dans le r?pertoire ? /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/libringbuffer ? CC libringbuffer_la-smp.lo CC libringbuffer_la-shm.lo shm.c: In function '_shm_object_table_alloc_shm': shm.c:148:9: warning: ignoring return value of 'mktemp', declared with attribute warn_unused_result [-Wunused-result] CC libringbuffer_la-ring_buffer_backend.lo CC libringbuffer_la-ring_buffer_frontend.lo CCLD libringbuffer.la make[2]: quittant le r?pertoire ? /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/libringbuffer ? [...] Making all in hello make[3]: entrant dans le r?pertoire ? /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/tests/hello ? CC hello-hello.o In file included from /usr/include/x86_64-linux-gnu/sys/socket.h:40:0, from /usr/include/netinet/in.h:25, from /usr/include/arpa/inet.h:23, from hello.c:29: /usr/include/x86_64-linux-gnu/bits/socket.h:433:23: attention : 'struct mmsghdr' declared inside parameter list [enabled by default] /usr/include/x86_64-linux-gnu/bits/socket.h:433:23: attention : visible uniquement depuis cette d?finition ou d?claration, ce qui n'est probablement pas ce que vous d?sirez [enabled by default] /usr/include/x86_64-linux-gnu/bits/socket.h:440:8: attention : 'struct mmsghdr' declared inside parameter list [enabled by default] CC hello-tp.o CCLD hello make[3]: quittant le r?pertoire ? /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/tests/hello ? Making all in hello-static-lib make[3]: entrant dans le r?pertoire ? /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/tests/hello-static-lib ? CC tp.lo CCLD liblttng-ust-provider-ust-test-hello.la CC hello.o In file included from /usr/include/x86_64-linux-gnu/sys/socket.h:40:0, from /usr/include/netinet/in.h:25, from /usr/include/arpa/inet.h:23, from hello.c:29: /usr/include/x86_64-linux-gnu/bits/socket.h:433:23: attention : 'struct mmsghdr' declared inside parameter list [enabled by default] /usr/include/x86_64-linux-gnu/bits/socket.h:433:23: attention : visible uniquement depuis cette d?finition ou d?claration, ce qui n'est probablement pas ce que vous d?sirez [enabled by default] /usr/include/x86_64-linux-gnu/bits/socket.h:440:8: attention : 'struct mmsghdr' declared inside parameter list [enabled by default] CCLD hello make[3]: quittant le r?pertoire ? /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/tests/hello-static-lib ? [...] Making all in demo make[3]: entrant dans le r?pertoire ? /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/tests/demo ? CC tp.lo CC tp2.lo CCLD liblttng-ust-provider-ust-tests-demo.la CC tp3.lo CCLD liblttng-ust-provider-ust-tests-demo3.la CC demo.o In file included from /usr/include/x86_64-linux-gnu/sys/socket.h:40:0, from /usr/include/netinet/in.h:25, from /usr/include/arpa/inet.h:23, from demo.c:29: /usr/include/x86_64-linux-gnu/bits/socket.h:433:23: attention : 'struct mmsghdr' declared inside parameter list [enabled by default] /usr/include/x86_64-linux-gnu/bits/socket.h:433:23: attention : visible uniquement depuis cette d?finition ou d?claration, ce qui n'est probablement pas ce que vous d?sirez [enabled by default] /usr/include/x86_64-linux-gnu/bits/socket.h:440:8: attention : 'struct mmsghdr' declared inside parameter list [enabled by default] CCLD demo make[3]: quittant le r?pertoire ? /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac/tests/demo ? [...] make[1]: quittant le r?pertoire ? /home/daniel/git.lttng.org/lttng-ust-2.1.1+-ac6b4ac ? ########## End ########## Is all this normal? I used the following script: $ ./bootstrap &> bootstrap.log $ LDFLAGS=-L/usr/local/lib ./configure --with-java-jdk=/usr/lib/jvm/java-1.7.0-openjdk-amd64 --with-jni-interface &> configure.log $ make &> make.log Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC? G3J 1X5 CANADA Vox?: (418) 844-4000 x4245 Fax?: (418) 844-4538 NAC?: 918V QSDJ Gouvernement du Canada?/ Government of Canada From mathieu.desnoyers at efficios.com Wed Mar 6 13:03:13 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 6 Mar 2013 13:03:13 -0500 Subject: [lttng-dev] [RFC] New LTTng domain attributes (buffer/include/exclude) Message-ID: <20130306180313.GA9899@Krystal> Hi, Following a discussion with other LTTng forks, we are coming up with the following idea to make soon-to-come per-user-id shared buffers for UST tracing. We'd like to get your feedback. Here is the idea: Both for per-process and per-uid (shared) buffers, we'd be working on the UST domain (-u/--userspace). We plan to add new attributes to domains: --buffers-pid: per PID buffers (current UST 2.0/2.1 behavior) --buffers-uid: per user ID buffers (upcoming in UST 2.2) --buffers-global: buffers shared across the system (e.g. kernel tracing) The UST default would stay "--buffers-pid", so just specifying "-u" without attribute would not change the current behavior. We plan on doing shortcuts, such as: -U: shortcut for -u --buffers-uid So we can do: lttng enable-event -U someeventA lttng enable-event -U someeventB rather than having to spell out the attribute argument for each enable-event/enable-channel. Other future attributes we plan on adding are inclusion/exclusion lists, followed by a comma-separated list: --include-pid 22,33,44 --include-uid 0,5 --exclude-pid 12,55 --exclude-uid 22 We believe these attributes will allow us to add those new configuration parameters to the toolchain without confusing users. At the API level (lttng.h), new attribute fields would be added to struct lttng_domain. The inclusion/exclusion lists would probably be separate "domain_set_attribute" APIs. Thoughts ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From Daniel.Thibault at drdc-rddc.gc.ca Wed Mar 6 14:58:43 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Wed, 6 Mar 2013 19:58:43 +0000 Subject: [lttng-dev] Userspace events not seen by kernel daemon? Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD0261A7@VAL-E-01.valcartier.drdc-rddc.gc.ca> I'm running an up-to-date LTTng suite (except for lttng-ust, where I'm using the 5 Mar 2013 20:17:22 commit). I've compiled the lttng-ust/doc/examples/easy-ust/sample application. While I run it (as a user *not* belonging to the tracing group), I notice something unexpected: * The local session daemon lists the sample user-space event ('lttng list -u') * The kernel session daemon does not see the sample user-space event at all ('sudo lttng list -u ') It was my understanding that the kernel daemon should see all kernel and user-space events (for as many user-spaces as there might be). To test this further, I set up two traces using separate consoles. The first is a user session: $ lttng create usersession $ lttng enable-event -u --all The other is a kernel session: $ sudo -H lttng create kernelsession $ sudo -H lttng enable-event -u --all $ sudo -H lttng enable-event -k sched_switch I start each session (respectively '$ lttng start' and '$ sudo -H lttng start') and the sample application (from a third console, '$ ./sample'). I wait until sample concludes, then shut down both sessions (respectively '$ lttng destroy' and '$ sudo -H lttng destroy'). Use of 'sudo -H' avoids current trace name collisions (contention over the .lttngrc file), as reported earlier on this list (but not filed as a bug...maybe I should do that too). The kernel trace contains no UST events, as can readily be discerned by the absence of a /ust branch in its folder structure. This is confirmed by babeltrace, which sees some 245 000 kernel events and nothing else. There are no missing events (babeltrace does not complain about skipped events, which it did with some other traces generated about the same time). The System Monitor shows two lttng-sessiond daemons (one for me, another for root) and three lttng-consumerd daemons (one for me, two for root) as expected. What did I do wrong? Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC? G3J 1X5 CANADA Vox?: (418) 844-4000 x4245 Fax?: (418) 844-4538 NAC?: 918V QSDJ Gouvernement du Canada?/ Government of Canada From amit.balboul at shinesec.com Wed Mar 6 18:09:44 2013 From: amit.balboul at shinesec.com (Amit Balboul) Date: Thu, 7 Mar 2013 01:09:44 +0200 Subject: [lttng-dev] Fwd: compiling LTTng for android In-Reply-To: References: Message-ID: Hi All, Regarding the last mail about tracing system calls on Android using LTTng, The issue of not receiving enabled event to trace from the kernel can be fixed patching src/bin/lttng-sessiond/kernel.c (patch attached) In the function *kernel_list_events,* fscanf-ing the events exported by the kernel using the fp must not use the syntax *%m* as it is obsolete (in Android), thus the fscanf returns 0 and won't read the kernel events (first condition false). Instead I use a pre-allocated buffer for the string and use the *%[^;]*syntax, and omitting the memory free (attached is the patch). The resulting output is (sessiond is run with verbose debug prints): root at android:/data/lttng/bin # *./lttng list -k* DEBUG1 [10239/10290]: Wait for client response (in thread_manage_clients() at main.c:3242) DEBUG1 [10239/10290]: Receiving data from client ... (in thread_manage_clients() at main.c:3287) DEBUG1 [10239/10290]: Nothing recv() from client... continuing (in thread_manage_clients() at main.c:3291) DEBUG1 [10239/10290]: Clean command context structure (in clean_command_ctx() at main.c:482) DEBUG1 [10239/10290]: Accepting client command ... (in thread_manage_clients() at main.c:3200) DEBUG1 [10239/10290]: Wait for client response (in thread_manage_clients() at main.c:3242) DEBUG1 [10239/10290]: Receiving data from client ... (in thread_manage_clients() at main.c:3287) DEBUG1 [10239/10290]: Processing client command 14 (in process_client_msg() at main.c:2227) DEBUG1 [10239/10290]: Kernel list events done (61 events) (in kernel_list_events() at kernel.c:653) DEBUG1 [10239/10290]: Sending response (size: 35640, retcode: Success) (in thread_manage_clients() at main.c:3338) DEBUG1 [10239/10290]: Clean command context structure (in clean_command_ctx() at main.c:482) DEBUG1 [10239/10290]: Accepting client command ... (in thread_manage_clients() at main.c:3200) Kernel events: ------------- block_rq_abort (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_rq_requeue (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_rq_complete (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_rq_insert (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_rq_issue (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_bio_bounce (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_bio_complete (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_bio_backmerge (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_bio_frontmerge (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_bio_queue (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_getrq (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_sleeprq (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_plug (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_unplug (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_split (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) irq_handler_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) irq_handler_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) softirq_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) softirq_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) softirq_raise (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_wakeup (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_switch (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_migrate_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_process_free (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_process_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_wait_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_process_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_process_fork (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_stat_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_stat_sleep (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_stat_iowait (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_stat_runtime (loglevel: TRACE_EMERG (0)) (type: tracepoint) sched_pi_setprio (loglevel: TRACE_EMERG (0)) (type: tracepoint) signal_generate (loglevel: TRACE_EMERG (0)) (type: tracepoint) signal_deliver (loglevel: TRACE_EMERG (0)) (type: tracepoint) signal_overflow_fail (loglevel: TRACE_EMERG (0)) (type: tracepoint) signal_lose_info (loglevel: TRACE_EMERG (0)) (type: tracepoint) lttng_statedump_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) lttng_statedump_end (loglevel: TRACE_EMERG (0)) (type: tracepoint) lttng_statedump_process_state (loglevel: TRACE_EMERG (0)) (type: tracepoint) lttng_statedump_file_descriptor (loglevel: TRACE_EMERG (0)) (type: tracepoint) lttng_statedump_vm_map (loglevel: TRACE_EMERG (0)) (type: tracepoint) lttng_statedump_network_interface (loglevel: TRACE_EMERG (0)) (type: tracepoint) lttng_statedump_interrupt (loglevel: TRACE_EMERG (0)) (type: tracepoint) timer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) timer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) timer_expire_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) timer_expire_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) timer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) hrtimer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) hrtimer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) hrtimer_expire_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) hrtimer_expire_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) hrtimer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) itimer_state (loglevel: TRACE_EMERG (0)) (type: tracepoint) itimer_expire (loglevel: TRACE_EMERG (0)) (type: tracepoint) root at android:/data/lttng/bin # Now I'm facing the issue of starting the traces: debugging the sessiond, consumerd and lttng I concluded that the issue is due to splice system call failure. even using a MMAP output type channel, the metadata channel is SPLICE type (hard-coded). Problem persists also when using relayd to pass the traces through the network. Ignoring the splice failure means closing of the metadata channel (maybe??) but need not affect the traces channel (right ?) Attached is a debug log of each thread of the sessiond, right after invoking "*./lttng start*". (with extra informative my prints) Please keep me in touch with any progress in this issue, Thank you, Amit. ---------- Forwarded message ---------- From: Amit Balboul Date: Wed, Feb 27, 2013 at 4:37 PM Subject: Re: [lttng-dev] compiling LTTng for android To: PLSTC Hey Pierre, Some major progress has been achieved, following is the summary: 1. Modules issue: I built (for ARM/Android) and installed latest stable version of busybox on the device. Seeing the code tries to run (hardcoded) /sbin/modprobe, made a soft link to busybox's modeprobe. Also, created /lib/modules/ directory and pushed the directory from /lib/modules on the machine. Now session daemon modprobes the desired modules successfully, (some are not present though as mentioned before) - no need to use insmod. 2. epoll_create1 issue: epoll_create1 patch was OK, I accidentally defined EPOLL_CLOEXEC as 0x02000000 instead of 02000000 (fixed). The running scenario: 1. Run ./lttng-sessiond -d -vvv Then: (commands are in bold, output is in blue for readability) root at android:/data/lttng/install_sysroot/bin # *./lttng create s1* Session s1 created. Traces will be written in /data/lttng-traces/s1-20130227-161145 root at android:/data/lttng/install_sysroot/bin # *./lttng enable-channel ch -k * Kernel channel ch enabled for session s1 root at android:/data/lttng/install_sysroot/bin # *./lttng enable-event ev -k -a* All kernel events are enabled in channel channel0 root at android:/data/lttng/install_sysroot/bin # *./lttng list s1* Tracing session s1: [inactive] Trace path: /data/lttng-traces/s1-20130227-161145 === Domain: Kernel === Channels: ------------- - channel0: [enabled] Attributes: overwrite mode: 0 subbufers size: 262144 number of subbufers: 4 switch timer interval: 0 read timer interval: 200 output: splice() Events: None - ch: [enabled] Attributes: overwrite mode: 0 subbufers size: 262144 number of subbufers: 4 switch timer interval: 0 read timer interval: 200 output: splice() Events: None root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * Kernel events: ------------- root at android:/data/lttng/install_sysroot/bin # *./lttng start* Tracing started for session s1 root at android:/data/lttng/install_sysroot/bin # *./lttng stop * Waiting for data availability Tracing stopped for session s1 root at android:/data/lttng/install_sysroot/bin # *Now: (this is not surprising because the kernel events list is empty...)* the folder /data/lttng-traces/s1-20130227-161145/kernel contains: total 0 -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_0 -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_1 -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_0 -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_1 -rwxrwxrwx 1 0 0 0 Feb 27 14:18 metadata *By the way:* When running the same scenario but creating the channel with *--output mmap*, still no data but the size of the first two files in the traces directory are 4Kb (I didn't bother to investigate them as I assume it is just the header - not the traces payload). Another issue: at this point, listing the sessions gives: root at android:/data/lttng/install_sysroot/bin # *./lttng list s1 * Tracing session s1: [inactive] Trace path: /data/lttng-traces/s1-20130227-161145 === Domain: Kernel === Error: No kernel consumer detected 99|root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * Error: Unable to list kernel events Error: Command error 1|root at android:/data/lttng/install_sysroot/bin # So currently I'm facing these issues: 1. Kernel events list is empty. 2. Listing the session/ kernel events after creating session, channel, event, start, stop - results in "no kernel consumer detected" If you have some insights please share them with me.. Thanks Amit. On Tue, Feb 26, 2013 at 7:35 PM, PLSTC wrote: > The modules you can't find are the same I am also missing I believe; I > think they are only compiled when certain kernel config defines are met > (and those might simply be unavailable under ARM). > > As for what you pointed in your first mail, I believe modprobe isn't > available on ARM, did you mean that some modules were not found when using > insmod? > > For the epoll_create1 problem, what kind of patch did you apply to add > support for the epoll_create1 function? > > > On Tue, Feb 26, 2013 at 11:29 AM, Amit Balboul wrote: > >> Ok I got : >> lttng-kretprobes.ko >> lttng-kprobes.ko >> , the other two are missing. >> >> >> ---------- Forwarded message ---------- >> From: Amit Balboul >> Date: Tue, Feb 26, 2013 at 5:49 PM >> Subject: Re: [lttng-dev] compiling LTTng for android >> To: PLSTC >> >> >> One more thing: >> >> The list of modules you gave my is not identical to mine: >> a. I pushed the modules from my machine to my folder in the device (not >> to /system/lib) as you directed me, and insmoded them manually. >> b. I pushed the whole tree under /lib/modules// which >> includes the modules.* and the sub directories: >> >> /lib/modules/3.0.31-gd5a18e0/extra$ ll >> total 2464 >> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ./ >> drwxr-xr-x 3 root root 4096 Feb 26 15:58 ../ >> drwxr-xr-x 2 root root 4096 Feb 26 15:58 lib/ >> -rw-r--r-- 1 root root 167184 Feb 26 15:58 >> lttng-ring-buffer-client-discard.ko >> -rw-r--r-- 1 root root 167206 Feb 26 15:58 >> lttng-ring-buffer-client-mmap-discard.ko >> -rw-r--r-- 1 root root 178586 Feb 26 15:58 >> lttng-ring-buffer-client-mmap-overwrite.ko >> -rw-r--r-- 1 root root 178564 Feb 26 15:58 >> lttng-ring-buffer-client-overwrite.ko >> -rw-r--r-- 1 root root 137179 Feb 26 15:58 >> lttng-ring-buffer-metadata-client.ko >> -rw-r--r-- 1 root root 137233 Feb 26 15:58 >> lttng-ring-buffer-metadata-mmap-client.ko >> -rw-r--r-- 1 root root 213451 Feb 26 15:58 lttng-statedump.ko >> -rw-r--r-- 1 root root 1314235 Feb 26 15:58 lttng-tracer.ko >> drwxr-xr-x 2 root root 4096 Feb 26 15:58 probes/ >> >> /lib/modules/3.0.31-gd5a18e0/extra/lib$ ll >> total 732 >> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ >> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ >> -rw-r--r-- 1 root root 738964 Feb 26 15:58 lttng-lib-ring-buffer.ko >> >> /lib/modules/3.0.31-gd5a18e0/extra/probes$ ll >> total 2872 >> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ >> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ >> -rw-r--r-- 1 root root 162872 Feb 26 15:58 lttng-probe-asoc.ko >> -rw-r--r-- 1 root root 171049 Feb 26 15:58 lttng-probe-block.ko >> -rw-r--r-- 1 root root 81165 Feb 26 15:58 lttng-probe-compaction.ko >> -rw-r--r-- 1 root root 333215 Feb 26 15:58 lttng-probe-ext4.ko >> -rw-r--r-- 1 root root 80413 Feb 26 15:58 lttng-probe-gpio.ko >> -rw-r--r-- 1 root root 84256 Feb 26 15:58 lttng-probe-irq.ko >> -rw-r--r-- 1 root root 135453 Feb 26 15:58 lttng-probe-jbd2.ko >> -rw-r--r-- 1 root root 105399 Feb 26 15:58 lttng-probe-kmem.ko >> -rw-r--r-- 1 root root 76240 Feb 26 15:58 lttng-probe-lttng.ko >> -rw-r--r-- 1 root root 88059 Feb 26 15:58 lttng-probe-module.ko >> -rw-r--r-- 1 root root 154032 Feb 26 15:58 lttng-probe-napi.ko >> -rw-r--r-- 1 root root 142038 Feb 26 15:58 lttng-probe-net.ko >> -rw-r--r-- 1 root root 93564 Feb 26 15:58 lttng-probe-power.ko >> -rw-r--r-- 1 root root 85530 Feb 26 15:58 lttng-probe-regulator.ko >> -rw-r--r-- 1 root root 138121 Feb 26 15:58 lttng-probe-sched.ko >> -rw-r--r-- 1 root root 152909 Feb 26 15:58 lttng-probe-scsi.ko >> -rw-r--r-- 1 root root 107491 Feb 26 15:58 lttng-probe-signal.ko >> -rw-r--r-- 1 root root 142711 Feb 26 15:58 lttng-probe-skb.ko >> -rw-r--r-- 1 root root 181983 Feb 26 15:58 lttng-probe-statedump.ko >> -rw-r--r-- 1 root root 126731 Feb 26 15:58 lttng-probe-timer.ko >> -rw-r--r-- 1 root root 86591 Feb 26 15:58 lttng-probe-workqueue.ko >> -rw-r--r-- 1 root root 133886 Feb 26 15:58 lttng-probe-writeback.ko >> -rw-r--r-- 1 root root 30863 Feb 26 15:58 lttng-types.ko >> >> Looking at the files shows I miss: >> lttng-kretprobes.ko >> lttng-kprobes.ko >> lttng-ftrace.ko >> lttng-probe-kvm.ko >> >> >> On Tue, Feb 26, 2013 at 3:56 PM, PLSTC wrote: >> >>> Back on the last email: >>> >>> Here's the insmod list I ended up building; you might not have compiled >>> all those modules, depending on your kernel config and on the architecture >>> used, so some might simply be absent from your output directory. >>> >>> insmod /system/lib/modules/lttng-types.ko >>> insmod /system/lib/modules/lttng-kretprobes.ko >>> insmod /system/lib/modules/lttng-kprobes.ko >>> insmod /system/lib/modules/lttng-ftrace.ko >>> insmod /system/lib/modules/lttng-lib-ring-buffer.ko >>> insmod /system/lib/modules/lttng-statedump.ko >>> insmod /system/lib/modules/lttng-tracer.ko >>> insmod /system/lib/modules/lttng-probe-timer.ko >>> insmod /system/lib/modules/lttng-probe-statedump.ko >>> insmod /system/lib/modules/lttng-probe-signal.ko >>> insmod /system/lib/modules/lttng-probe-sched.ko >>> insmod /system/lib/modules/lttng-probe-lttng.ko >>> insmod /system/lib/modules/lttng-probe-kvm.ko >>> insmod /system/lib/modules/lttng-probe-irq.ko >>> insmod /system/lib/modules/lttng-probe-block.ko >>> insmod /system/lib/modules/lttng-ring-buffer-metadata-mmap-client.ko >>> insmod /system/lib/modules/lttng-ring-buffer-metadata-client.ko >>> insmod /system/lib/modules/lttng-ring-buffer-client-overwrite.ko >>> insmod /system/lib/modules/lttng-ring-buffer-client-mmap-overwrite.ko >>> insmod /system/lib/modules/lttng-ring-buffer-client-mmap-discard.ko >>> insmod /system/lib/modules/lttng-ring-buffer-client-discard.ko >>> >>> >>> We also haven't had time recently to test if the kprobes/kretprobes >>> worked, but they probably do; we decided to focus a bit more on the >>> 'tracepoints' aspect instead. >>> >>> Anyway, good luck with your exploration, and if you find something >>> interesting, I'd love to know more about it! >>> >>> -PL >>> >>> On Tue, Feb 26, 2013 at 8:06 AM, PLSTC wrote: >>> >>>> Hey Amit, >>>> >>>> Good news indeed it seems! >>>> >>>> When it comes to pushing the libs/bin, we haven't found any better way >>>> than using adb push yet; of course, if all the projects were included >>>> directly in Android's external, we would simply flash the device after each >>>> build, but currently we're still having trouble generating the correct >>>> Android makefiles. >>>> >>>> As for the modules, I might still have a dep load list somewhere I >>>> could send you in a few hours, I remember fighting to get the order right... >>>> >>>> Also, once everything loads, could you tell me what kind of output >>>> 'lttng list -k' provides you? Here, we're having trouble listing the >>>> 'default' kernel trace points provided by HAVE_TRACEPOINTS, and the >>>> returned list is simply empty (which is a bit strange). >>>> >>>> -PL >>>> >>> >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: kernel.c.patch Type: application/octet-stream Size: 1285 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: l_after_start_0.sessiond Type: application/octet-stream Size: 2955 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: l_after_start_1.sessiond Type: application/octet-stream Size: 2880 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: l_after_start_2.sessiond Type: application/octet-stream Size: 2105 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: l_after_start_3.sessiond Type: application/octet-stream Size: 1115 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: l_after_start_4.sessiond Type: application/octet-stream Size: 98 bytes Desc: not available URL: From pierre-luc.st-charles at polymtl.ca Wed Mar 6 20:04:04 2013 From: pierre-luc.st-charles at polymtl.ca (Pierre-Luc St-Charles) Date: Wed, 6 Mar 2013 20:04:04 -0500 Subject: [lttng-dev] Fwd: compiling LTTng for android In-Reply-To: References: Message-ID: Great findings! I'll also try to look into this new problem by next monday; I'm falling a bit behind on my 'investigations', but I'll keep you updated if anything comes up. -PL On Mar 6, 2013 6:09 PM, "Amit Balboul" wrote: > Hi All, > > Regarding the last mail about tracing system calls on Android using LTTng, > The issue of not receiving enabled event to trace from the kernel can be > fixed patching src/bin/lttng-sessiond/kernel.c (patch attached) > In the function *kernel_list_events,* fscanf-ing the events exported by > the kernel using the fp must not use the syntax *%m* as it is obsolete > (in Android), > thus the fscanf returns 0 and won't read the kernel events (first > condition false). > Instead I use a pre-allocated buffer for the string and use the *%[^;]*syntax, and omitting the memory free (attached is the patch). > > The resulting output is (sessiond is run with verbose debug prints): > > root at android:/data/lttng/bin # *./lttng list -k* > DEBUG1 [10239/10290]: Wait for client response (in thread_manage_clients() > at main.c:3242) > DEBUG1 [10239/10290]: Receiving data from client ... (in > thread_manage_clients() at main.c:3287) > DEBUG1 [10239/10290]: Nothing recv() from client... continuing (in > thread_manage_clients() at main.c:3291) > DEBUG1 [10239/10290]: Clean command context structure (in > clean_command_ctx() at main.c:482) > DEBUG1 [10239/10290]: Accepting client command ... (in > thread_manage_clients() at main.c:3200) > DEBUG1 [10239/10290]: Wait for client response (in thread_manage_clients() > at main.c:3242) > DEBUG1 [10239/10290]: Receiving data from client ... (in > thread_manage_clients() at main.c:3287) > DEBUG1 [10239/10290]: Processing client command 14 (in > process_client_msg() at main.c:2227) > DEBUG1 [10239/10290]: Kernel list events done (61 events) (in > kernel_list_events() at kernel.c:653) > DEBUG1 [10239/10290]: Sending response (size: 35640, retcode: Success) (in > thread_manage_clients() at main.c:3338) > DEBUG1 [10239/10290]: Clean command context structure (in > clean_command_ctx() at main.c:482) > DEBUG1 [10239/10290]: Accepting client command ... (in > thread_manage_clients() at main.c:3200) > Kernel events: > ------------- > block_rq_abort (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_rq_requeue (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_rq_complete (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_rq_insert (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_rq_issue (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_bio_bounce (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_bio_complete (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_bio_backmerge (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_bio_frontmerge (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_bio_queue (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_getrq (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_sleeprq (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_plug (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_unplug (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_split (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) > block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) > irq_handler_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) > irq_handler_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > softirq_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) > softirq_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > softirq_raise (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_wakeup (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_switch (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_migrate_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_process_free (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_process_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_wait_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_process_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_process_fork (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_stat_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_stat_sleep (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_stat_iowait (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_stat_runtime (loglevel: TRACE_EMERG (0)) (type: tracepoint) > sched_pi_setprio (loglevel: TRACE_EMERG (0)) (type: tracepoint) > signal_generate (loglevel: TRACE_EMERG (0)) (type: tracepoint) > signal_deliver (loglevel: TRACE_EMERG (0)) (type: tracepoint) > signal_overflow_fail (loglevel: TRACE_EMERG (0)) (type: tracepoint) > signal_lose_info (loglevel: TRACE_EMERG (0)) (type: tracepoint) > lttng_statedump_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) > lttng_statedump_end (loglevel: TRACE_EMERG (0)) (type: tracepoint) > lttng_statedump_process_state (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > lttng_statedump_file_descriptor (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > lttng_statedump_vm_map (loglevel: TRACE_EMERG (0)) (type: tracepoint) > lttng_statedump_network_interface (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > lttng_statedump_interrupt (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > timer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) > timer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) > timer_expire_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) > timer_expire_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > timer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) > hrtimer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) > hrtimer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) > hrtimer_expire_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) > hrtimer_expire_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > hrtimer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) > itimer_state (loglevel: TRACE_EMERG (0)) (type: tracepoint) > itimer_expire (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > root at android:/data/lttng/bin # > > Now I'm facing the issue of starting the traces: > debugging the sessiond, consumerd and lttng I concluded that the issue is > due to splice system call failure. > even using a MMAP output type channel, the metadata channel is SPLICE type > (hard-coded). > Problem persists also when using relayd to pass the traces through the > network. > Ignoring the splice failure means closing of the metadata channel > (maybe??) but need not affect the traces channel (right ?) > Attached is a debug log of each thread of the sessiond, right after > invoking "*./lttng start*". (with extra informative my prints) > > Please keep me in touch with any progress in this issue, > Thank you, > Amit. > > > > > > > ---------- Forwarded message ---------- > From: Amit Balboul > Date: Wed, Feb 27, 2013 at 4:37 PM > Subject: Re: [lttng-dev] compiling LTTng for android > To: PLSTC > > > Hey Pierre, > > Some major progress has been achieved, following is the summary: > > 1. Modules issue: > I built (for ARM/Android) and installed latest stable version of busybox > on the device. > Seeing the code tries to run (hardcoded) /sbin/modprobe, made a soft link > to busybox's modeprobe. > Also, created /lib/modules/ directory and pushed the > directory from /lib/modules on the machine. > Now session daemon modprobes the desired modules successfully, (some are > not present though as mentioned before) - no need to use insmod. > > 2. epoll_create1 issue: > epoll_create1 patch was OK, I accidentally defined EPOLL_CLOEXEC as > 0x02000000 instead of 02000000 (fixed). > > The running scenario: > > 1. Run ./lttng-sessiond -d -vvv > > Then: (commands are in bold, output is in blue for readability) > > root at android:/data/lttng/install_sysroot/bin # *./lttng create s1* > > Session s1 created. > Traces will be written in /data/lttng-traces/s1-20130227-161145 > root at android:/data/lttng/install_sysroot/bin # *./lttng enable-channel ch > -k* > Kernel channel ch enabled for session s1 > root at android:/data/lttng/install_sysroot/bin # *./lttng enable-event ev > -k -a* > All kernel events are enabled in channel channel0 > root at android:/data/lttng/install_sysroot/bin # *./lttng list s1* > Tracing session s1: [inactive] > Trace path: /data/lttng-traces/s1-20130227-161145 > > === Domain: Kernel === > > Channels: > ------------- > - channel0: [enabled] > > Attributes: > overwrite mode: 0 > subbufers size: 262144 > number of subbufers: 4 > switch timer interval: 0 > read timer interval: 200 > output: splice() > > Events: > None > > - ch: [enabled] > > Attributes: > overwrite mode: 0 > subbufers size: 262144 > number of subbufers: 4 > switch timer interval: 0 > read timer interval: 200 > output: splice() > > Events: > None > > root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * > > Kernel events: > ------------- > > root at android:/data/lttng/install_sysroot/bin # *./lttng start* > Tracing started for session s1 > root at android:/data/lttng/install_sysroot/bin # *./lttng stop * > > Waiting for data availability > Tracing stopped for session s1 > root at android:/data/lttng/install_sysroot/bin # > > *Now: (this is not surprising because the kernel events list is empty...)* > the folder /data/lttng-traces/s1-20130227-161145/kernel contains: > total 0 > -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_0 > -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_1 > -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_0 > -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_1 > -rwxrwxrwx 1 0 0 0 Feb 27 14:18 metadata > > *By the way:* > When running the same scenario but creating the channel with *--output > mmap*, still no data but the size of the first two files in the traces > directory are 4Kb (I didn't bother to investigate them as I assume it is > just the header - not the traces payload). > > Another issue: at this point, listing the sessions gives: > root at android:/data/lttng/install_sysroot/bin # *./lttng list s1 * > > Tracing session s1: [inactive] > Trace path: /data/lttng-traces/s1-20130227-161145 > > === Domain: Kernel === > > Error: No kernel consumer detected > 99|root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * > > Error: Unable to list kernel events > Error: Command error > 1|root at android:/data/lttng/install_sysroot/bin # > > So currently I'm facing these issues: > 1. Kernel events list is empty. > 2. Listing the session/ kernel events after creating session, channel, > event, start, stop - results in "no kernel consumer detected" > > If you have some insights please share them with me.. > > Thanks > > Amit. > > > On Tue, Feb 26, 2013 at 7:35 PM, PLSTC wrote: > >> The modules you can't find are the same I am also missing I believe; I >> think they are only compiled when certain kernel config defines are met >> (and those might simply be unavailable under ARM). >> >> As for what you pointed in your first mail, I believe modprobe isn't >> available on ARM, did you mean that some modules were not found when using >> insmod? >> >> For the epoll_create1 problem, what kind of patch did you apply to add >> support for the epoll_create1 function? >> >> >> On Tue, Feb 26, 2013 at 11:29 AM, Amit Balboul > > wrote: >> >>> Ok I got : >>> lttng-kretprobes.ko >>> lttng-kprobes.ko >>> , the other two are missing. >>> >>> >>> ---------- Forwarded message ---------- >>> From: Amit Balboul >>> Date: Tue, Feb 26, 2013 at 5:49 PM >>> Subject: Re: [lttng-dev] compiling LTTng for android >>> To: PLSTC >>> >>> >>> One more thing: >>> >>> The list of modules you gave my is not identical to mine: >>> a. I pushed the modules from my machine to my folder in the device (not >>> to /system/lib) as you directed me, and insmoded them manually. >>> b. I pushed the whole tree under /lib/modules// which >>> includes the modules.* and the sub directories: >>> >>> /lib/modules/3.0.31-gd5a18e0/extra$ ll >>> total 2464 >>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ./ >>> drwxr-xr-x 3 root root 4096 Feb 26 15:58 ../ >>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 lib/ >>> -rw-r--r-- 1 root root 167184 Feb 26 15:58 >>> lttng-ring-buffer-client-discard.ko >>> -rw-r--r-- 1 root root 167206 Feb 26 15:58 >>> lttng-ring-buffer-client-mmap-discard.ko >>> -rw-r--r-- 1 root root 178586 Feb 26 15:58 >>> lttng-ring-buffer-client-mmap-overwrite.ko >>> -rw-r--r-- 1 root root 178564 Feb 26 15:58 >>> lttng-ring-buffer-client-overwrite.ko >>> -rw-r--r-- 1 root root 137179 Feb 26 15:58 >>> lttng-ring-buffer-metadata-client.ko >>> -rw-r--r-- 1 root root 137233 Feb 26 15:58 >>> lttng-ring-buffer-metadata-mmap-client.ko >>> -rw-r--r-- 1 root root 213451 Feb 26 15:58 lttng-statedump.ko >>> -rw-r--r-- 1 root root 1314235 Feb 26 15:58 lttng-tracer.ko >>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 probes/ >>> >>> /lib/modules/3.0.31-gd5a18e0/extra/lib$ ll >>> total 732 >>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ >>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ >>> -rw-r--r-- 1 root root 738964 Feb 26 15:58 lttng-lib-ring-buffer.ko >>> >>> /lib/modules/3.0.31-gd5a18e0/extra/probes$ ll >>> total 2872 >>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ >>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ >>> -rw-r--r-- 1 root root 162872 Feb 26 15:58 lttng-probe-asoc.ko >>> -rw-r--r-- 1 root root 171049 Feb 26 15:58 lttng-probe-block.ko >>> -rw-r--r-- 1 root root 81165 Feb 26 15:58 lttng-probe-compaction.ko >>> -rw-r--r-- 1 root root 333215 Feb 26 15:58 lttng-probe-ext4.ko >>> -rw-r--r-- 1 root root 80413 Feb 26 15:58 lttng-probe-gpio.ko >>> -rw-r--r-- 1 root root 84256 Feb 26 15:58 lttng-probe-irq.ko >>> -rw-r--r-- 1 root root 135453 Feb 26 15:58 lttng-probe-jbd2.ko >>> -rw-r--r-- 1 root root 105399 Feb 26 15:58 lttng-probe-kmem.ko >>> -rw-r--r-- 1 root root 76240 Feb 26 15:58 lttng-probe-lttng.ko >>> -rw-r--r-- 1 root root 88059 Feb 26 15:58 lttng-probe-module.ko >>> -rw-r--r-- 1 root root 154032 Feb 26 15:58 lttng-probe-napi.ko >>> -rw-r--r-- 1 root root 142038 Feb 26 15:58 lttng-probe-net.ko >>> -rw-r--r-- 1 root root 93564 Feb 26 15:58 lttng-probe-power.ko >>> -rw-r--r-- 1 root root 85530 Feb 26 15:58 lttng-probe-regulator.ko >>> -rw-r--r-- 1 root root 138121 Feb 26 15:58 lttng-probe-sched.ko >>> -rw-r--r-- 1 root root 152909 Feb 26 15:58 lttng-probe-scsi.ko >>> -rw-r--r-- 1 root root 107491 Feb 26 15:58 lttng-probe-signal.ko >>> -rw-r--r-- 1 root root 142711 Feb 26 15:58 lttng-probe-skb.ko >>> -rw-r--r-- 1 root root 181983 Feb 26 15:58 lttng-probe-statedump.ko >>> -rw-r--r-- 1 root root 126731 Feb 26 15:58 lttng-probe-timer.ko >>> -rw-r--r-- 1 root root 86591 Feb 26 15:58 lttng-probe-workqueue.ko >>> -rw-r--r-- 1 root root 133886 Feb 26 15:58 lttng-probe-writeback.ko >>> -rw-r--r-- 1 root root 30863 Feb 26 15:58 lttng-types.ko >>> >>> Looking at the files shows I miss: >>> lttng-kretprobes.ko >>> lttng-kprobes.ko >>> lttng-ftrace.ko >>> lttng-probe-kvm.ko >>> >>> >>> On Tue, Feb 26, 2013 at 3:56 PM, PLSTC wrote: >>> >>>> Back on the last email: >>>> >>>> Here's the insmod list I ended up building; you might not have compiled >>>> all those modules, depending on your kernel config and on the architecture >>>> used, so some might simply be absent from your output directory. >>>> >>>> insmod /system/lib/modules/lttng-types.ko >>>> insmod /system/lib/modules/lttng-kretprobes.ko >>>> insmod /system/lib/modules/lttng-kprobes.ko >>>> insmod /system/lib/modules/lttng-ftrace.ko >>>> insmod /system/lib/modules/lttng-lib-ring-buffer.ko >>>> insmod /system/lib/modules/lttng-statedump.ko >>>> insmod /system/lib/modules/lttng-tracer.ko >>>> insmod /system/lib/modules/lttng-probe-timer.ko >>>> insmod /system/lib/modules/lttng-probe-statedump.ko >>>> insmod /system/lib/modules/lttng-probe-signal.ko >>>> insmod /system/lib/modules/lttng-probe-sched.ko >>>> insmod /system/lib/modules/lttng-probe-lttng.ko >>>> insmod /system/lib/modules/lttng-probe-kvm.ko >>>> insmod /system/lib/modules/lttng-probe-irq.ko >>>> insmod /system/lib/modules/lttng-probe-block.ko >>>> insmod /system/lib/modules/lttng-ring-buffer-metadata-mmap-client.ko >>>> insmod /system/lib/modules/lttng-ring-buffer-metadata-client.ko >>>> insmod /system/lib/modules/lttng-ring-buffer-client-overwrite.ko >>>> insmod /system/lib/modules/lttng-ring-buffer-client-mmap-overwrite.ko >>>> insmod /system/lib/modules/lttng-ring-buffer-client-mmap-discard.ko >>>> insmod /system/lib/modules/lttng-ring-buffer-client-discard.ko >>>> >>>> >>>> We also haven't had time recently to test if the kprobes/kretprobes >>>> worked, but they probably do; we decided to focus a bit more on the >>>> 'tracepoints' aspect instead. >>>> >>>> Anyway, good luck with your exploration, and if you find something >>>> interesting, I'd love to know more about it! >>>> >>>> -PL >>>> >>>> On Tue, Feb 26, 2013 at 8:06 AM, PLSTC wrote: >>>> >>>>> Hey Amit, >>>>> >>>>> Good news indeed it seems! >>>>> >>>>> When it comes to pushing the libs/bin, we haven't found any better way >>>>> than using adb push yet; of course, if all the projects were included >>>>> directly in Android's external, we would simply flash the device after each >>>>> build, but currently we're still having trouble generating the correct >>>>> Android makefiles. >>>>> >>>>> As for the modules, I might still have a dep load list somewhere I >>>>> could send you in a few hours, I remember fighting to get the order right... >>>>> >>>>> Also, once everything loads, could you tell me what kind of output >>>>> 'lttng list -k' provides you? Here, we're having trouble listing the >>>>> 'default' kernel trace points provided by HAVE_TRACEPOINTS, and the >>>>> returned list is simply empty (which is a bit strange). >>>>> >>>>> -PL >>>>> >>>> >>>> >>> >>> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Paul_Woegerer at mentor.com Thu Mar 7 04:19:03 2013 From: Paul_Woegerer at mentor.com (Woegerer, Paul) Date: Thu, 7 Mar 2013 10:19:03 +0100 Subject: [lttng-dev] [RFC] New LTTng domain attributes (buffer/include/exclude) In-Reply-To: <20130306180313.GA9899@Krystal> References: <20130306180313.GA9899@Krystal> Message-ID: <51385B87.5010500@mentor.com> On 03/06/2013 07:03 PM, Mathieu Desnoyers wrote: > Other future attributes we plan on adding are inclusion/exclusion lists, > followed by a comma-separated list: > > --include-pid 22,33,44 > --include-uid 0,5 > --exclude-pid 12,55 > --exclude-uid 22 How about child processes of the given pids ? Would it be the default to also collect their events into the buffer ? -- Paul Woegerer | SW Development Engineer http://go.mentor.com/sourceryanalyzer Mentor Embedded(tm) | Prinz Eugen Stra?e 72/2/4, Vienna, 1040 Austria Nucleus? | Linux? | Android(tm) | Services | UI | Multi-OS Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. From Daniel.Thibault at drdc-rddc.gc.ca Thu Mar 7 11:25:08 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Thu, 7 Mar 2013 16:25:08 +0000 Subject: [lttng-dev] babeltrace and strictly sorting events Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD026371@VAL-E-01.valcartier.drdc-rddc.gc.ca> Babeltrace sorts the events submitted to it from a variety of source files (multiple traces, each potentially with multiple domains, each potentially with multiple sources (for UST anyway), each potentially with multiple channels, each potentially with multiple CPU IDs) based on timestamps (babeltrace/lib/iterator.c's stream_compare). This works fine, but what about the case where two events have strictly the same timestamp? Within a single host, this can only happen if they have different CPU IDs. It can also happen when merging traces from different hosts. As it currently stands, stream_compare looks at the timestamps only, so the ordering in the aforementioned cases is undefined (left to the luck of the heap sort). I think stream_compare needs to also check for (s_a->parent.real_timestamp == s_b->parent.real_timestamp) and, in that case only, compare hosts (alphabetical ordering is as good as any), then CPU IDs (numerical ordering). Obviously, this is a potentially expensive change since this function is called awfully often when babeltracing or lttngtopping large traces, so maybe the extra tests could be controlled by a command option (called --strict-ordering, say). Or is this so rare it's not worth bothering with? In which case a small cautionary note in babeltrace's man pages would be enough (those man pages really ought to state that babeltrace's output is time-ordered; right now they don't mention this at all). Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC? G3J 1X5 CANADA Vox?: (418) 844-4000 x4245 Fax?: (418) 844-4538 NAC?: 918V QSDJ Gouvernement du Canada?/ Government of Canada From jdesfossez at efficios.com Thu Mar 7 12:46:22 2013 From: jdesfossez at efficios.com (Julien Desfossez) Date: Thu, 7 Mar 2013 12:46:22 -0500 Subject: [lttng-dev] [LTTNG-TOOLS PATCH] On-disk multiple tracefiles circular buffer Message-ID: <1362678382-11138-1-git-send-email-jdesfossez@efficios.com> This patch introduces the tracefile_size and tracefile_count parameters to the enable-channel command and the API. This allows to split a stream into multiple tracefiles and limit the amount of trace data to keep on disk. The tracefiles are readable independently or with the others as long as the metadata file is present. For now only local traces are handled, relayd modifications coming soon. Signed-off-by: Julien Desfossez --- include/lttng/lttng.h | 7 +- src/bin/lttng-sessiond/channel.c | 10 ++ src/bin/lttng-sessiond/consumer.c | 18 +++- src/bin/lttng-sessiond/consumer.h | 12 ++- src/bin/lttng-sessiond/kernel-consumer.c | 14 ++- src/bin/lttng-sessiond/kernel.c | 3 + src/bin/lttng-sessiond/trace-kernel.h | 2 + src/bin/lttng-sessiond/trace-ust.c | 4 + src/bin/lttng-sessiond/trace-ust.h | 2 + src/bin/lttng-sessiond/ust-app.c | 3 + src/bin/lttng-sessiond/ust-app.h | 2 + src/bin/lttng-sessiond/ust-consumer.c | 4 +- src/bin/lttng/commands/enable_channels.c | 31 ++++++ src/common/consumer.c | 140 +++++++++++++++++++++++++- src/common/consumer.h | 21 +++- src/common/defaults.h | 8 ++ src/common/kernel-consumer/kernel-consumer.c | 25 ++--- src/common/sessiond-comm/sessiond-comm.h | 6 ++ src/common/ust-consumer/ust-consumer.c | 44 ++------ src/lib/lttng-ctl/lttng-ctl.c | 4 + 20 files changed, 294 insertions(+), 66 deletions(-) diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index 6077047..24c17c7 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -269,7 +269,9 @@ struct lttng_event_field { * * The structures should be initialized to zero before use. */ -#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 +#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 \ + - 8 /* tracefile_size */ \ + - 8 /* tracefile_count */ struct lttng_channel_attr { int overwrite; /* 1: overwrite, 0: discard */ uint64_t subbuf_size; /* bytes */ @@ -277,6 +279,9 @@ struct lttng_channel_attr { unsigned int switch_timer_interval; /* usec */ unsigned int read_timer_interval; /* usec */ enum lttng_event_output output; /* splice, mmap */ + /* LTTng 2.0 padding limit */ + uint64_t tracefile_size; /* bytes */ + uint64_t tracefile_count; /* number of tracefiles */ char padding[LTTNG_CHANNEL_ATTR_PADDING1]; }; diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index 7ebe4b1..a5beb24 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -282,6 +282,16 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain, goto error; } + /* + * The tracefile_size should not be < to the subbuf_size, otherwise + * we won't be able to write the packets on disk + */ + if ((attr->attr.tracefile_size > 0) && + (attr->attr.tracefile_size < attr->attr.subbuf_size)) { + ret = LTTNG_ERR_INVALID; + goto error; + } + /* Create UST channel */ uchan = trace_ust_create_channel(attr, usess->pathname); if (uchan == NULL) { diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 92abcf2..1973059 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -625,7 +625,9 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, gid_t gid, uint64_t relayd_id, uint64_t key, - unsigned char *uuid) + unsigned char *uuid, + uint64_t tracefile_size, + uint64_t tracefile_count) { assert(msg); @@ -645,6 +647,8 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.ask_channel.gid = gid; msg->u.ask_channel.relayd_id = relayd_id; msg->u.ask_channel.key = key; + msg->u.ask_channel.tracefile_size = tracefile_size; + msg->u.ask_channel.tracefile_count = tracefile_count; memcpy(msg->u.ask_channel.uuid, uuid, sizeof(msg->u.ask_channel.uuid)); @@ -670,7 +674,9 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, const char *name, unsigned int nb_init_streams, enum lttng_event_output output, - int type) + int type, + uint64_t tracefile_size, + uint64_t tracefile_count) { assert(msg); @@ -687,6 +693,8 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.channel.nb_init_streams = nb_init_streams; msg->u.channel.output = output; msg->u.channel.type = type; + msg->u.channel.tracefile_size = tracefile_size; + msg->u.channel.tracefile_count = tracefile_count; strncpy(msg->u.channel.pathname, pathname, sizeof(msg->u.channel.pathname)); @@ -703,7 +711,9 @@ void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg, enum lttng_consumer_command cmd, uint64_t channel_key, uint64_t stream_key, - int cpu) + int cpu, + uint64_t tracefile_size, + uint64_t tracefile_count) { assert(msg); @@ -713,6 +723,8 @@ void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.stream.channel_key = channel_key; msg->u.stream.stream_key = stream_key; msg->u.stream.cpu = cpu; + msg->u.stream.tracefile_size = tracefile_size; + msg->u.stream.tracefile_count = tracefile_count; } /* diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index 3616d46..864a45b 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -197,12 +197,16 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, gid_t gid, uint64_t relayd_id, uint64_t key, - unsigned char *uuid); + unsigned char *uuid, + uint64_t tracefile_size, + uint64_t tracefile_count); void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg, enum lttng_consumer_command cmd, uint64_t channel_key, uint64_t stream_key, - int cpu); + int cpu, + uint64_t tracefile_size, + uint64_t tracefile_count); void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, enum lttng_consumer_command cmd, uint64_t channel_key, @@ -214,7 +218,9 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, const char *name, unsigned int nb_init_streams, enum lttng_event_output output, - int type); + int type, + uint64_t tracefile_size, + uint64_t tracefile_count); int consumer_is_data_pending(uint64_t session_id, struct consumer_output *consumer); diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 837afdc..1b17380 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -93,7 +93,9 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, channel->channel->name, channel->stream_count, channel->channel->attr.output, - CONSUMER_CHANNEL_TYPE_DATA); + CONSUMER_CHANNEL_TYPE_DATA, + channel->channel->attr.tracefile_size, + channel->channel->attr.tracefile_count); health_code_update(); @@ -173,7 +175,8 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, DEFAULT_METADATA_NAME, 1, DEFAULT_KERNEL_CHANNEL_OUTPUT, - CONSUMER_CHANNEL_TYPE_METADATA); + CONSUMER_CHANNEL_TYPE_METADATA, + 0, 0); health_code_update(); @@ -189,7 +192,8 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, LTTNG_CONSUMER_ADD_STREAM, session->metadata->fd, session->metadata_stream_fd, - 0); /* CPU: 0 for metadata. */ + 0, /* CPU: 0 for metadata. */ + 0, 0); /* don't split metadata */ health_code_update(); @@ -234,7 +238,9 @@ int kernel_consumer_add_stream(struct consumer_socket *sock, LTTNG_CONSUMER_ADD_STREAM, channel->fd, stream->fd, - stream->cpu); + stream->cpu, + stream->tracefile_size, + stream->tracefile_count); health_code_update(); diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index d3a6453..9519411 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -536,6 +536,9 @@ int kernel_open_channel_stream(struct ltt_kernel_channel *channel) PERROR("fcntl session fd"); } + lks->tracefile_size = channel->channel->attr.tracefile_size; + lks->tracefile_count = channel->channel->attr.tracefile_count; + /* Add stream to channe stream list */ cds_list_add(&lks->list, &channel->stream_list.head); channel->stream_count++; diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index 66ca8db..87807d9 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -82,6 +82,8 @@ struct ltt_kernel_stream { int cpu; /* Format is %s_%d respectively channel name and CPU number. */ char name[DEFAULT_STREAM_NAME_LEN]; + uint64_t tracefile_size; + uint64_t tracefile_count; struct cds_list_head list; }; diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 5e06a84..6278ede 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -302,6 +302,10 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, goto error_free_channel; } + /* On-disk circular buffer parameters */ + luc->tracefile_size = chan->attr.tracefile_size; + luc->tracefile_count = chan->attr.tracefile_count; + DBG2("Trace UST channel %s created", luc->name); return luc; diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index f5fa092..f8eb08f 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -58,6 +58,8 @@ struct ltt_ust_channel { struct lttng_ht *ctx; struct lttng_ht *events; struct lttng_ht_node_str node; + uint64_t tracefile_size; + uint64_t tracefile_count; }; /* UST Metadata */ diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 7288763..a708714 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1288,6 +1288,9 @@ static void shadow_copy_channel(struct ust_app_channel *ua_chan, strncpy(ua_chan->name, uchan->name, sizeof(ua_chan->name)); ua_chan->name[sizeof(ua_chan->name) - 1] = '\0'; + ua_chan->tracefile_size = uchan->tracefile_size; + ua_chan->tracefile_count = uchan->tracefile_count; + /* Copy event attributes since the layout is different. */ ua_chan->attr.subbuf_size = uchan->attr.subbuf_size; ua_chan->attr.num_subbuf = uchan->attr.num_subbuf; diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index c6294d0..2b1db3b 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -141,6 +141,8 @@ struct ust_app_channel { struct ust_app_session *session; struct lttng_ht *ctx; struct lttng_ht *events; + uint64_t tracefile_size; + uint64_t tracefile_count; /* * UST event registry. The ONLY writer is the application thread. */ diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 33cb6ff..b49ddbd 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -133,7 +133,9 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, ua_sess->gid, consumer->net_seq_index, ua_chan->key, - ua_sess->registry.uuid); + ua_sess->registry.uuid, + ua_chan->tracefile_size, + ua_chan->tracefile_count); health_code_update(); diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c index d9a3b02..f700b62 100644 --- a/src/bin/lttng/commands/enable_channels.c +++ b/src/bin/lttng/commands/enable_channels.c @@ -51,6 +51,8 @@ enum { OPT_READ_TIMER, OPT_USERSPACE, OPT_LIST_OPTIONS, + OPT_TRACEFILE_SIZE, + OPT_TRACEFILE_COUNT, }; static struct lttng_handle *handle; @@ -78,6 +80,8 @@ static struct poptOption long_options[] = { {"read-timer", 0, POPT_ARG_INT, 0, OPT_READ_TIMER, 0, 0}, {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, {"output", 0, POPT_ARG_STRING, &opt_output, 0, 0, 0}, + {"tracefile_size", 'C', POPT_ARG_INT, 0, OPT_TRACEFILE_SIZE, 0, 0}, + {"tracefile_count", 'W', POPT_ARG_INT, 0, OPT_TRACEFILE_COUNT, 0, 0}, {0, 0, 0, 0, 0, 0, 0} }; @@ -117,6 +121,8 @@ static void usage(FILE *ofp) DEFAULT_CHANNEL_READ_TIMER); fprintf(ofp, " --output TYPE Channel output type (Values: %s, %s)\n", output_mmap, output_splice); + fprintf(ofp, " -C, --tracefile-size NUM Maximum size of tracefiles (in bytes)\n"); + fprintf(ofp, " -W, --tracefile-count NUM Number of tracefiles to keep\n"); fprintf(ofp, "\n"); } @@ -149,6 +155,12 @@ static void set_default_attr(struct lttng_domain *dom) if (chan.attr.output == -1) { chan.attr.output = default_attr.output; } + if (chan.attr.tracefile_count == -1) { + chan.attr.tracefile_count = default_attr.tracefile_count; + } + if (chan.attr.tracefile_size == -1) { + chan.attr.tracefile_size = default_attr.tracefile_size; + } } /* @@ -175,6 +187,15 @@ static int enable_channel(char *session_name) set_default_attr(&dom); + if ((chan.attr.tracefile_size > 0) && + (chan.attr.tracefile_size < chan.attr.subbuf_size)) { + ERR("Tracefile_size must be superior or equal to subbuf_size " + "(%" PRIu64 " < %" PRIu64 ")", + chan.attr.tracefile_size, chan.attr.subbuf_size); + ret = CMD_ERROR; + goto error; + } + /* Setting channel output */ if (opt_output) { if (!strncmp(output_mmap, opt_output, strlen(output_mmap))) { @@ -303,6 +324,16 @@ int cmd_enable_channels(int argc, const char **argv) case OPT_USERSPACE: opt_userspace = 1; break; + case OPT_TRACEFILE_SIZE: + chan.attr.tracefile_size = atoll(poptGetOptArg(pc)); + DBG("Maximum tracefile size set to %" PRIu64, + chan.attr.tracefile_size); + break; + case OPT_TRACEFILE_COUNT: + chan.attr.tracefile_count = atoll(poptGetOptArg(pc)); + DBG("Maximum tracefile count set to %" PRIu64, + chan.attr.tracefile_count); + break; case OPT_LIST_OPTIONS: list_cmd_options(stdout, long_options); goto end; diff --git a/src/common/consumer.c b/src/common/consumer.c index 25f891a..0c316af 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -500,7 +500,9 @@ struct lttng_consumer_stream *consumer_allocate_stream(uint64_t channel_key, uint64_t session_id, int cpu, int *alloc_ret, - enum consumer_channel_type type) + enum consumer_channel_type type, + uint64_t tracefile_size, + uint64_t tracefile_count) { int ret; struct lttng_consumer_stream *stream; @@ -522,6 +524,8 @@ struct lttng_consumer_stream *consumer_allocate_stream(uint64_t channel_key, stream->gid = gid; stream->net_seq_idx = relayd_id; stream->session_id = session_id; + stream->tracefile_size = tracefile_size; + stream->tracefile_count = tracefile_count; pthread_mutex_init(&stream->lock, NULL); /* If channel is the metadata, flag this stream as metadata. */ @@ -777,7 +781,9 @@ struct lttng_consumer_channel *consumer_allocate_channel(unsigned long key, uid_t uid, gid_t gid, int relayd_id, - enum lttng_event_output output) + enum lttng_event_output output, + uint64_t tracefile_size, + uint64_t tracefile_count) { struct lttng_consumer_channel *channel; @@ -794,6 +800,8 @@ struct lttng_consumer_channel *consumer_allocate_channel(unsigned long key, channel->gid = gid; channel->relayd_id = relayd_id; channel->output = output; + channel->tracefile_size = tracefile_size; + channel->tracefile_count = tracefile_count; strncpy(channel->pathname, pathname, sizeof(channel->pathname)); channel->pathname[sizeof(channel->pathname) - 1] = '\0'; @@ -1240,6 +1248,102 @@ end: } /* + * Create the tracefile on disk + */ +int lttng_create_output_file(struct lttng_consumer_stream *stream) +{ + int ret; + char full_path[PATH_MAX]; + char *path_name_id = NULL; + char *path; + + assert(stream); + + ret = snprintf(full_path, sizeof(full_path), "%s/%s", + stream->chan->pathname, stream->name); + if (ret < 0) { + PERROR("snprintf on_recv_stream"); + goto error; + } + + /* Opening the tracefile in write mode */ + if (stream->net_seq_idx == (uint64_t) -1ULL) { + /* + * if we split the trace in multiple files, we have to add + * the tracefile current count at the end of the tracefile + * name + */ + if (stream->tracefile_size > 0) { + ret = asprintf(&path_name_id, "%s_%" PRIu64, full_path, + stream->tracefile_current_count); + if (ret < 0) { + PERROR("Allocating path name ID"); + goto error; + } + path = path_name_id; + } else { + path = full_path; + } + + ret = run_as_open(path, O_WRONLY | O_CREAT | O_TRUNC, + S_IRWXU|S_IRWXG|S_IRWXO, stream->uid, stream->gid); + if (ret < 0) { + PERROR("open kernel stream path %s", full_path); + goto error_free; + } + stream->out_fd = ret; + stream->tracefile_current_size = 0; + if (path_name_id) { + free(path_name_id); + path_name_id = NULL; + } + } + +error_free: + if (path_name_id) { + free(path_name_id); + } +error: + return ret; +} + +/* + * Change the output tracefile according to the tracefile_size and + * tracefile_count parameters. + * stream->lock must be held before calling this function because + * we are modifying the stream status. + */ +static int rotate_output_file(struct lttng_consumer_stream *stream) +{ + int ret; + + ret = close(stream->out_fd); + if (ret < 0) { + PERROR("Closing tracefile"); + goto end; + } + + /* safety : should not happen with args validation */ + if (stream->tracefile_current_size == 0) { + ERR("Tracefile size too small, rotating without writing in it"); + ret = -1; + goto end; + } + + if (stream->tracefile_count > 0) { + stream->tracefile_current_count = + (stream->tracefile_current_count + 1) % stream->tracefile_count; + } else { + stream->tracefile_current_count++; + } + + return lttng_create_output_file(stream); + +end: + return ret; +} + +/* * Mmap the ring buffer, read it and write the data to the tracefile. This is a * core function for writing trace buffers to either the local filesystem or * the network. @@ -1345,6 +1449,22 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap( } else { /* No streaming, we have to set the len with the full padding */ len += padding; + + /* + * check if we need to change the tracefile before writing + * the packet + */ + if (stream->tracefile_size > 0 && + (stream->tracefile_current_size + len) > + stream->tracefile_size) { + ret = rotate_output_file(stream); + if (ret < 0) { + ERR("Rotating output file"); + goto end; + } + outfd = stream->out_fd; + } + stream->tracefile_current_size += len; } while (len > 0) { @@ -1507,6 +1627,22 @@ ssize_t lttng_consumer_on_read_subbuffer_splice( } else { /* No streaming, we have to set the len with the full padding */ len += padding; + + /* + * check if we need to change the tracefile before writing + * the packet + */ + if (stream->tracefile_size > 0 && + (stream->tracefile_current_size + len) > + stream->tracefile_size) { + ret = rotate_output_file(stream); + if (ret < 0) { + ERR("Rotating output file"); + goto end; + } + outfd = stream->out_fd; + } + stream->tracefile_current_size += len; } while (len > 0) { diff --git a/src/common/consumer.h b/src/common/consumer.h index a3e1ec3..867c5ef 100644 --- a/src/common/consumer.h +++ b/src/common/consumer.h @@ -136,6 +136,12 @@ struct lttng_consumer_channel { * contiguousness and order. */ uint64_t contig_metadata_written; + + /* + * On-disk circular buffer + */ + uint64_t tracefile_size; + uint64_t tracefile_count; }; /* @@ -221,6 +227,12 @@ struct lttng_consumer_stream { /* Internal state of libustctl. */ struct ustctl_consumer_stream *ustream; struct cds_list_head send_node; + + /* On-disk circular buffer */ + uint64_t tracefile_size; + uint64_t tracefile_count; + uint64_t tracefile_current_size; + uint64_t tracefile_current_count; }; /* @@ -431,7 +443,9 @@ struct lttng_consumer_stream *consumer_allocate_stream(uint64_t channel_key, uint64_t session_id, int cpu, int *alloc_ret, - enum consumer_channel_type type); + enum consumer_channel_type type, + uint64_t tracefile_size, + uint64_t tracefile_count); struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, uint64_t session_id, const char *pathname, @@ -439,7 +453,9 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, uid_t uid, gid_t gid, int relayd_id, - enum lttng_event_output output); + enum lttng_event_output output, + uint64_t tracefile_size, + uint64_t tracefile_count); void consumer_del_stream(struct lttng_consumer_stream *stream, struct lttng_ht *ht); void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, @@ -464,6 +480,7 @@ struct lttng_consumer_local_data *lttng_consumer_create( int (*recv_stream)(struct lttng_consumer_stream *stream), int (*update_stream)(int sessiond_key, uint32_t state)); void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx); +int lttng_create_output_file(struct lttng_consumer_stream *stream); ssize_t lttng_consumer_on_read_subbuffer_mmap( struct lttng_consumer_local_data *ctx, struct lttng_consumer_stream *stream, unsigned long len, diff --git a/src/common/defaults.h b/src/common/defaults.h index 83159d7..8a07ba0 100644 --- a/src/common/defaults.h +++ b/src/common/defaults.h @@ -138,6 +138,10 @@ #define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM DEFAULT_CHANNEL_SUBBUF_NUM /* See lttng-kernel.h enum lttng_kernel_output for channel output */ #define DEFAULT_KERNEL_CHANNEL_OUTPUT LTTNG_EVENT_SPLICE +/* By default, unlimited tracefile size */ +#define DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE 0 +/* By default, unlimited tracefile count */ +#define DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT 0 /* User space defaults */ @@ -147,6 +151,10 @@ #define DEFAULT_UST_CHANNEL_SUBBUF_NUM DEFAULT_CHANNEL_SUBBUF_NUM /* See lttng-ust.h enum lttng_ust_output */ #define DEFAULT_UST_CHANNEL_OUTPUT LTTNG_EVENT_MMAP +/* By default, unlimited tracefile size */ +#define DEFAULT_UST_CHANNEL_TRACEFILE_SIZE 0 +/* By default, unlimited tracefile count */ +#define DEFAULT_UST_CHANNEL_TRACEFILE_COUNT 0 /* * Default timeout value for the sem_timedwait() call. Blocking forever is not diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index ca1e98b..7ab1bf0 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -132,7 +132,9 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, new_channel = consumer_allocate_channel(msg.u.channel.channel_key, msg.u.channel.session_id, msg.u.channel.pathname, msg.u.channel.name, msg.u.channel.uid, msg.u.channel.gid, - msg.u.channel.relayd_id, msg.u.channel.output); + msg.u.channel.relayd_id, msg.u.channel.output, + msg.u.channel.tracefile_size, + msg.u.channel.tracefile_count); if (new_channel == NULL) { lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); goto end_nosignal; @@ -229,7 +231,9 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, channel->session_id, msg.u.stream.cpu, &alloc_ret, - channel->type); + channel->type, + channel->tracefile_size, + channel->tracefile_count); if (new_stream == NULL) { switch (alloc_ret) { case -ENOMEM: @@ -501,28 +505,15 @@ end: int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream) { int ret; - char full_path[PATH_MAX]; assert(stream); - ret = snprintf(full_path, sizeof(full_path), "%s/%s", - stream->chan->pathname, stream->name); + ret = lttng_create_output_file(stream); if (ret < 0) { - PERROR("snprintf on_recv_stream"); + ERR("Creating output file"); goto error; } - /* Opening the tracefile in write mode */ - if (stream->net_seq_idx == (uint64_t) -1ULL) { - ret = run_as_open(full_path, O_WRONLY | O_CREAT | O_TRUNC, - S_IRWXU|S_IRWXG|S_IRWXO, stream->uid, stream->gid); - if (ret < 0) { - PERROR("open kernel stream path %s", full_path); - goto error; - } - stream->out_fd = ret; - } - if (stream->output == LTTNG_EVENT_MMAP) { /* get the len of the mmap region */ unsigned long mmap_len; diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 60a3ead..871027c 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -273,10 +273,14 @@ struct lttcomm_consumer_msg { /* Use splice or mmap to consume this fd */ enum lttng_event_output output; int type; /* Per cpu or metadata. */ + uint64_t tracefile_size; /* bytes */ + uint64_t tracefile_count; /* number of tracefiles */ } LTTNG_PACKED channel; /* Only used by Kernel. */ struct { uint64_t stream_key; uint64_t channel_key; + uint64_t tracefile_size; /* bytes */ + uint64_t tracefile_count; /* number of tracefiles */ int32_t cpu; /* On which CPU this stream is assigned. */ } LTTNG_PACKED stream; /* Only used by Kernel. */ struct { @@ -309,6 +313,8 @@ struct lttcomm_consumer_msg { uint64_t relayd_id; /* Relayd id if apply. */ uint64_t key; /* Unique channel key. */ unsigned char uuid[UUID_STR_LEN]; /* uuid for ust tracer. */ + uint64_t tracefile_size; /* bytes */ + uint64_t tracefile_count; /* number of tracefiles */ } LTTNG_PACKED ask_channel; struct { uint64_t key; diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 5d9dc96..41fd49b 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -109,13 +109,14 @@ error: */ static struct lttng_consumer_channel *allocate_channel(uint64_t session_id, const char *pathname, const char *name, uid_t uid, gid_t gid, - int relayd_id, uint64_t key, enum lttng_event_output output) + int relayd_id, uint64_t key, enum lttng_event_output output, + uint64_t tracefile_size, uint64_t tracefile_count) { assert(pathname); assert(name); return consumer_allocate_channel(key, session_id, pathname, name, uid, gid, - relayd_id, output); + relayd_id, output, tracefile_size, tracefile_count); } /* @@ -144,7 +145,8 @@ static struct lttng_consumer_stream *allocate_stream(int cpu, int key, channel->session_id, cpu, &alloc_ret, - channel->type); + channel->type, + 0, 0); if (stream == NULL) { switch (alloc_ret) { case -ENOENT: @@ -264,6 +266,8 @@ static int create_ust_streams(struct lttng_consumer_channel *channel, goto error_alloc; } stream->ustream = ustream; + stream->tracefile_size = channel->tracefile_size; + stream->tracefile_count = channel->tracefile_count; /* * Store it so we can save multiple function calls afterwards since * this value is used heavily in the stream threads. This is UST @@ -750,7 +754,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, msg.u.ask_channel.pathname, msg.u.ask_channel.name, msg.u.ask_channel.uid, msg.u.ask_channel.gid, msg.u.ask_channel.relayd_id, msg.u.ask_channel.key, - (enum lttng_event_output) msg.u.ask_channel.output); + (enum lttng_event_output) msg.u.ask_channel.output, + msg.u.ask_channel.tracefile_size, + msg.u.ask_channel.tracefile_count); if (!channel) { goto end_channel_error; } @@ -1176,35 +1182,7 @@ end: */ int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream) { - int ret; - char full_path[PATH_MAX]; - - /* Opening the tracefile in write mode */ - if (stream->net_seq_idx != (uint64_t) -1ULL) { - goto end; - } - - ret = snprintf(full_path, sizeof(full_path), "%s/%s", - stream->chan->pathname, stream->name); - if (ret < 0) { - PERROR("snprintf on_recv_stream"); - goto error; - } - - ret = run_as_open(full_path, O_WRONLY | O_CREAT | O_TRUNC, - S_IRWXU | S_IRWXG | S_IRWXO, stream->uid, stream->gid); - if (ret < 0) { - PERROR("open stream path %s", full_path); - goto error; - } - stream->out_fd = ret; - -end: - /* we return 0 to let the library handle the FD internally */ - return 0; - -error: - return ret; + return lttng_create_output_file(stream); } /* diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 8f63bf3..f2a6107 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -1360,6 +1360,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, attr->subbuf_size = default_get_kernel_channel_subbuf_size(); attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM; attr->output = DEFAULT_KERNEL_CHANNEL_OUTPUT; + attr->tracefile_size = DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE; + attr->tracefile_count = DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT; break; case LTTNG_DOMAIN_UST: #if 0 @@ -1374,6 +1376,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, attr->subbuf_size = default_get_ust_channel_subbuf_size(); attr->num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM; attr->output = DEFAULT_UST_CHANNEL_OUTPUT; + attr->tracefile_size = DEFAULT_UST_CHANNEL_TRACEFILE_SIZE; + attr->tracefile_count = DEFAULT_UST_CHANNEL_TRACEFILE_COUNT; break; default: /* Default behavior: leave set to 0. */ -- 1.7.10.4 From Daniel.Thibault at drdc-rddc.gc.ca Fri Mar 8 09:34:31 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Fri, 8 Mar 2013 14:34:31 +0000 Subject: [lttng-dev] [LTTNG-TOOLS PATCH] On-disk multiple tracefiles circular buffer Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD026557@VAL-E-01.valcartier.drdc-rddc.gc.ca> > @@ -78,6 +80,8 @@ static struct poptOption long_options[] = { > {"read-timer", 0, POPT_ARG_INT, 0, OPT_READ_TIMER, 0, 0}, > {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, > {"output", 0, POPT_ARG_STRING, &opt_output, 0, 0, 0}, > + {"tracefile_size", 'C', POPT_ARG_INT, 0, OPT_TRACEFILE_SIZE, 0, 0}, > + {"tracefile_count", 'W', POPT_ARG_INT, 0, OPT_TRACEFILE_COUNT, 0, 0}, > {0, 0, 0, 0, 0, 0, 0} > }; > > @@ -117,6 +121,8 @@ static void usage(FILE *ofp) > DEFAULT_CHANNEL_READ_TIMER); > fprintf(ofp, " --output TYPE Channel output type (Values: %s, %s)\n", > output_mmap, output_splice); > + fprintf(ofp, " -C, --tracefile-size NUM Maximum size of tracefiles (in bytes)\n"); > + fprintf(ofp, " -W, --tracefile-count NUM Number of tracefiles to keep\n"); > fprintf(ofp, "\n"); > } You've got the command options parsed as "tracefile_size" but documented as "tracefile-size" (likewise for _count/-count). The latter is preferable for consistency with the rest of the user interface. > @@ -175,6 +187,15 @@ static int enable_channel(char *session_name) > > set_default_attr(&dom); > > + if ((chan.attr.tracefile_size > 0) && > + (chan.attr.tracefile_size < chan.attr.subbuf_size)) { > + ERR("Tracefile_size must be superior or equal to subbuf_size " > + "(%" PRIu64 " < %" PRIu64 ")", > + chan.attr.tracefile_size, chan.attr.subbuf_size); > + ret = CMD_ERROR; > + goto error; > + } That should be ERR("The tracefile-size must be superior or equal to the subbuf-size ". I hope the man pages will make clear how these two new command options work, as the initial presentation of tracefile-size as the "Maximum size of tracefiles (in bytes)" and tracefile-count as the "Number of tracefiles to keep" can be understood quite wrongly. It can be misconstrued to mean each trace file is limited in size (so only the first SIZE bytes are captured, the rest is thrown away), or that the limitation applies to the *set* of trace files (maximum total size of trace files, the sum being over all CPU IDs for that channel). The chunking mechanism should also explain its circularity, as a user could initially expect the trace file chunk numbering to be open-ended, the excess files (assuming tracefile-count is set) being deleted from the low-number end (e.g. a tracefile-count of two could be expected to yield, once the trace is concluded, the files "channel0_0_23" and "channel0_0_24"). Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC G3J 1X5 CANADA Vox : (418) 844-4000 x4245 Fax : (418) 844-4538 [Valcartier]\\vsi-wdut-o980, [Valcartier]\\edge NAC : 918V QSDJ Gouvernement du Canada / Government of Canada From mathieu.desnoyers at efficios.com Fri Mar 8 11:17:56 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Fri, 8 Mar 2013 11:17:56 -0500 Subject: [lttng-dev] [LTTNG-TOOLS PATCH] On-disk multiple tracefiles circular buffer In-Reply-To: <1362678382-11138-1-git-send-email-jdesfossez@efficios.com> References: <1362678382-11138-1-git-send-email-jdesfossez@efficios.com> Message-ID: <20130308161756.GA5037@Krystal> * Julien Desfossez (jdesfossez at efficios.com) wrote: > This patch introduces the tracefile_size and tracefile_count parameters > to the enable-channel command and the API. I having similar questions as Daniel about tracefile-size and tracefile-count. for each stream, do we have max size used on disk = size * count or size used = size ? If there is a doubt about the semantic, maybe using clearer terms that don't need to be explained might help. I guess the confusion here is: what is a tracefile exactly ? The notion of "stream" is much clearer than "tracefile" in the CTF spec, so we might want to consider: --stream-chunks-num NUM: each stream, on disk, is divided in at most NUM chunks (one file per chunk). When the maximum number of chunks is reached, oldest chunks are deleted for this stream, thus creating a flight recorder on disk. --stream-chunks-size SIZE: chunk size. Must be a multiple of subbuf-size. Default value: subbuffer size. > This allows to split a stream into multiple tracefiles and limit the > amount of trace data to keep on disk. > The tracefiles are readable independently or with the others as long as > the metadata file is present. > > For now only local traces are handled, relayd modifications coming soon. > > Signed-off-by: Julien Desfossez > --- > include/lttng/lttng.h | 7 +- > src/bin/lttng-sessiond/channel.c | 10 ++ > src/bin/lttng-sessiond/consumer.c | 18 +++- > src/bin/lttng-sessiond/consumer.h | 12 ++- > src/bin/lttng-sessiond/kernel-consumer.c | 14 ++- > src/bin/lttng-sessiond/kernel.c | 3 + > src/bin/lttng-sessiond/trace-kernel.h | 2 + > src/bin/lttng-sessiond/trace-ust.c | 4 + > src/bin/lttng-sessiond/trace-ust.h | 2 + > src/bin/lttng-sessiond/ust-app.c | 3 + > src/bin/lttng-sessiond/ust-app.h | 2 + > src/bin/lttng-sessiond/ust-consumer.c | 4 +- > src/bin/lttng/commands/enable_channels.c | 31 ++++++ > src/common/consumer.c | 140 +++++++++++++++++++++++++- > src/common/consumer.h | 21 +++- > src/common/defaults.h | 8 ++ > src/common/kernel-consumer/kernel-consumer.c | 25 ++--- > src/common/sessiond-comm/sessiond-comm.h | 6 ++ > src/common/ust-consumer/ust-consumer.c | 44 ++------ > src/lib/lttng-ctl/lttng-ctl.c | 4 + > 20 files changed, 294 insertions(+), 66 deletions(-) > > diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h > index 6077047..24c17c7 100644 > --- a/include/lttng/lttng.h > +++ b/include/lttng/lttng.h > @@ -269,7 +269,9 @@ struct lttng_event_field { > * > * The structures should be initialized to zero before use. > */ > -#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 > +#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 \ > + - 8 /* tracefile_size */ \ > + - 8 /* tracefile_count */ > struct lttng_channel_attr { > int overwrite; /* 1: overwrite, 0: discard */ > uint64_t subbuf_size; /* bytes */ > @@ -277,6 +279,9 @@ struct lttng_channel_attr { > unsigned int switch_timer_interval; /* usec */ > unsigned int read_timer_interval; /* usec */ > enum lttng_event_output output; /* splice, mmap */ > + /* LTTng 2.0 padding limit */ > + uint64_t tracefile_size; /* bytes */ > + uint64_t tracefile_count; /* number of tracefiles */ We'll have padding problems between the enum and uint64_t. Sadly lttng_channel_attr is not packed. We should ensure the first uint64_t is on a 64-bit alignment within the structure. If necessary, we might need to add a dummy field before the first uint64_t. Failure to ensure this could cause new liblttng-ctl to write zeros beyond the size allocated by applications. > > char padding[LTTNG_CHANNEL_ATTR_PADDING1]; > }; > diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c > index 7ebe4b1..a5beb24 100644 > --- a/src/bin/lttng-sessiond/channel.c > +++ b/src/bin/lttng-sessiond/channel.c > @@ -282,6 +282,16 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain, > goto error; > } > > + /* > + * The tracefile_size should not be < to the subbuf_size, otherwise > + * we won't be able to write the packets on disk > + */ > + if ((attr->attr.tracefile_size > 0) && > + (attr->attr.tracefile_size < attr->attr.subbuf_size)) { Actually, you might want to consider that the stream-chunk-size need to be a multiple of the subbuffer size. The check needs to be more strict. > + ret = LTTNG_ERR_INVALID; > + goto error; > + } > + > /* Create UST channel */ > uchan = trace_ust_create_channel(attr, usess->pathname); > if (uchan == NULL) { > diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c > index 92abcf2..1973059 100644 > --- a/src/bin/lttng-sessiond/consumer.c > +++ b/src/bin/lttng-sessiond/consumer.c > @@ -625,7 +625,9 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, > gid_t gid, > uint64_t relayd_id, > uint64_t key, > - unsigned char *uuid) > + unsigned char *uuid, > + uint64_t tracefile_size, > + uint64_t tracefile_count) > { > assert(msg); > > @@ -645,6 +647,8 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, > msg->u.ask_channel.gid = gid; > msg->u.ask_channel.relayd_id = relayd_id; > msg->u.ask_channel.key = key; > + msg->u.ask_channel.tracefile_size = tracefile_size; > + msg->u.ask_channel.tracefile_count = tracefile_count; > > memcpy(msg->u.ask_channel.uuid, uuid, sizeof(msg->u.ask_channel.uuid)); > > @@ -670,7 +674,9 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, > const char *name, > unsigned int nb_init_streams, > enum lttng_event_output output, > - int type) > + int type, > + uint64_t tracefile_size, > + uint64_t tracefile_count) > { > assert(msg); > > @@ -687,6 +693,8 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, > msg->u.channel.nb_init_streams = nb_init_streams; > msg->u.channel.output = output; > msg->u.channel.type = type; > + msg->u.channel.tracefile_size = tracefile_size; > + msg->u.channel.tracefile_count = tracefile_count; > > strncpy(msg->u.channel.pathname, pathname, > sizeof(msg->u.channel.pathname)); > @@ -703,7 +711,9 @@ void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg, > enum lttng_consumer_command cmd, > uint64_t channel_key, > uint64_t stream_key, > - int cpu) > + int cpu, > + uint64_t tracefile_size, > + uint64_t tracefile_count) > { > assert(msg); > > @@ -713,6 +723,8 @@ void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg, > msg->u.stream.channel_key = channel_key; > msg->u.stream.stream_key = stream_key; > msg->u.stream.cpu = cpu; > + msg->u.stream.tracefile_size = tracefile_size; > + msg->u.stream.tracefile_count = tracefile_count; > } > > /* > diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h > index 3616d46..864a45b 100644 > --- a/src/bin/lttng-sessiond/consumer.h > +++ b/src/bin/lttng-sessiond/consumer.h > @@ -197,12 +197,16 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, > gid_t gid, > uint64_t relayd_id, > uint64_t key, > - unsigned char *uuid); > + unsigned char *uuid, > + uint64_t tracefile_size, > + uint64_t tracefile_count); > void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg, > enum lttng_consumer_command cmd, > uint64_t channel_key, > uint64_t stream_key, > - int cpu); > + int cpu, > + uint64_t tracefile_size, > + uint64_t tracefile_count); > void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, > enum lttng_consumer_command cmd, > uint64_t channel_key, > @@ -214,7 +218,9 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, > const char *name, > unsigned int nb_init_streams, > enum lttng_event_output output, > - int type); > + int type, > + uint64_t tracefile_size, > + uint64_t tracefile_count); > int consumer_is_data_pending(uint64_t session_id, > struct consumer_output *consumer); > > diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c > index 837afdc..1b17380 100644 > --- a/src/bin/lttng-sessiond/kernel-consumer.c > +++ b/src/bin/lttng-sessiond/kernel-consumer.c > @@ -93,7 +93,9 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, > channel->channel->name, > channel->stream_count, > channel->channel->attr.output, > - CONSUMER_CHANNEL_TYPE_DATA); > + CONSUMER_CHANNEL_TYPE_DATA, > + channel->channel->attr.tracefile_size, > + channel->channel->attr.tracefile_count); > > health_code_update(); > > @@ -173,7 +175,8 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, > DEFAULT_METADATA_NAME, > 1, > DEFAULT_KERNEL_CHANNEL_OUTPUT, > - CONSUMER_CHANNEL_TYPE_METADATA); > + CONSUMER_CHANNEL_TYPE_METADATA, > + 0, 0); > > health_code_update(); > > @@ -189,7 +192,8 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, > LTTNG_CONSUMER_ADD_STREAM, > session->metadata->fd, > session->metadata_stream_fd, > - 0); /* CPU: 0 for metadata. */ > + 0, /* CPU: 0 for metadata. */ > + 0, 0); /* don't split metadata */ > > health_code_update(); > > @@ -234,7 +238,9 @@ int kernel_consumer_add_stream(struct consumer_socket *sock, > LTTNG_CONSUMER_ADD_STREAM, > channel->fd, > stream->fd, > - stream->cpu); > + stream->cpu, > + stream->tracefile_size, > + stream->tracefile_count); > > health_code_update(); > > diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c > index d3a6453..9519411 100644 > --- a/src/bin/lttng-sessiond/kernel.c > +++ b/src/bin/lttng-sessiond/kernel.c > @@ -536,6 +536,9 @@ int kernel_open_channel_stream(struct ltt_kernel_channel *channel) > PERROR("fcntl session fd"); > } > > + lks->tracefile_size = channel->channel->attr.tracefile_size; > + lks->tracefile_count = channel->channel->attr.tracefile_count; > + > /* Add stream to channe stream list */ > cds_list_add(&lks->list, &channel->stream_list.head); > channel->stream_count++; > diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h > index 66ca8db..87807d9 100644 > --- a/src/bin/lttng-sessiond/trace-kernel.h > +++ b/src/bin/lttng-sessiond/trace-kernel.h > @@ -82,6 +82,8 @@ struct ltt_kernel_stream { > int cpu; > /* Format is %s_%d respectively channel name and CPU number. */ > char name[DEFAULT_STREAM_NAME_LEN]; > + uint64_t tracefile_size; > + uint64_t tracefile_count; > struct cds_list_head list; > }; > > diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c > index 5e06a84..6278ede 100644 > --- a/src/bin/lttng-sessiond/trace-ust.c > +++ b/src/bin/lttng-sessiond/trace-ust.c > @@ -302,6 +302,10 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, > goto error_free_channel; > } > > + /* On-disk circular buffer parameters */ > + luc->tracefile_size = chan->attr.tracefile_size; > + luc->tracefile_count = chan->attr.tracefile_count; > + > DBG2("Trace UST channel %s created", luc->name); > > return luc; > diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h > index f5fa092..f8eb08f 100644 > --- a/src/bin/lttng-sessiond/trace-ust.h > +++ b/src/bin/lttng-sessiond/trace-ust.h > @@ -58,6 +58,8 @@ struct ltt_ust_channel { > struct lttng_ht *ctx; > struct lttng_ht *events; > struct lttng_ht_node_str node; > + uint64_t tracefile_size; > + uint64_t tracefile_count; > }; > > /* UST Metadata */ > diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c > index 7288763..a708714 100644 > --- a/src/bin/lttng-sessiond/ust-app.c > +++ b/src/bin/lttng-sessiond/ust-app.c > @@ -1288,6 +1288,9 @@ static void shadow_copy_channel(struct ust_app_channel *ua_chan, > strncpy(ua_chan->name, uchan->name, sizeof(ua_chan->name)); > ua_chan->name[sizeof(ua_chan->name) - 1] = '\0'; > > + ua_chan->tracefile_size = uchan->tracefile_size; > + ua_chan->tracefile_count = uchan->tracefile_count; > + > /* Copy event attributes since the layout is different. */ > ua_chan->attr.subbuf_size = uchan->attr.subbuf_size; > ua_chan->attr.num_subbuf = uchan->attr.num_subbuf; > diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h > index c6294d0..2b1db3b 100644 > --- a/src/bin/lttng-sessiond/ust-app.h > +++ b/src/bin/lttng-sessiond/ust-app.h > @@ -141,6 +141,8 @@ struct ust_app_channel { > struct ust_app_session *session; > struct lttng_ht *ctx; > struct lttng_ht *events; > + uint64_t tracefile_size; > + uint64_t tracefile_count; > /* > * UST event registry. The ONLY writer is the application thread. > */ > diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c > index 33cb6ff..b49ddbd 100644 > --- a/src/bin/lttng-sessiond/ust-consumer.c > +++ b/src/bin/lttng-sessiond/ust-consumer.c > @@ -133,7 +133,9 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, > ua_sess->gid, > consumer->net_seq_index, > ua_chan->key, > - ua_sess->registry.uuid); > + ua_sess->registry.uuid, > + ua_chan->tracefile_size, > + ua_chan->tracefile_count); > > health_code_update(); > > diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c > index d9a3b02..f700b62 100644 > --- a/src/bin/lttng/commands/enable_channels.c > +++ b/src/bin/lttng/commands/enable_channels.c > @@ -51,6 +51,8 @@ enum { > OPT_READ_TIMER, > OPT_USERSPACE, > OPT_LIST_OPTIONS, > + OPT_TRACEFILE_SIZE, > + OPT_TRACEFILE_COUNT, > }; > > static struct lttng_handle *handle; > @@ -78,6 +80,8 @@ static struct poptOption long_options[] = { > {"read-timer", 0, POPT_ARG_INT, 0, OPT_READ_TIMER, 0, 0}, > {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, > {"output", 0, POPT_ARG_STRING, &opt_output, 0, 0, 0}, > + {"tracefile_size", 'C', POPT_ARG_INT, 0, OPT_TRACEFILE_SIZE, 0, 0}, > + {"tracefile_count", 'W', POPT_ARG_INT, 0, OPT_TRACEFILE_COUNT, 0, 0}, > {0, 0, 0, 0, 0, 0, 0} > }; > > @@ -117,6 +121,8 @@ static void usage(FILE *ofp) > DEFAULT_CHANNEL_READ_TIMER); > fprintf(ofp, " --output TYPE Channel output type (Values: %s, %s)\n", > output_mmap, output_splice); > + fprintf(ofp, " -C, --tracefile-size NUM Maximum size of tracefiles (in bytes)\n"); > + fprintf(ofp, " -W, --tracefile-count NUM Number of tracefiles to keep\n"); > fprintf(ofp, "\n"); > } > > @@ -149,6 +155,12 @@ static void set_default_attr(struct lttng_domain *dom) > if (chan.attr.output == -1) { > chan.attr.output = default_attr.output; > } > + if (chan.attr.tracefile_count == -1) { > + chan.attr.tracefile_count = default_attr.tracefile_count; > + } > + if (chan.attr.tracefile_size == -1) { > + chan.attr.tracefile_size = default_attr.tracefile_size; > + } > } > > /* > @@ -175,6 +187,15 @@ static int enable_channel(char *session_name) > > set_default_attr(&dom); > > + if ((chan.attr.tracefile_size > 0) && > + (chan.attr.tracefile_size < chan.attr.subbuf_size)) { Same issue about need for checking more strictly. > + ERR("Tracefile_size must be superior or equal to subbuf_size " > + "(%" PRIu64 " < %" PRIu64 ")", > + chan.attr.tracefile_size, chan.attr.subbuf_size); > + ret = CMD_ERROR; > + goto error; > + } > + > /* Setting channel output */ > if (opt_output) { > if (!strncmp(output_mmap, opt_output, strlen(output_mmap))) { > @@ -303,6 +324,16 @@ int cmd_enable_channels(int argc, const char **argv) > case OPT_USERSPACE: > opt_userspace = 1; > break; > + case OPT_TRACEFILE_SIZE: > + chan.attr.tracefile_size = atoll(poptGetOptArg(pc)); > + DBG("Maximum tracefile size set to %" PRIu64, > + chan.attr.tracefile_size); > + break; > + case OPT_TRACEFILE_COUNT: > + chan.attr.tracefile_count = atoll(poptGetOptArg(pc)); > + DBG("Maximum tracefile count set to %" PRIu64, > + chan.attr.tracefile_count); > + break; > case OPT_LIST_OPTIONS: > list_cmd_options(stdout, long_options); > goto end; > diff --git a/src/common/consumer.c b/src/common/consumer.c > index 25f891a..0c316af 100644 > --- a/src/common/consumer.c > +++ b/src/common/consumer.c > @@ -500,7 +500,9 @@ struct lttng_consumer_stream *consumer_allocate_stream(uint64_t channel_key, > uint64_t session_id, > int cpu, > int *alloc_ret, > - enum consumer_channel_type type) > + enum consumer_channel_type type, > + uint64_t tracefile_size, > + uint64_t tracefile_count) > { > int ret; > struct lttng_consumer_stream *stream; > @@ -522,6 +524,8 @@ struct lttng_consumer_stream *consumer_allocate_stream(uint64_t channel_key, > stream->gid = gid; > stream->net_seq_idx = relayd_id; > stream->session_id = session_id; > + stream->tracefile_size = tracefile_size; > + stream->tracefile_count = tracefile_count; > pthread_mutex_init(&stream->lock, NULL); > > /* If channel is the metadata, flag this stream as metadata. */ > @@ -777,7 +781,9 @@ struct lttng_consumer_channel *consumer_allocate_channel(unsigned long key, > uid_t uid, > gid_t gid, > int relayd_id, > - enum lttng_event_output output) > + enum lttng_event_output output, > + uint64_t tracefile_size, > + uint64_t tracefile_count) > { > struct lttng_consumer_channel *channel; > > @@ -794,6 +800,8 @@ struct lttng_consumer_channel *consumer_allocate_channel(unsigned long key, > channel->gid = gid; > channel->relayd_id = relayd_id; > channel->output = output; > + channel->tracefile_size = tracefile_size; > + channel->tracefile_count = tracefile_count; > > strncpy(channel->pathname, pathname, sizeof(channel->pathname)); > channel->pathname[sizeof(channel->pathname) - 1] = '\0'; > @@ -1240,6 +1248,102 @@ end: > } > > /* > + * Create the tracefile on disk > + */ > +int lttng_create_output_file(struct lttng_consumer_stream *stream) > +{ > + int ret; > + char full_path[PATH_MAX]; > + char *path_name_id = NULL; > + char *path; > + > + assert(stream); > + > + ret = snprintf(full_path, sizeof(full_path), "%s/%s", > + stream->chan->pathname, stream->name); > + if (ret < 0) { > + PERROR("snprintf on_recv_stream"); > + goto error; > + } > + > + /* Opening the tracefile in write mode */ > + if (stream->net_seq_idx == (uint64_t) -1ULL) { > + /* > + * if we split the trace in multiple files, we have to add > + * the tracefile current count at the end of the tracefile > + * name > + */ > + if (stream->tracefile_size > 0) { > + ret = asprintf(&path_name_id, "%s_%" PRIu64, full_path, > + stream->tracefile_current_count); > + if (ret < 0) { > + PERROR("Allocating path name ID"); > + goto error; > + } > + path = path_name_id; > + } else { > + path = full_path; > + } > + > + ret = run_as_open(path, O_WRONLY | O_CREAT | O_TRUNC, > + S_IRWXU|S_IRWXG|S_IRWXO, stream->uid, stream->gid); > + if (ret < 0) { > + PERROR("open kernel stream path %s", full_path); > + goto error_free; > + } > + stream->out_fd = ret; > + stream->tracefile_current_size = 0; > + if (path_name_id) { no need for the if() in c99: free() will check for NULL. > + free(path_name_id); > + path_name_id = NULL; This free() is useless. It's done below. > + } > + } > + > +error_free: these are not "error" labels, but rather "end" labels. You reach then through non-error code paths. > + if (path_name_id) { > + free(path_name_id); no need for the if() in c99: free() will check for NULL. > + } > +error: > + return ret; > +} > + > +/* > + * Change the output tracefile according to the tracefile_size and > + * tracefile_count parameters. > + * stream->lock must be held before calling this function because > + * we are modifying the stream status. > + */ > +static int rotate_output_file(struct lttng_consumer_stream *stream) > +{ > + int ret; > + > + ret = close(stream->out_fd); > + if (ret < 0) { > + PERROR("Closing tracefile"); > + goto end; this should be an error label. > + } if close succeeds, it might be better to set out_fd to -1 so we don't end up closing the same fd twice if we reach error path below and after close the FD again when destroying the stream. > + > + /* safety : should not happen with args validation */ > + if (stream->tracefile_current_size == 0) { > + ERR("Tracefile size too small, rotating without writing in it"); > + ret = -1; ret = -EINVAL; > + goto end; this should be an error label. > + } > + > + if (stream->tracefile_count > 0) { > + stream->tracefile_current_count = > + (stream->tracefile_current_count + 1) % stream->tracefile_count; here tracefile_current_count vs tracefile_count are misleading. by tracefile_count, do you actually mean the maximum number of chunks ? > + } else { > + stream->tracefile_current_count++; > + } > + > + return lttng_create_output_file(stream); > + > +end: > + return ret; > +} > + > +/* > * Mmap the ring buffer, read it and write the data to the tracefile. This is a > * core function for writing trace buffers to either the local filesystem or > * the network. > @@ -1345,6 +1449,22 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap( > } else { > /* No streaming, we have to set the len with the full padding */ > len += padding; > + > + /* > + * check if we need to change the tracefile before writing what do you mean by "change" ? Please detail in the comment. > + * the packet > + */ could you wrap this check below into a separate function ? It is specific to chunks rotation, and copy-pasted into both splice and mmap code. > + if (stream->tracefile_size > 0 && > + (stream->tracefile_current_size + len) > > + stream->tracefile_size) { > + ret = rotate_output_file(stream); > + if (ret < 0) { > + ERR("Rotating output file"); > + goto end; > + } > + outfd = stream->out_fd; > + } > + stream->tracefile_current_size += len; > } > > while (len > 0) { > @@ -1507,6 +1627,22 @@ ssize_t lttng_consumer_on_read_subbuffer_splice( > } else { > /* No streaming, we have to set the len with the full padding */ > len += padding; > + > + /* > + * check if we need to change the tracefile before writing > + * the packet change = ? > + */ > + if (stream->tracefile_size > 0 && > + (stream->tracefile_current_size + len) > > + stream->tracefile_size) { > + ret = rotate_output_file(stream); > + if (ret < 0) { > + ERR("Rotating output file"); > + goto end; > + } > + outfd = stream->out_fd; > + } > + stream->tracefile_current_size += len; > } Thanks, Mathieu > > while (len > 0) { > diff --git a/src/common/consumer.h b/src/common/consumer.h > index a3e1ec3..867c5ef 100644 > --- a/src/common/consumer.h > +++ b/src/common/consumer.h > @@ -136,6 +136,12 @@ struct lttng_consumer_channel { > * contiguousness and order. > */ > uint64_t contig_metadata_written; > + > + /* > + * On-disk circular buffer > + */ > + uint64_t tracefile_size; > + uint64_t tracefile_count; > }; > > /* > @@ -221,6 +227,12 @@ struct lttng_consumer_stream { > /* Internal state of libustctl. */ > struct ustctl_consumer_stream *ustream; > struct cds_list_head send_node; > + > + /* On-disk circular buffer */ > + uint64_t tracefile_size; > + uint64_t tracefile_count; > + uint64_t tracefile_current_size; > + uint64_t tracefile_current_count; > }; > > /* > @@ -431,7 +443,9 @@ struct lttng_consumer_stream *consumer_allocate_stream(uint64_t channel_key, > uint64_t session_id, > int cpu, > int *alloc_ret, > - enum consumer_channel_type type); > + enum consumer_channel_type type, > + uint64_t tracefile_size, > + uint64_t tracefile_count); > struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, > uint64_t session_id, > const char *pathname, > @@ -439,7 +453,9 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, > uid_t uid, > gid_t gid, > int relayd_id, > - enum lttng_event_output output); > + enum lttng_event_output output, > + uint64_t tracefile_size, > + uint64_t tracefile_count); > void consumer_del_stream(struct lttng_consumer_stream *stream, > struct lttng_ht *ht); > void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, > @@ -464,6 +480,7 @@ struct lttng_consumer_local_data *lttng_consumer_create( > int (*recv_stream)(struct lttng_consumer_stream *stream), > int (*update_stream)(int sessiond_key, uint32_t state)); > void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx); > +int lttng_create_output_file(struct lttng_consumer_stream *stream); > ssize_t lttng_consumer_on_read_subbuffer_mmap( > struct lttng_consumer_local_data *ctx, > struct lttng_consumer_stream *stream, unsigned long len, > diff --git a/src/common/defaults.h b/src/common/defaults.h > index 83159d7..8a07ba0 100644 > --- a/src/common/defaults.h > +++ b/src/common/defaults.h > @@ -138,6 +138,10 @@ > #define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM DEFAULT_CHANNEL_SUBBUF_NUM > /* See lttng-kernel.h enum lttng_kernel_output for channel output */ > #define DEFAULT_KERNEL_CHANNEL_OUTPUT LTTNG_EVENT_SPLICE > +/* By default, unlimited tracefile size */ > +#define DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE 0 > +/* By default, unlimited tracefile count */ > +#define DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT 0 > > /* User space defaults */ > > @@ -147,6 +151,10 @@ > #define DEFAULT_UST_CHANNEL_SUBBUF_NUM DEFAULT_CHANNEL_SUBBUF_NUM > /* See lttng-ust.h enum lttng_ust_output */ > #define DEFAULT_UST_CHANNEL_OUTPUT LTTNG_EVENT_MMAP > +/* By default, unlimited tracefile size */ > +#define DEFAULT_UST_CHANNEL_TRACEFILE_SIZE 0 > +/* By default, unlimited tracefile count */ > +#define DEFAULT_UST_CHANNEL_TRACEFILE_COUNT 0 > > /* > * Default timeout value for the sem_timedwait() call. Blocking forever is not > diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c > index ca1e98b..7ab1bf0 100644 > --- a/src/common/kernel-consumer/kernel-consumer.c > +++ b/src/common/kernel-consumer/kernel-consumer.c > @@ -132,7 +132,9 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, > new_channel = consumer_allocate_channel(msg.u.channel.channel_key, > msg.u.channel.session_id, msg.u.channel.pathname, > msg.u.channel.name, msg.u.channel.uid, msg.u.channel.gid, > - msg.u.channel.relayd_id, msg.u.channel.output); > + msg.u.channel.relayd_id, msg.u.channel.output, > + msg.u.channel.tracefile_size, > + msg.u.channel.tracefile_count); > if (new_channel == NULL) { > lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); > goto end_nosignal; > @@ -229,7 +231,9 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, > channel->session_id, > msg.u.stream.cpu, > &alloc_ret, > - channel->type); > + channel->type, > + channel->tracefile_size, > + channel->tracefile_count); > if (new_stream == NULL) { > switch (alloc_ret) { > case -ENOMEM: > @@ -501,28 +505,15 @@ end: > int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream) > { > int ret; > - char full_path[PATH_MAX]; > > assert(stream); > > - ret = snprintf(full_path, sizeof(full_path), "%s/%s", > - stream->chan->pathname, stream->name); > + ret = lttng_create_output_file(stream); > if (ret < 0) { > - PERROR("snprintf on_recv_stream"); > + ERR("Creating output file"); > goto error; > } > > - /* Opening the tracefile in write mode */ > - if (stream->net_seq_idx == (uint64_t) -1ULL) { > - ret = run_as_open(full_path, O_WRONLY | O_CREAT | O_TRUNC, > - S_IRWXU|S_IRWXG|S_IRWXO, stream->uid, stream->gid); > - if (ret < 0) { > - PERROR("open kernel stream path %s", full_path); > - goto error; > - } > - stream->out_fd = ret; > - } > - > if (stream->output == LTTNG_EVENT_MMAP) { > /* get the len of the mmap region */ > unsigned long mmap_len; > diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h > index 60a3ead..871027c 100644 > --- a/src/common/sessiond-comm/sessiond-comm.h > +++ b/src/common/sessiond-comm/sessiond-comm.h > @@ -273,10 +273,14 @@ struct lttcomm_consumer_msg { > /* Use splice or mmap to consume this fd */ > enum lttng_event_output output; > int type; /* Per cpu or metadata. */ > + uint64_t tracefile_size; /* bytes */ > + uint64_t tracefile_count; /* number of tracefiles */ > } LTTNG_PACKED channel; /* Only used by Kernel. */ > struct { > uint64_t stream_key; > uint64_t channel_key; > + uint64_t tracefile_size; /* bytes */ > + uint64_t tracefile_count; /* number of tracefiles */ > int32_t cpu; /* On which CPU this stream is assigned. */ > } LTTNG_PACKED stream; /* Only used by Kernel. */ > struct { > @@ -309,6 +313,8 @@ struct lttcomm_consumer_msg { > uint64_t relayd_id; /* Relayd id if apply. */ > uint64_t key; /* Unique channel key. */ > unsigned char uuid[UUID_STR_LEN]; /* uuid for ust tracer. */ > + uint64_t tracefile_size; /* bytes */ > + uint64_t tracefile_count; /* number of tracefiles */ > } LTTNG_PACKED ask_channel; > struct { > uint64_t key; > diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c > index 5d9dc96..41fd49b 100644 > --- a/src/common/ust-consumer/ust-consumer.c > +++ b/src/common/ust-consumer/ust-consumer.c > @@ -109,13 +109,14 @@ error: > */ > static struct lttng_consumer_channel *allocate_channel(uint64_t session_id, > const char *pathname, const char *name, uid_t uid, gid_t gid, > - int relayd_id, uint64_t key, enum lttng_event_output output) > + int relayd_id, uint64_t key, enum lttng_event_output output, > + uint64_t tracefile_size, uint64_t tracefile_count) > { > assert(pathname); > assert(name); > > return consumer_allocate_channel(key, session_id, pathname, name, uid, gid, > - relayd_id, output); > + relayd_id, output, tracefile_size, tracefile_count); > } > > /* > @@ -144,7 +145,8 @@ static struct lttng_consumer_stream *allocate_stream(int cpu, int key, > channel->session_id, > cpu, > &alloc_ret, > - channel->type); > + channel->type, > + 0, 0); > if (stream == NULL) { > switch (alloc_ret) { > case -ENOENT: > @@ -264,6 +266,8 @@ static int create_ust_streams(struct lttng_consumer_channel *channel, > goto error_alloc; > } > stream->ustream = ustream; > + stream->tracefile_size = channel->tracefile_size; > + stream->tracefile_count = channel->tracefile_count; > /* > * Store it so we can save multiple function calls afterwards since > * this value is used heavily in the stream threads. This is UST > @@ -750,7 +754,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, > msg.u.ask_channel.pathname, msg.u.ask_channel.name, > msg.u.ask_channel.uid, msg.u.ask_channel.gid, > msg.u.ask_channel.relayd_id, msg.u.ask_channel.key, > - (enum lttng_event_output) msg.u.ask_channel.output); > + (enum lttng_event_output) msg.u.ask_channel.output, > + msg.u.ask_channel.tracefile_size, > + msg.u.ask_channel.tracefile_count); > if (!channel) { > goto end_channel_error; > } > @@ -1176,35 +1182,7 @@ end: > */ > int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream) > { > - int ret; > - char full_path[PATH_MAX]; > - > - /* Opening the tracefile in write mode */ > - if (stream->net_seq_idx != (uint64_t) -1ULL) { > - goto end; > - } > - > - ret = snprintf(full_path, sizeof(full_path), "%s/%s", > - stream->chan->pathname, stream->name); > - if (ret < 0) { > - PERROR("snprintf on_recv_stream"); > - goto error; > - } > - > - ret = run_as_open(full_path, O_WRONLY | O_CREAT | O_TRUNC, > - S_IRWXU | S_IRWXG | S_IRWXO, stream->uid, stream->gid); > - if (ret < 0) { > - PERROR("open stream path %s", full_path); > - goto error; > - } > - stream->out_fd = ret; > - > -end: > - /* we return 0 to let the library handle the FD internally */ > - return 0; > - > -error: > - return ret; > + return lttng_create_output_file(stream); > } > > /* > diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c > index 8f63bf3..f2a6107 100644 > --- a/src/lib/lttng-ctl/lttng-ctl.c > +++ b/src/lib/lttng-ctl/lttng-ctl.c > @@ -1360,6 +1360,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, > attr->subbuf_size = default_get_kernel_channel_subbuf_size(); > attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM; > attr->output = DEFAULT_KERNEL_CHANNEL_OUTPUT; > + attr->tracefile_size = DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE; > + attr->tracefile_count = DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT; > break; > case LTTNG_DOMAIN_UST: > #if 0 > @@ -1374,6 +1376,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, > attr->subbuf_size = default_get_ust_channel_subbuf_size(); > attr->num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM; > attr->output = DEFAULT_UST_CHANNEL_OUTPUT; > + attr->tracefile_size = DEFAULT_UST_CHANNEL_TRACEFILE_SIZE; > + attr->tracefile_count = DEFAULT_UST_CHANNEL_TRACEFILE_COUNT; > break; > default: > /* Default behavior: leave set to 0. */ > -- > 1.7.10.4 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From jeremie.galarneau at efficios.com Fri Mar 8 13:14:20 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Fri, 8 Mar 2013 13:14:20 -0500 Subject: [lttng-dev] Babeltrace v1.0.3 In-Reply-To: References: Message-ID: Taking this back on the mailing list for public reference. I was able to reproduce the "babeltrace: symbol lookup error: babeltrace: undefined symbol: opt_clock_cycles" issue on Ubuntu 12.04 after installing the babeltrace package. Looking at the package's information page[1], it appears that the it depends on both libbabeltrace-ctf0 and libbabeltrace0 packages. Issuing "sudo apt-get purge babeltrace" will not remove them and the v1.0.0-rc1 libraries left on the system will conflict with the ones you are installing from the 1.0.3 source package. Removing these left-over packages (libbabeltrace-ctf0 and libbabeltrace0) explicitly using "apt-get remove/purge" solved the problem here. Let me know if it helps. Regards, J?r?mie [1] http://packages.ubuntu.com/precise/babeltrace On Fri, Mar 8, 2013 at 12:00 AM, Nikitha Annaji wrote: > Hello, > > Yes, I uninstalled it. > > Actually this Babeltrace (1.0.0-rc1) package was along with ubuntu 12.04. > So I uninstalled it using the command " sudo apt-get purge lttng" and > then installed Babeltrace v1.0.3. > > Now also am getting this error :( > > On Fri, Mar 8, 2013 at 12:40 AM, J?r?mie Galarneau > wrote: >> Did you uninstall the previous version of Babeltrace (1.0.0-rc1)? >> >> If not, please run "sudo make uninstall" in 1.0.0-rc1's source >> directory to remove any trace of Babeltrace before you install the >> newest version. (or using your distro's package manager, if you had >> installed the babeltrace package) >> >> Please let me know if you still get this error at this point. >> >> J?r?mie >> >> On Wed, Mar 6, 2013 at 11:46 PM, Nikitha Annaji >> wrote: >>> Hello, >>> >>> I am using ubuntu 12.04 . >>> As I told I just downloaded the package from https://lttng.org/download, >>> extracted and builded by the below steps : >>> >>> 1. ./configure >>> 2. make >>> 3. sudo make install >>> 4. sudo ldconfig >>> >>> By using LTTNG i was able to reproduce the log ( >>> final-7351-20130219-153152 ) which is in CTF format. Then i was trying >>> to use Babeltrace to convert above 'ctf log' into 'text' by giving the >>> option as, >>> >>> babeltrace final-7351-20130219-153152 >>> >>> Then i got This error. But if I switch to version v1.0.0-rc1 then it >>> is working fine. >>> >>> >>> >>> On Wed, Mar 6, 2013 at 11:25 PM, J?r?mie Galarneau >>> wrote: >>>> Hi, >>>> >>>> All available source code documentation is available in the doc folder >>>> of the release tarball. However, the CTF spec itself is available at: >>>> >>>> http://git.efficios.com/?p=ctf.git;a=blob_plain;f=common-trace-format-specification.txt;hb=master >>>> >>>> I could not reproduce your issue here. Which ubuntu version are you >>>> using and can you provide me with reproduction steps? What is the >>>> exact command you are issuing to get babeltrace to error out? >>>> >>>> Regards, >>>> J?r?mie >>>> >>>> On Wed, Mar 6, 2013 at 1:22 AM, Nikitha Annaji >>>> wrote: >>>>> Hi Jeremie , >>>>> >>>>> I need one more help. >>>>> Is their any documentation on source code of babeltrace version v1.0.0-rc1 . >>>>> >>>>> It will be a great help if you provide me the documentation because am >>>>> not able to understand the source code. >>>>> >>>>> Thanks in advance. >>>>> >>>>> Thanks & Regards >>>>> Nikitha Annaji >>>>> >>>>> >>>>> On Wed, Mar 6, 2013 at 12:08 AM, J?r?mie Galarneau >>>>> wrote: >>>>>> Hi Nikitha, >>>>>> >>>>>> I'd be glad to help you but I need more details. On which platform are >>>>>> you getting this error? >>>>>> >>>>>> Are you using a pre-compiled package from your distribution or did you >>>>>> build babeltrace yourself? >>>>>> If you compiled it yourself, which configuration options did you use? >>>>>> >>>>>> Regards, >>>>>> J?r?mie >>>>>> >>>>>> On Tue, Mar 5, 2013 at 8:41 AM, Nikitha Annaji >>>>>> wrote: >>>>>>> Hi, >>>>>>> I was using the babeltrace version v1.0.0-rc1 and it use to produce >>>>>>> the text log when we give the ctf input, >>>>>>> but when i switched Babeltrace to the newer version it is started >>>>>>> giving this error : babeltrace: symbol lookup error: babeltrace: >>>>>>> undefined symbol: opt_clock_cycles . Can you please tell me what >>>>>>> should be done so that i will not get this error again. >>>>>>> >>>>>>> Thanks & Regards >>>>>>> Nikitha Annaji >>>>>>> >>>>>>> _______________________________________________ >>>>>>> lttng-dev mailing list >>>>>>> lttng-dev at lists.lttng.org >>>>>>> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev >>> >>> >>> >>> -- >>> Thanks & Regards >>> Nikitha Annaji > > > > -- > Thanks & Regards > Nikitha Annaji From Daniel.Thibault at drdc-rddc.gc.ca Fri Mar 8 15:31:33 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Fri, 8 Mar 2013 20:31:33 +0000 Subject: [lttng-dev] [LTTNG-TOOLS PATCH] On-disk multiple tracefiles circular buffer Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD026695@VAL-E-01.valcartier.drdc-rddc.gc.ca> -----Message d'origine----- From: Mathieu Desnoyers > I having similar questions as Daniel about tracefile-size and tracefile-count. > > For each stream, do we have max size used on disk = size * count or size used = size ? My understanding is that the maximum size on disk of a stream (channel) would be size*count*CPUs*processes, where processes is the number of user-space processes emitting events on that channel (this number can theoretically be quite large); for the kernel this number is 1. > If there is a doubt about the semantic, maybe using clearer terms that don't need to be explained might help. I guess the confusion here is: > what is a tracefile exactly ? The notion of "stream" is much clearer than "tracefile" in the CTF spec, so we might want to consider: > >--stream-chunks-num NUM: each stream, on disk, is divided in at most > NUM chunks (one file per chunk). When the maximum number of chunks is > reached, oldest chunks are deleted for this stream, thus creating > a flight recorder on disk. > >--stream-chunks-size SIZE: chunk size. Must be a multiple of > subbuf-size. Default value: subbuffer size. According to the CTF spec ("Event Stream: An ordered sequence of events, containing a subset of the trace event types."), an event stream is an LTTng channel. This is clearly not the same thing as an on-disk file (and its corresponding file stream). This would mean: --stream-chunks-num NUM: each file stream (a channel, CPU ID, originating process ID triplet), on disk, is divided in at most NUM chunks (one file per chunk). When the maximum number of chunks is reached, the oldest chunks are overwritten by this stream, thus creating a circular flight recorder on disk. > Actually, you might want to consider that the stream-chunk-size need to be a multiple of the subbuffer size. The check needs to be more strict. Good idea. Not necessarily a power of two, though. ########## On a somewhat related topic, I find the CTF (1.8.2) spec confusing in sections 5 and 6: > 5. Event Packet Header > > The event packet header consists of two parts: the "event packet header" > is the same for all streams of a trace. The second part, the "event > packet context", is described on a per-stream basis. Both are described > in the TSDL meta-data. The packets are aligned on architecture-page-sized > addresses. [...] > 5.1 Event Packet Header Description [...] > 5.2 Event Packet Context Description [...] > 6. Event Structure > > The overall structure of an event is: > > 1 - Stream Packet Context (as specified by the stream meta-data) > 2 - Event Header (as specified by the stream meta-data) > 3 - Stream Event Context (as specified by the stream meta-data) > 4 - Event Context (as specified by the event meta-data) > 5 - Event Payload (as specified by the event meta-data) [...] > 6.1 Event Header [...] > 6.1.1 Type 1 - Few event IDs [...] > 6.1.2 Type 2 - Many event IDs [...] > 6.2 Event Context > > The event context contains information relative to the current event. > The choice and meaning of this information is specified by the TSDL > stream and event meta-data descriptions. The stream context is applied > to all events within the stream. The stream context structure follows > the event header. The event context is applied to specific events. Its > structure follows the stream context structure. [...] > 6.3 Event Payload > > An event payload contains fields specific to a given event type. The fields > belonging to an event type are described in the event-specific meta-data > within a structure type. The babeltrace output labels the following structured fields in each event record: stream.packet.context stream.event.header stream.event.context event.context event.fields They match section 6: > 1 - Stream Packet Context (as specified by the stream meta-data) > 2 - Event Header (as specified by the stream meta-data) > 3 - Stream Event Context (as specified by the stream meta-data) > 4 - Event Context (as specified by the event meta-data) > 5 - Event Payload (as specified by the event meta-data) But where does section 5 fit in? There is no "Event Packet Header" or "Event Packet Context" in the above. Section 3 mentions that "The event stream header will therefore be referred to as the 'event packet header' throughout the rest of this document." Judging by the C structs described, the lack of a Stream Packet Context struct in section 6, and the babeltrace output, I'm pretty sure that the "stream packet context" is the "event packet context" and that it also subsumes the "event packet header" (a.k.a. "event stream header"). But it would be nice if this were actually stated in the CTF spec. I would also like to know if LTTng can populate the "Event Context" (6.4) of a trace, or if this is something only other CTF producers may do. I haven't yet been able to produce any traces that have that field in them, and don't see how to do so. Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC G3J 1X5 CANADA Vox : (418) 844-4000 x4245 Fax : (418) 844-4538 NAC : 918V QSDJ Gouvernement du Canada / Government of Canada From dgoulet at efficios.com Mon Mar 11 13:43:20 2013 From: dgoulet at efficios.com (David Goulet) Date: Mon, 11 Mar 2013 13:43:20 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Fix: mark generated python bindings files as nodist In-Reply-To: <1360979205-20346-1-git-send-email-jeremie.galarneau@efficios.com> References: <1360979205-20346-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <513E17B8.3010400@efficios.com> Merged! Thanks! J?r?mie Galarneau: > make dist would fail if ./configure had not been invoked with > the --enable-python-bindings switch. > > Signed-off-by: J?r?mie Galarneau > --- > extras/bindings/swig/python/Makefile.am | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/extras/bindings/swig/python/Makefile.am b/extras/bindings/swig/python/Makefile.am > index c6a6901..6e7baa6 100644 > --- a/extras/bindings/swig/python/Makefile.am > +++ b/extras/bindings/swig/python/Makefile.am > @@ -4,16 +4,14 @@ lttng.i: lttng.i.in > AM_CFLAGS = -I$(PYTHON_INCLUDE) -I$(top_srcdir)/lib/lttng-ctl -I../common \ > $(BUDDY_CFLAGS) > > -EXTRA_DIST = lttng.i > -python_PYTHON = lttng.py > +EXTRA_DIST = lttng.i.in > +nodist_python_PYTHON = lttng.py > pyexec_LTLIBRARIES = _lttng.la > > MAINTAINERCLEANFILES = lttng_wrap.c lttng.py > > -_lttng_la_SOURCES = lttng_wrap.c > - > +nodist__lttng_la_SOURCES = lttng_wrap.c > _lttng_la_LDFLAGS = -module > - > _lttng_la_LIBADD = $(top_srcdir)/src/lib/lttng-ctl/liblttng-ctl.la \ > $(top_srcdir)/src/common/sessiond-comm/libsessiond-comm.la > From dgoulet at efficios.com Mon Mar 11 13:43:30 2013 From: dgoulet at efficios.com (David Goulet) Date: Mon, 11 Mar 2013 13:43:30 -0400 Subject: [lttng-dev] Pull request for lttng-tools tests cleanup branch In-Reply-To: References: Message-ID: <513E17C2.1070109@efficios.com> Merged! Thanks! Christian Babeux: > Hello lttng-droids, > > Instead of spamming the mailing list with the 30+ patches for the > lttng-tools tests cleanup branch, > I would kindly ask for a pull request for commits 9ac429ef .. 0ea4ac57 > on my personal repository. > > You can find the branch here: > git://github.com/cbab/lttng-tools.git -b tests-cleanup > > Web: > https://github.com/cbab/lttng-tools/commits/tests-cleanup > > Thanks, > > Christian From yannick.brosseau at gmail.com Mon Mar 11 22:55:00 2013 From: yannick.brosseau at gmail.com (Yannick Brosseau) Date: Mon, 11 Mar 2013 22:55:00 -0400 Subject: [lttng-dev] [PATCH babeltrace 1/2] Added Python 3.0 or better requirement to the README file In-Reply-To: References: <1359640251-6133-1-git-send-email-jeremie.galarneau@efficios.com> <510BA252.3020604@gmail.com> Message-ID: <513E9904.2050201@gmail.com> On 2013-02-01 08:54, J?r?mie Galarneau wrote: > As for as I know, the bindings do work with Python 2.7. > However, we have decided to no longer explicitly support older > versions of Python in order to make the bindings, along with future > developments, easily maintainable. > My main concern is that 2.7 is still the default version for many linux distribution, so it might be early to drop 2.7 support. Yannick From jp_ikaheimonen at mentor.com Tue Mar 12 09:16:25 2013 From: jp_ikaheimonen at mentor.com (Ikaheimonen, JP) Date: Tue, 12 Mar 2013 13:16:25 +0000 Subject: [lttng-dev] [PATCH babeltrace] Move memstream.h and uuid.h to include/babeltrace/compat directory Message-ID: <009B25148989C6458484484699278506985C2118@EU-MBX-01.mgc.mentorg.com> As preparation for a new compatibility layer, the files memstream.h and uuid.h are moved to include/babeltrace/compat. --- converter/babeltrace-log.c | 2 +- formats/ctf/Makefile.am | 3 +-- formats/ctf/ctf.c | 4 ++-- formats/ctf/metadata/ctf-visitor-generate-io-struct.c | 2 +- include/Makefile.am | 3 ++- {formats/ctf => include/babeltrace/compat}/memstream.h | 0 include/babeltrace/{ => compat}/uuid.h | 0 include/babeltrace/ctf-ir/metadata.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename {formats/ctf => include/babeltrace/compat}/memstream.h (100%) rename include/babeltrace/{ => compat}/uuid.h (100%) diff --git a/converter/babeltrace-log.c b/converter/babeltrace-log.c index 2148711..0214e9a 100644 --- a/converter/babeltrace-log.c +++ b/converter/babeltrace-log.c @@ -45,7 +45,7 @@ #include #include -#include +#include #include #define USEC_PER_SEC 1000000UL diff --git a/formats/ctf/Makefile.am b/formats/ctf/Makefile.am index d803b69..6dcc1bb 100644 --- a/formats/ctf/Makefile.am +++ b/formats/ctf/Makefile.am @@ -9,8 +9,7 @@ libbabeltrace_ctf_la_SOURCES = \ events.c \ iterator.c \ callbacks.c \ - events-private.h \ - memstream.h + events-private.h # Request that the linker keeps all static libraries objects. libbabeltrace_ctf_la_LDFLAGS = \ diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 5a51495..bb3ba83 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ #include "metadata/ctf-parser.h" #include "metadata/ctf-ast.h" #include "events-private.h" -#include "memstream.h" +#include " /* * We currently simply map a page to read the packet header and packet diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index 9bcc170..3be054d 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include "ctf-scanner.h" diff --git a/include/Makefile.am b/include/Makefile.am index 824be61..0ade99b 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -30,6 +30,7 @@ noinst_HEADERS = \ babeltrace/ctf/types.h \ babeltrace/ctf/callbacks-internal.h \ babeltrace/trace-handle-internal.h \ - babeltrace/uuid.h \ + babeltrace/compat/uuid.h \ + babeltrace/compat/memstream.h \ babeltrace/endian.h \ babeltrace/mmap-align.h diff --git a/formats/ctf/memstream.h b/include/babeltrace/compat/memstream.h similarity index 100% rename from formats/ctf/memstream.h rename to include/babeltrace/compat/memstream.h diff --git a/include/babeltrace/uuid.h b/include/babeltrace/compat/uuid.h similarity index 100% rename from include/babeltrace/uuid.h rename to include/babeltrace/compat/uuid.h diff --git a/include/babeltrace/ctf-ir/metadata.h b/include/babeltrace/ctf-ir/metadata.h index 04e8945..fdb671a 100644 --- a/include/babeltrace/ctf-ir/metadata.h +++ b/include/babeltrace/ctf-ir/metadata.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include -- 1.7.10.4 From jeremie.galarneau at efficios.com Tue Mar 12 10:31:14 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Tue, 12 Mar 2013 10:31:14 -0400 Subject: [lttng-dev] [PATCH babeltrace 1/2] Added Python 3.0 or better requirement to the README file In-Reply-To: <513E9904.2050201@gmail.com> References: <1359640251-6133-1-git-send-email-jeremie.galarneau@efficios.com> <510BA252.3020604@gmail.com> <513E9904.2050201@gmail.com> Message-ID: Although I agree it can prove to be an inconvenience for some users, most distributions provide a Python 3 package at this point. The reasoning is that since these bindings are still in development and won't be integrated into the master branch for some time, the effort needed to develop and test them while targeting two versions of Python is hard to justify. On Mon, Mar 11, 2013 at 10:55 PM, Yannick Brosseau wrote: > On 2013-02-01 08:54, J?r?mie Galarneau wrote: >> As for as I know, the bindings do work with Python 2.7. >> However, we have decided to no longer explicitly support older >> versions of Python in order to make the bindings, along with future >> developments, easily maintainable. >> > My main concern is that 2.7 is still the default version for many linux > distribution, so it might be early to drop 2.7 support. > > Yannick > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From osdepend at gmail.com Tue Mar 12 13:25:21 2013 From: osdepend at gmail.com (OSDepend) Date: Wed, 13 Mar 2013 01:25:21 +0800 Subject: [lttng-dev] build error: ltt-control package Message-ID: <201303130125186687389@gmail.com> Hi, all, I met some trouble when i tried to "make" the ltt-control-0.88-09242010. The code is list below: make[2]: Leaving directory `/usr/src/ltt-control-0.88-09242010/liblttd' Making all in lttd make[2]: Entering directory `/usr/src/ltt-control-0.88-09242010/lttd' gcc -DHAVE_CONFIG_H -I.. -I.. -g -O2 -MT lttd.o -MD -MP -MF .deps/lttd.Tpo -c -o lttd.o lttd.c mv -f .deps/lttd.Tpo .deps/lttd.Po /bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o lttd lttd.o ../liblttd/liblttd.la -lpthread libtool: link: gcc -g -O2 -o .libs/lttd lttd.o ../liblttd/.libs/liblttd.so -lpthread ../liblttd/.libs/liblttd.so: undefined reference to `sync_file_range' collect2: ld returned 1 exit status make[2]: *** [lttd] Error 1 make[2]: Leaving directory `/usr/src/ltt-control-0.88-09242010/lttd' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/src/ltt-control-0.88-09242010' make: *** [all] Error 2 My workstation is Centos 5.5, glibc-2.5. It seems like a design bug in centos which ignore the sysycall sync_file_range, so seems the only way for me is to just delete the related code. Is there any other way to make it through? please help me out!! 2013-03-13 zhengchen -------------- next part -------------- An HTML attachment was scrubbed... URL: From yannick.brosseau at gmail.com Tue Mar 12 13:27:13 2013 From: yannick.brosseau at gmail.com (Yannick Brosseau) Date: Tue, 12 Mar 2013 13:27:13 -0400 Subject: [lttng-dev] LTTV CTF support work in progress Message-ID: <513F6571.10301@gmail.com> Hi all, Some of you want to know what is the current status of LTTV. The current port to use libbabeltrace to read the CTF file produced by LTTng 2.x is going well, but there are still issues remaining. If you want to try the current version, you can grab the babelproto branch in the LTTV git repo: http://git.lttng.org/?p=lttv.git;a=shortlog;h=refs/heads/babelproto You will need the master branch of the babeltrace git to compile it. The textview is working and a basic Control Flow view (state view) is showing. We have some bugs in the display of the state (Some redraw problem, and some values seems to not be displayed correctly), so you should not rely on the information displayed. Performance wise, it's still costly to open a big trace. You might get some improvment with some addition I did for babeltrace, which are available in my personal babeltrace repo, in the branch iter_equals_pos : http://git.dorsal.polymtl.ca/~ybrosseau?p=babeltrace.git;a=shortlog;h=refs/heads/iter_equals_pos I will keep you posted when it runs better... :) Yannick From raphael.beamonte at gmail.com Tue Mar 12 17:24:42 2013 From: raphael.beamonte at gmail.com (=?UTF-8?q?Rapha=C3=ABl=20Beamonte?=) Date: Tue, 12 Mar 2013 17:24:42 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Correct LTTng version Message-ID: <14dbf3b61272282c1f4163c8a1a2f2b681f3989c.1363123481.git.raphael.beamonte@gmail.com> Signed-off-by: Rapha?l Beamonte --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7e35c06..c8aa034 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([lttng-tools],[2.1.0],[dgoulet at efficios.com],[],[http://lttng.org]) +AC_INIT([lttng-tools],[2.1.1],[dgoulet at efficios.com],[],[http://lttng.org]) AC_CONFIG_AUX_DIR([config]) AC_CANONICAL_TARGET AC_CANONICAL_HOST -- 1.7.10.4 From raphael.beamonte at gmail.com Tue Mar 12 17:24:51 2013 From: raphael.beamonte at gmail.com (=?UTF-8?q?Rapha=C3=ABl=20Beamonte?=) Date: Tue, 12 Mar 2013 17:24:51 -0400 Subject: [lttng-dev] [lttng-ust PATCH] Correct LTTng version Message-ID: <7faae28ab8f9e1e0bc6bce5df4bb11a8053ac8cf.1363123477.git.raphael.beamonte@gmail.com> Signed-off-by: Rapha?l Beamonte --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fdc5c84..6f6f885 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT([lttng-ust],[2.1.0],[mathieu dot desnoyers at efficios dot com]) +AC_INIT([lttng-ust],[2.1.1],[mathieu dot desnoyers at efficios dot com]) # Following the numbering scheme proposed by libtool for the library version # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -- 1.7.10.4 From dgoulet at efficios.com Tue Mar 12 17:28:17 2013 From: dgoulet at efficios.com (David Goulet) Date: Tue, 12 Mar 2013 17:28:17 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Correct LTTng version In-Reply-To: <14dbf3b61272282c1f4163c8a1a2f2b681f3989c.1363123481.git.raphael.beamonte@gmail.com> References: <14dbf3b61272282c1f4163c8a1a2f2b681f3989c.1363123481.git.raphael.beamonte@gmail.com> Message-ID: <513F9DF1.9030909@efficios.com> Hi Rapha?l, This is not very relevant because we branch at each release so the master version is a bit useless. Do you have a need for that? Thanks David Rapha?l Beamonte: > Signed-off-by: Rapha?l Beamonte > --- > configure.ac | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/configure.ac b/configure.ac > index 7e35c06..c8aa034 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1,4 +1,4 @@ > -AC_INIT([lttng-tools],[2.1.0],[dgoulet at efficios.com],[],[http://lttng.org]) > +AC_INIT([lttng-tools],[2.1.1],[dgoulet at efficios.com],[],[http://lttng.org]) > AC_CONFIG_AUX_DIR([config]) > AC_CANONICAL_TARGET > AC_CANONICAL_HOST From raphael.beamonte at gmail.com Tue Mar 12 17:31:49 2013 From: raphael.beamonte at gmail.com (=?ISO-8859-1?Q?Rapha=EBl_Beamonte?=) Date: Tue, 12 Mar 2013 17:31:49 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Correct LTTng version In-Reply-To: <513F9DF1.9030909@efficios.com> References: <14dbf3b61272282c1f4163c8a1a2f2b681f3989c.1363123481.git.raphael.beamonte@gmail.com> <513F9DF1.9030909@efficios.com> Message-ID: Hi David, The tag version changed in LTTng but not the displayed version, and it made me remove the whole LTTng tools from my computer and reinstall them as I didn't understand why the version number displayed wasn't the one from the version I was installing. It's not a very important bug, but it could be a time consumer one... Rapha?l 2013/3/12 David Goulet > Hi Rapha?l, > > This is not very relevant because we branch at each release so the > master version is a bit useless. > > Do you have a need for that? > > Thanks > David > > Rapha?l Beamonte: > > Signed-off-by: Rapha?l Beamonte > > --- > > configure.ac | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/configure.ac b/configure.ac > > index 7e35c06..c8aa034 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -1,4 +1,4 @@ > > -AC_INIT([lttng-tools],[2.1.0],[dgoulet at efficios.com],[],[ > http://lttng.org]) > > +AC_INIT([lttng-tools],[2.1.1],[dgoulet at efficios.com],[],[ > http://lttng.org]) > > AC_CONFIG_AUX_DIR([config]) > > AC_CANONICAL_TARGET > > AC_CANONICAL_HOST > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yannick.brosseau at gmail.com Tue Mar 12 17:34:57 2013 From: yannick.brosseau at gmail.com (Yannick Brosseau) Date: Tue, 12 Mar 2013 17:34:57 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Correct LTTng version In-Reply-To: References: <14dbf3b61272282c1f4163c8a1a2f2b681f3989c.1363123481.git.raphael.beamonte@gmail.com> <513F9DF1.9030909@efficios.com> Message-ID: <513F9F81.9040909@gmail.com> Maybe we should find a way to add the git commit id and maybe other git info to the version display when we build it from git. On 2013-03-12 17:31, Rapha?l Beamonte wrote: > Hi David, > > The tag version changed in LTTng but not the displayed version, and it > made me remove the whole LTTng tools from my computer and reinstall > them as I didn't understand why the version number displayed wasn't > the one from the version I was installing. It's not a very important > bug, but it could be a time consumer one... > > Rapha?l > > 2013/3/12 David Goulet > > > Hi Rapha?l, > > This is not very relevant because we branch at each release so the > master version is a bit useless. > > Do you have a need for that? > > Thanks > David > > Rapha?l Beamonte: > > Signed-off-by: Rapha?l Beamonte > > > --- > > configure.ac | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/configure.ac b/configure.ac > > > index 7e35c06..c8aa034 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -1,4 +1,4 @@ > > -AC_INIT([lttng-tools],[2.1.0],[dgoulet at efficios.com > ],[],[http://lttng.org]) > > +AC_INIT([lttng-tools],[2.1.1],[dgoulet at efficios.com > ],[],[http://lttng.org]) > > AC_CONFIG_AUX_DIR([config]) > > AC_CANONICAL_TARGET > > AC_CANONICAL_HOST > > > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgoulet at efficios.com Tue Mar 12 17:38:13 2013 From: dgoulet at efficios.com (David Goulet) Date: Tue, 12 Mar 2013 17:38:13 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Correct LTTng version In-Reply-To: <513F9F81.9040909@gmail.com> References: <14dbf3b61272282c1f4163c8a1a2f2b681f3989c.1363123481.git.raphael.beamonte@gmail.com> <513F9DF1.9030909@efficios.com> <513F9F81.9040909@gmail.com> Message-ID: <513FA045.401@efficios.com> Yup that would be ideal actually! Master is not 2.0 nor 2.1 so having something like "git-FIRST_8_BYTES_OF_HEAD_COMMIT" would be very useful. Thanks! David Yannick Brosseau: > Maybe we should find a way to add the git commit id and maybe other git > info to the version display when we build it from git. > > On 2013-03-12 17:31, Rapha?l Beamonte wrote: >> Hi David, >> >> The tag version changed in LTTng but not the displayed version, and it >> made me remove the whole LTTng tools from my computer and reinstall >> them as I didn't understand why the version number displayed wasn't >> the one from the version I was installing. It's not a very important >> bug, but it could be a time consumer one... >> >> Rapha?l >> >> 2013/3/12 David Goulet > > >> >> Hi Rapha?l, >> >> This is not very relevant because we branch at each release so the >> master version is a bit useless. >> >> Do you have a need for that? >> >> Thanks >> David >> >> Rapha?l Beamonte: >> > Signed-off-by: Rapha?l Beamonte > > >> > --- >> > configure.ac | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> > >> > diff --git a/configure.ac b/configure.ac >> >> > index 7e35c06..c8aa034 100644 >> > --- a/configure.ac >> > +++ b/configure.ac >> > @@ -1,4 +1,4 @@ >> > -AC_INIT([lttng-tools],[2.1.0],[dgoulet at efficios.com >> ],[],[http://lttng.org]) >> > +AC_INIT([lttng-tools],[2.1.1],[dgoulet at efficios.com >> ],[],[http://lttng.org]) >> > AC_CONFIG_AUX_DIR([config]) >> > AC_CANONICAL_TARGET >> > AC_CANONICAL_HOST >> >> >> >> >> _______________________________________________ >> lttng-dev mailing list >> lttng-dev at lists.lttng.org >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From raphael.beamonte at gmail.com Tue Mar 12 17:37:33 2013 From: raphael.beamonte at gmail.com (=?ISO-8859-1?Q?Rapha=EBl_Beamonte?=) Date: Tue, 12 Mar 2013 17:37:33 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Correct LTTng version In-Reply-To: <513F9F81.9040909@gmail.com> References: <14dbf3b61272282c1f4163c8a1a2f2b681f3989c.1363123481.git.raphael.beamonte@gmail.com> <513F9DF1.9030909@efficios.com> <513F9F81.9040909@gmail.com> Message-ID: 2013/3/12 Yannick Brosseau > Maybe we should find a way to add the git commit id and maybe other git > info to the version display when we build it from git. > I agree with Yannick. That's something that could be very useful. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jistone at redhat.com Tue Mar 12 17:54:30 2013 From: jistone at redhat.com (Josh Stone) Date: Tue, 12 Mar 2013 14:54:30 -0700 Subject: [lttng-dev] [lttng-tools PATCH] Correct LTTng version In-Reply-To: <513FA045.401@efficios.com> References: <14dbf3b61272282c1f4163c8a1a2f2b681f3989c.1363123481.git.raphael.beamonte@gmail.com> <513F9DF1.9030909@efficios.com> <513F9F81.9040909@gmail.com> <513FA045.401@efficios.com> Message-ID: <513FA416.1040106@redhat.com> On 03/12/2013 02:38 PM, David Goulet wrote: > Yup that would be ideal actually! > > Master is not 2.0 nor 2.1 so having something like > "git-FIRST_8_BYTES_OF_HEAD_COMMIT" would be very useful. You might like this script we use with systemtap: http://sourceware.org/git/gitweb.cgi?p=systemtap.git;a=blob;f=git_version.sh That gives us a header which defines a git version string such as "release-2.1-78-g3d0a328", in the style of "git describe". From pierre-luc.st-charles at polymtl.ca Tue Mar 12 18:51:20 2013 From: pierre-luc.st-charles at polymtl.ca (Pierre-Luc St-Charles) Date: Tue, 12 Mar 2013 18:51:20 -0400 Subject: [lttng-dev] Fwd: compiling LTTng for android In-Reply-To: References: Message-ID: Hey Amit, Here's a small update on my latest findings regarding the broken *splice* / bad Bionic impl problem: Although it didn't really cross my mind earlier, we had seen this exact problem before, but in another project; we had also investigated a bit at the time, but to no avail. It seems the issue is known by the Android/Bionic community, but it's simply not on their immediate todo list (and hasn't been for at least the past two years -- see https://code.google.com/p/android/issues/detail?id=11330). The solutions we are now considering are: adding splice support (and whatever else might also be needed) to Bionic ourselves (saving BILLIONS of broken lives in the process, IF the changes are accepted), or simply inserting glibc (and building against it) in our device images. In the next few days, we'll be studying how much time the first solution would actually take (as we're not really experts in that domain at all), but considering the nature/objective of this project, it might be the wisest decision (as it would not require too much swerving away from the default images people have on their devices for LTTng to actually work). If we deem it 'impossible/out of our league', we'll simply try to get a working tool asap using glibc, which should not be very complicated itself (many people have actually successfully done it before). In any case, I'll keep you updated, and I'll also post any big updates on the mailing list. -PL On Wed, Mar 6, 2013 at 8:04 PM, Pierre-Luc St-Charles < pierre-luc.st-charles at polymtl.ca> wrote: > Great findings! > > I'll also try to look into this new problem by next monday; I'm falling a > bit behind on my 'investigations', but I'll keep you updated if anything > comes up. > > -PL > On Mar 6, 2013 6:09 PM, "Amit Balboul" wrote: > >> Hi All, >> >> Regarding the last mail about tracing system calls on Android using LTTng, >> The issue of not receiving enabled event to trace from the kernel can be >> fixed patching src/bin/lttng-sessiond/kernel.c (patch attached) >> In the function *kernel_list_events,* fscanf-ing the events exported by >> the kernel using the fp must not use the syntax *%m* as it is obsolete >> (in Android), >> thus the fscanf returns 0 and won't read the kernel events (first >> condition false). >> Instead I use a pre-allocated buffer for the string and use the *%[^;]*syntax, and omitting the memory free (attached is the patch). >> >> The resulting output is (sessiond is run with verbose debug prints): >> >> root at android:/data/lttng/bin # *./lttng list -k* >> DEBUG1 [10239/10290]: Wait for client response (in >> thread_manage_clients() at main.c:3242) >> DEBUG1 [10239/10290]: Receiving data from client ... (in >> thread_manage_clients() at main.c:3287) >> DEBUG1 [10239/10290]: Nothing recv() from client... continuing (in >> thread_manage_clients() at main.c:3291) >> DEBUG1 [10239/10290]: Clean command context structure (in >> clean_command_ctx() at main.c:482) >> DEBUG1 [10239/10290]: Accepting client command ... (in >> thread_manage_clients() at main.c:3200) >> DEBUG1 [10239/10290]: Wait for client response (in >> thread_manage_clients() at main.c:3242) >> DEBUG1 [10239/10290]: Receiving data from client ... (in >> thread_manage_clients() at main.c:3287) >> DEBUG1 [10239/10290]: Processing client command 14 (in >> process_client_msg() at main.c:2227) >> DEBUG1 [10239/10290]: Kernel list events done (61 events) (in >> kernel_list_events() at kernel.c:653) >> DEBUG1 [10239/10290]: Sending response (size: 35640, retcode: Success) >> (in thread_manage_clients() at main.c:3338) >> DEBUG1 [10239/10290]: Clean command context structure (in >> clean_command_ctx() at main.c:482) >> DEBUG1 [10239/10290]: Accepting client command ... (in >> thread_manage_clients() at main.c:3200) >> Kernel events: >> ------------- >> block_rq_abort (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_rq_requeue (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_rq_complete (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_rq_insert (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_rq_issue (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_bio_bounce (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_bio_complete (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_bio_backmerge (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_bio_frontmerge (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_bio_queue (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_getrq (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_sleeprq (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_plug (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_unplug (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_split (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> irq_handler_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> irq_handler_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> softirq_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> softirq_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> softirq_raise (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: >> tracepoint) >> sched_wakeup (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_switch (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_migrate_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_process_free (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_process_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_wait_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_process_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_process_fork (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_stat_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_stat_sleep (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_stat_iowait (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_stat_runtime (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> sched_pi_setprio (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> signal_generate (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> signal_deliver (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> signal_overflow_fail (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> signal_lose_info (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> lttng_statedump_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> lttng_statedump_end (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> lttng_statedump_process_state (loglevel: TRACE_EMERG (0)) (type: >> tracepoint) >> lttng_statedump_file_descriptor (loglevel: TRACE_EMERG (0)) (type: >> tracepoint) >> lttng_statedump_vm_map (loglevel: TRACE_EMERG (0)) (type: >> tracepoint) >> lttng_statedump_network_interface (loglevel: TRACE_EMERG (0)) >> (type: tracepoint) >> lttng_statedump_interrupt (loglevel: TRACE_EMERG (0)) (type: >> tracepoint) >> timer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> timer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> timer_expire_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> timer_expire_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> timer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> hrtimer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> hrtimer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> hrtimer_expire_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> hrtimer_expire_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> hrtimer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> itimer_state (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> itimer_expire (loglevel: TRACE_EMERG (0)) (type: tracepoint) >> >> root at android:/data/lttng/bin # >> >> Now I'm facing the issue of starting the traces: >> debugging the sessiond, consumerd and lttng I concluded that the issue is >> due to splice system call failure. >> even using a MMAP output type channel, the metadata channel is SPLICE >> type (hard-coded). >> Problem persists also when using relayd to pass the traces through the >> network. >> Ignoring the splice failure means closing of the metadata channel >> (maybe??) but need not affect the traces channel (right ?) >> Attached is a debug log of each thread of the sessiond, right after >> invoking "*./lttng start*". (with extra informative my prints) >> >> Please keep me in touch with any progress in this issue, >> Thank you, >> Amit. >> >> >> >> >> >> >> ---------- Forwarded message ---------- >> From: Amit Balboul >> Date: Wed, Feb 27, 2013 at 4:37 PM >> Subject: Re: [lttng-dev] compiling LTTng for android >> To: PLSTC >> >> >> Hey Pierre, >> >> Some major progress has been achieved, following is the summary: >> >> 1. Modules issue: >> I built (for ARM/Android) and installed latest stable version of busybox >> on the device. >> Seeing the code tries to run (hardcoded) /sbin/modprobe, made a soft link >> to busybox's modeprobe. >> Also, created /lib/modules/ directory and pushed the >> directory from /lib/modules on the machine. >> Now session daemon modprobes the desired modules successfully, (some are >> not present though as mentioned before) - no need to use insmod. >> >> 2. epoll_create1 issue: >> epoll_create1 patch was OK, I accidentally defined EPOLL_CLOEXEC as >> 0x02000000 instead of 02000000 (fixed). >> >> The running scenario: >> >> 1. Run ./lttng-sessiond -d -vvv >> >> Then: (commands are in bold, output is in blue for readability) >> >> root at android:/data/lttng/install_sysroot/bin # *./lttng create s1* >> >> Session s1 created. >> Traces will be written in /data/lttng-traces/s1-20130227-161145 >> root at android:/data/lttng/install_sysroot/bin # *./lttng enable-channel >> ch -k* >> Kernel channel ch enabled for session s1 >> root at android:/data/lttng/install_sysroot/bin # *./lttng enable-event ev >> -k -a* >> All kernel events are enabled in channel channel0 >> root at android:/data/lttng/install_sysroot/bin # *./lttng list s1* >> Tracing session s1: [inactive] >> Trace path: /data/lttng-traces/s1-20130227-161145 >> >> === Domain: Kernel === >> >> Channels: >> ------------- >> - channel0: [enabled] >> >> Attributes: >> overwrite mode: 0 >> subbufers size: 262144 >> number of subbufers: 4 >> switch timer interval: 0 >> read timer interval: 200 >> output: splice() >> >> Events: >> None >> >> - ch: [enabled] >> >> Attributes: >> overwrite mode: 0 >> subbufers size: 262144 >> number of subbufers: 4 >> switch timer interval: 0 >> read timer interval: 200 >> output: splice() >> >> Events: >> None >> >> root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * >> >> Kernel events: >> ------------- >> >> root at android:/data/lttng/install_sysroot/bin # *./lttng start* >> Tracing started for session s1 >> root at android:/data/lttng/install_sysroot/bin # *./lttng stop * >> >> Waiting for data availability >> Tracing stopped for session s1 >> root at android:/data/lttng/install_sysroot/bin # >> >> *Now: (this is not surprising because the kernel events list is empty...) >> * >> the folder /data/lttng-traces/s1-20130227-161145/kernel contains: >> total 0 >> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_0 >> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_1 >> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_0 >> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_1 >> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 metadata >> >> *By the way:* >> When running the same scenario but creating the channel with *--output >> mmap*, still no data but the size of the first two files in the traces >> directory are 4Kb (I didn't bother to investigate them as I assume it is >> just the header - not the traces payload). >> >> Another issue: at this point, listing the sessions gives: >> root at android:/data/lttng/install_sysroot/bin # *./lttng list s1 * >> >> Tracing session s1: [inactive] >> Trace path: /data/lttng-traces/s1-20130227-161145 >> >> === Domain: Kernel === >> >> Error: No kernel consumer detected >> 99|root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * >> >> Error: Unable to list kernel events >> Error: Command error >> 1|root at android:/data/lttng/install_sysroot/bin # >> >> So currently I'm facing these issues: >> 1. Kernel events list is empty. >> 2. Listing the session/ kernel events after creating session, channel, >> event, start, stop - results in "no kernel consumer detected" >> >> If you have some insights please share them with me.. >> >> Thanks >> >> Amit. >> >> >> On Tue, Feb 26, 2013 at 7:35 PM, PLSTC wrote: >> >>> The modules you can't find are the same I am also missing I believe; I >>> think they are only compiled when certain kernel config defines are met >>> (and those might simply be unavailable under ARM). >>> >>> As for what you pointed in your first mail, I believe modprobe isn't >>> available on ARM, did you mean that some modules were not found when using >>> insmod? >>> >>> For the epoll_create1 problem, what kind of patch did you apply to add >>> support for the epoll_create1 function? >>> >>> >>> On Tue, Feb 26, 2013 at 11:29 AM, Amit Balboul < >>> amit.balboul at shinesec.com> wrote: >>> >>>> Ok I got : >>>> lttng-kretprobes.ko >>>> lttng-kprobes.ko >>>> , the other two are missing. >>>> >>>> >>>> ---------- Forwarded message ---------- >>>> From: Amit Balboul >>>> Date: Tue, Feb 26, 2013 at 5:49 PM >>>> Subject: Re: [lttng-dev] compiling LTTng for android >>>> To: PLSTC >>>> >>>> >>>> One more thing: >>>> >>>> The list of modules you gave my is not identical to mine: >>>> a. I pushed the modules from my machine to my folder in the device (not >>>> to /system/lib) as you directed me, and insmoded them manually. >>>> b. I pushed the whole tree under /lib/modules// which >>>> includes the modules.* and the sub directories: >>>> >>>> /lib/modules/3.0.31-gd5a18e0/extra$ ll >>>> total 2464 >>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ./ >>>> drwxr-xr-x 3 root root 4096 Feb 26 15:58 ../ >>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 lib/ >>>> -rw-r--r-- 1 root root 167184 Feb 26 15:58 >>>> lttng-ring-buffer-client-discard.ko >>>> -rw-r--r-- 1 root root 167206 Feb 26 15:58 >>>> lttng-ring-buffer-client-mmap-discard.ko >>>> -rw-r--r-- 1 root root 178586 Feb 26 15:58 >>>> lttng-ring-buffer-client-mmap-overwrite.ko >>>> -rw-r--r-- 1 root root 178564 Feb 26 15:58 >>>> lttng-ring-buffer-client-overwrite.ko >>>> -rw-r--r-- 1 root root 137179 Feb 26 15:58 >>>> lttng-ring-buffer-metadata-client.ko >>>> -rw-r--r-- 1 root root 137233 Feb 26 15:58 >>>> lttng-ring-buffer-metadata-mmap-client.ko >>>> -rw-r--r-- 1 root root 213451 Feb 26 15:58 lttng-statedump.ko >>>> -rw-r--r-- 1 root root 1314235 Feb 26 15:58 lttng-tracer.ko >>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 probes/ >>>> >>>> /lib/modules/3.0.31-gd5a18e0/extra/lib$ ll >>>> total 732 >>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ >>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ >>>> -rw-r--r-- 1 root root 738964 Feb 26 15:58 lttng-lib-ring-buffer.ko >>>> >>>> /lib/modules/3.0.31-gd5a18e0/extra/probes$ ll >>>> total 2872 >>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ >>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ >>>> -rw-r--r-- 1 root root 162872 Feb 26 15:58 lttng-probe-asoc.ko >>>> -rw-r--r-- 1 root root 171049 Feb 26 15:58 lttng-probe-block.ko >>>> -rw-r--r-- 1 root root 81165 Feb 26 15:58 lttng-probe-compaction.ko >>>> -rw-r--r-- 1 root root 333215 Feb 26 15:58 lttng-probe-ext4.ko >>>> -rw-r--r-- 1 root root 80413 Feb 26 15:58 lttng-probe-gpio.ko >>>> -rw-r--r-- 1 root root 84256 Feb 26 15:58 lttng-probe-irq.ko >>>> -rw-r--r-- 1 root root 135453 Feb 26 15:58 lttng-probe-jbd2.ko >>>> -rw-r--r-- 1 root root 105399 Feb 26 15:58 lttng-probe-kmem.ko >>>> -rw-r--r-- 1 root root 76240 Feb 26 15:58 lttng-probe-lttng.ko >>>> -rw-r--r-- 1 root root 88059 Feb 26 15:58 lttng-probe-module.ko >>>> -rw-r--r-- 1 root root 154032 Feb 26 15:58 lttng-probe-napi.ko >>>> -rw-r--r-- 1 root root 142038 Feb 26 15:58 lttng-probe-net.ko >>>> -rw-r--r-- 1 root root 93564 Feb 26 15:58 lttng-probe-power.ko >>>> -rw-r--r-- 1 root root 85530 Feb 26 15:58 lttng-probe-regulator.ko >>>> -rw-r--r-- 1 root root 138121 Feb 26 15:58 lttng-probe-sched.ko >>>> -rw-r--r-- 1 root root 152909 Feb 26 15:58 lttng-probe-scsi.ko >>>> -rw-r--r-- 1 root root 107491 Feb 26 15:58 lttng-probe-signal.ko >>>> -rw-r--r-- 1 root root 142711 Feb 26 15:58 lttng-probe-skb.ko >>>> -rw-r--r-- 1 root root 181983 Feb 26 15:58 lttng-probe-statedump.ko >>>> -rw-r--r-- 1 root root 126731 Feb 26 15:58 lttng-probe-timer.ko >>>> -rw-r--r-- 1 root root 86591 Feb 26 15:58 lttng-probe-workqueue.ko >>>> -rw-r--r-- 1 root root 133886 Feb 26 15:58 lttng-probe-writeback.ko >>>> -rw-r--r-- 1 root root 30863 Feb 26 15:58 lttng-types.ko >>>> >>>> Looking at the files shows I miss: >>>> lttng-kretprobes.ko >>>> lttng-kprobes.ko >>>> lttng-ftrace.ko >>>> lttng-probe-kvm.ko >>>> >>>> >>>> On Tue, Feb 26, 2013 at 3:56 PM, PLSTC wrote: >>>> >>>>> Back on the last email: >>>>> >>>>> Here's the insmod list I ended up building; you might not have >>>>> compiled all those modules, depending on your kernel config and on the >>>>> architecture used, so some might simply be absent from your output >>>>> directory. >>>>> >>>>> insmod /system/lib/modules/lttng-types.ko >>>>> insmod /system/lib/modules/lttng-kretprobes.ko >>>>> insmod /system/lib/modules/lttng-kprobes.ko >>>>> insmod /system/lib/modules/lttng-ftrace.ko >>>>> insmod /system/lib/modules/lttng-lib-ring-buffer.ko >>>>> insmod /system/lib/modules/lttng-statedump.ko >>>>> insmod /system/lib/modules/lttng-tracer.ko >>>>> insmod /system/lib/modules/lttng-probe-timer.ko >>>>> insmod /system/lib/modules/lttng-probe-statedump.ko >>>>> insmod /system/lib/modules/lttng-probe-signal.ko >>>>> insmod /system/lib/modules/lttng-probe-sched.ko >>>>> insmod /system/lib/modules/lttng-probe-lttng.ko >>>>> insmod /system/lib/modules/lttng-probe-kvm.ko >>>>> insmod /system/lib/modules/lttng-probe-irq.ko >>>>> insmod /system/lib/modules/lttng-probe-block.ko >>>>> insmod /system/lib/modules/lttng-ring-buffer-metadata-mmap-client.ko >>>>> insmod /system/lib/modules/lttng-ring-buffer-metadata-client.ko >>>>> insmod /system/lib/modules/lttng-ring-buffer-client-overwrite.ko >>>>> insmod /system/lib/modules/lttng-ring-buffer-client-mmap-overwrite.ko >>>>> insmod /system/lib/modules/lttng-ring-buffer-client-mmap-discard.ko >>>>> insmod /system/lib/modules/lttng-ring-buffer-client-discard.ko >>>>> >>>>> >>>>> We also haven't had time recently to test if the kprobes/kretprobes >>>>> worked, but they probably do; we decided to focus a bit more on the >>>>> 'tracepoints' aspect instead. >>>>> >>>>> Anyway, good luck with your exploration, and if you find something >>>>> interesting, I'd love to know more about it! >>>>> >>>>> -PL >>>>> >>>>> On Tue, Feb 26, 2013 at 8:06 AM, PLSTC wrote: >>>>> >>>>>> Hey Amit, >>>>>> >>>>>> Good news indeed it seems! >>>>>> >>>>>> When it comes to pushing the libs/bin, we haven't found any better >>>>>> way than using adb push yet; of course, if all the projects were included >>>>>> directly in Android's external, we would simply flash the device after each >>>>>> build, but currently we're still having trouble generating the correct >>>>>> Android makefiles. >>>>>> >>>>>> As for the modules, I might still have a dep load list somewhere I >>>>>> could send you in a few hours, I remember fighting to get the order right... >>>>>> >>>>>> Also, once everything loads, could you tell me what kind of output >>>>>> 'lttng list -k' provides you? Here, we're having trouble listing the >>>>>> 'default' kernel trace points provided by HAVE_TRACEPOINTS, and the >>>>>> returned list is simply empty (which is a bit strange). >>>>>> >>>>>> -PL >>>>>> >>>>> >>>>> >>>> >>>> >>> >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From raphael.beamonte at gmail.com Tue Mar 12 22:07:50 2013 From: raphael.beamonte at gmail.com (=?UTF-8?q?Rapha=C3=ABl=20Beamonte?=) Date: Tue, 12 Mar 2013 22:07:50 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version line in LTTng versions compiled from git sources. In-Reply-To: <513FA045.401@efficios.com> References: <513FA045.401@efficios.com> Message-ID: <963e75cf2cdaa8ccf854f3d34932d5fc1f2c1103.1363140466.git.raphael.beamonte@gmail.com> Signed-off-by: Rapha?l Beamonte --- src/bin/lttng/Makefile.am | 6 +++++- src/bin/lttng/lttng.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng/Makefile.am b/src/bin/lttng/Makefile.am index 21eebab..1b1219b 100644 --- a/src/bin/lttng/Makefile.am +++ b/src/bin/lttng/Makefile.am @@ -1,5 +1,9 @@ +git_version_string=$$(git describe --long --all 2>/dev/null) +git_version=$$(test -n "${git_version_string}" && echo "-DGIT_VERSION=\"${git_version_string}\"") + AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src \ - -DINSTALL_BIN_PATH=\""$(bindir)"\" + -DINSTALL_BIN_PATH=\""$(bindir)"\" \ + ${git_version} bin_PROGRAMS = lttng diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 8562144..28f8fec 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -81,7 +81,11 @@ static struct cmd_struct commands[] = { static void usage(FILE *ofp) { - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); + fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n"); +#ifdef GIT_VERSION + fprintf(ofp, "Git version: " GIT_VERSION"\n"); +#endif + fprintf(ofp, "\n"); fprintf(ofp, "usage: lttng [OPTIONS] []\n"); fprintf(ofp, "\n"); fprintf(ofp, "Options:\n"); -- 1.7.10.4 From raphael.beamonte at gmail.com Tue Mar 12 22:12:20 2013 From: raphael.beamonte at gmail.com (=?UTF-8?B?UmFwaGHDq2wgQmVhbW9udGU=?=) Date: Tue, 12 Mar 2013 22:12:20 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version line in LTTng versions compiled from git sources. In-Reply-To: <963e75cf2cdaa8ccf854f3d34932d5fc1f2c1103.1363140466.git.raphael.beamonte@gmail.com> References: <513FA045.401@efficios.com> <963e75cf2cdaa8ccf854f3d34932d5fc1f2c1103.1363140466.git.raphael.beamonte@gmail.com> Message-ID: <513FE084.7030405@gmail.com> Hello, This version adds a line "Git version" to "LTTng --help". The value of this line is calculated during "make" and then defined in a GIT_VERSION macro. It also works for versions without Git as it will just not define the GIT_VERSION value. The black point is that the "test" is made each time we "make" the tool. This can be corrected but I'm not sure it's necessary as this one is well working. If this patch is ok for you, I can apply an identical patch to UST and babeltrace. Rapha?l On 2013-03-12 22:07, Rapha?l Beamonte wrote: > Signed-off-by: Rapha?l Beamonte > --- > src/bin/lttng/Makefile.am | 6 +++++- > src/bin/lttng/lttng.c | 6 +++++- > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/src/bin/lttng/Makefile.am b/src/bin/lttng/Makefile.am > index 21eebab..1b1219b 100644 > --- a/src/bin/lttng/Makefile.am > +++ b/src/bin/lttng/Makefile.am > @@ -1,5 +1,9 @@ > +git_version_string=$$(git describe --long --all 2>/dev/null) > +git_version=$$(test -n "${git_version_string}" && echo "-DGIT_VERSION=\"${git_version_string}\"") > + > AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src \ > - -DINSTALL_BIN_PATH=\""$(bindir)"\" > + -DINSTALL_BIN_PATH=\""$(bindir)"\" \ > + ${git_version} > > bin_PROGRAMS = lttng > > diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c > index 8562144..28f8fec 100644 > --- a/src/bin/lttng/lttng.c > +++ b/src/bin/lttng/lttng.c > @@ -81,7 +81,11 @@ static struct cmd_struct commands[] = { > > static void usage(FILE *ofp) > { > - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); > + fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n"); > +#ifdef GIT_VERSION > + fprintf(ofp, "Git version: " GIT_VERSION"\n"); > +#endif > + fprintf(ofp, "\n"); > fprintf(ofp, "usage: lttng [OPTIONS] []\n"); > fprintf(ofp, "\n"); > fprintf(ofp, "Options:\n"); > -- Rapha?l Beamonte. Information Systems and Telecommunications Engineer (UTT, France) Specialized in Mobile Technologies and Embedded Systems M.A.Sc. Student in Computer Engineering (Polytechnique Montr?al, Canada) (33)-(0)6 10 97 27 25 - (1) 438 938-6879 - raphael.beamonte at gmail.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From raphael.beamonte at gmail.com Tue Mar 12 22:32:54 2013 From: raphael.beamonte at gmail.com (=?UTF-8?q?Rapha=C3=ABl=20Beamonte?=) Date: Tue, 12 Mar 2013 22:32:54 -0400 Subject: [lttng-dev] [lttng-tools PATCH (correction)] Add a git version line in LTTng versions compiled from git sources. In-Reply-To: <963e75cf2cdaa8ccf854f3d34932d5fc1f2c1103.1363140466.git.raphael.beamonte@gmail.com> References: <963e75cf2cdaa8ccf854f3d34932d5fc1f2c1103.1363140466.git.raphael.beamonte@gmail.com> Message-ID: <58d3a93c0b404dbea2dfa196630fae58594db08f.1363141970.git.raphael.beamonte@gmail.com> Signed-off-by: Rapha?l Beamonte --- src/bin/lttng/Makefile.am | 6 +++++- src/bin/lttng/commands/version.c | 3 +++ src/bin/lttng/lttng.c | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng/Makefile.am b/src/bin/lttng/Makefile.am index 21eebab..1b1219b 100644 --- a/src/bin/lttng/Makefile.am +++ b/src/bin/lttng/Makefile.am @@ -1,5 +1,9 @@ +git_version_string=$$(git describe --long --all 2>/dev/null) +git_version=$$(test -n "${git_version_string}" && echo "-DGIT_VERSION=\"${git_version_string}\"") + AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src \ - -DINSTALL_BIN_PATH=\""$(bindir)"\" + -DINSTALL_BIN_PATH=\""$(bindir)"\" \ + ${git_version} bin_PROGRAMS = lttng diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c index 7f69de3..6b315c5 100644 --- a/src/bin/lttng/commands/version.c +++ b/src/bin/lttng/commands/version.c @@ -79,6 +79,9 @@ int cmd_version(int argc, const char **argv) } MSG("lttng version " VERSION " - " VERSION_NAME); +#ifdef GIT_VERSION + MSG("Git version: " GIT_VERSION); +#endif MSG("\n" VERSION_DESCRIPTION "\n"); MSG("Web site: http://lttng.org"); MSG("\nlttng is free software and under the GPL license and part LGPL"); diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 8562144..28f8fec 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -81,7 +81,11 @@ static struct cmd_struct commands[] = { static void usage(FILE *ofp) { - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); + fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n"); +#ifdef GIT_VERSION + fprintf(ofp, "Git version: " GIT_VERSION"\n"); +#endif + fprintf(ofp, "\n"); fprintf(ofp, "usage: lttng [OPTIONS] []\n"); fprintf(ofp, "\n"); fprintf(ofp, "Options:\n"); -- 1.7.10.4 From mathieu.desnoyers at efficios.com Wed Mar 13 09:26:33 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 13 Mar 2013 09:26:33 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version line in LTTng versions compiled from git sources. In-Reply-To: <513FE084.7030405@gmail.com> References: <513FA045.401@efficios.com> <963e75cf2cdaa8ccf854f3d34932d5fc1f2c1103.1363140466.git.raphael.beamonte@gmail.com> <513FE084.7030405@gmail.com> Message-ID: <20130313132633.GA15843@Krystal> * Rapha?l Beamonte (raphael.beamonte at gmail.com) wrote: > Hello, > > This version adds a line "Git version" to "LTTng --help". The value of > this line is calculated during "make" and then defined in a GIT_VERSION > macro. > It also works for versions without Git as it will just not define the > GIT_VERSION value. The black point is that the "test" is made each time > we "make" the tool. This can be corrected but I'm not sure it's > necessary as this one is well working. > > If this patch is ok for you, I can apply an identical patch to UST and > babeltrace. Does the entire project needs to be rebuilt at every commit then, or just one or two files ? Thanks, Mathieu > > Rapha?l > > On 2013-03-12 22:07, Rapha?l Beamonte wrote: > > Signed-off-by: Rapha?l Beamonte > > --- > > src/bin/lttng/Makefile.am | 6 +++++- > > src/bin/lttng/lttng.c | 6 +++++- > > 2 files changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/src/bin/lttng/Makefile.am b/src/bin/lttng/Makefile.am > > index 21eebab..1b1219b 100644 > > --- a/src/bin/lttng/Makefile.am > > +++ b/src/bin/lttng/Makefile.am > > @@ -1,5 +1,9 @@ > > +git_version_string=$$(git describe --long --all 2>/dev/null) > > +git_version=$$(test -n "${git_version_string}" && echo "-DGIT_VERSION=\"${git_version_string}\"") > > + > > AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src \ > > - -DINSTALL_BIN_PATH=\""$(bindir)"\" > > + -DINSTALL_BIN_PATH=\""$(bindir)"\" \ > > + ${git_version} > > > > bin_PROGRAMS = lttng > > > > diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c > > index 8562144..28f8fec 100644 > > --- a/src/bin/lttng/lttng.c > > +++ b/src/bin/lttng/lttng.c > > @@ -81,7 +81,11 @@ static struct cmd_struct commands[] = { > > > > static void usage(FILE *ofp) > > { > > - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); > > + fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n"); > > +#ifdef GIT_VERSION > > + fprintf(ofp, "Git version: " GIT_VERSION"\n"); > > +#endif > > + fprintf(ofp, "\n"); > > fprintf(ofp, "usage: lttng [OPTIONS] []\n"); > > fprintf(ofp, "\n"); > > fprintf(ofp, "Options:\n"); > > > > > -- > Rapha?l Beamonte. > Information Systems and Telecommunications Engineer (UTT, France) > Specialized in Mobile Technologies and Embedded Systems > M.A.Sc. Student in Computer Engineering (Polytechnique Montr?al, Canada) > (33)-(0)6 10 97 27 25 - (1) 438 938-6879 - raphael.beamonte at gmail.com > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: From mathieu.desnoyers at efficios.com Wed Mar 13 10:01:52 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 13 Mar 2013 10:01:52 -0400 Subject: [lttng-dev] build error: ltt-control package In-Reply-To: <201303130125186687389@gmail.com> References: <201303130125186687389@gmail.com> Message-ID: <20130313140152.GB16186@Krystal> * OSDepend (osdepend at gmail.com) wrote: > Hi, all, > > I met some trouble when i tried to "make" the ltt-control-0.88-09242010. The code is list below: > > make[2]: Leaving directory `/usr/src/ltt-control-0.88-09242010/liblttd' > Making all in lttd > make[2]: Entering directory `/usr/src/ltt-control-0.88-09242010/lttd' > gcc -DHAVE_CONFIG_H -I.. -I.. -g -O2 -MT lttd.o -MD -MP -MF .deps/lttd.Tpo -c -o lttd.o lttd.c > mv -f .deps/lttd.Tpo .deps/lttd.Po > /bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o lttd lttd.o ../liblttd/liblttd.la -lpthread > libtool: link: gcc -g -O2 -o .libs/lttd lttd.o ../liblttd/.libs/liblttd.so -lpthread > ../liblttd/.libs/liblttd.so: undefined reference to `sync_file_range' > collect2: ld returned 1 exit status > make[2]: *** [lttd] Error 1 > make[2]: Leaving directory `/usr/src/ltt-control-0.88-09242010/lttd' > make[1]: *** [all-recursive] Error 1 > make[1]: Leaving directory `/usr/src/ltt-control-0.88-09242010' > make: *** [all] Error 2 > > My workstation is Centos 5.5, glibc-2.5. > It seems like a design bug in centos which ignore the sysycall sync_file_range, so seems the only way for me is to just delete the related code. > Is there any other way to make it through? please help me out!! I'm afraid this old LTTng 0.x version is not supported anymore. Please move to 2.x series. However, removing the sync_file_range call should keep things working. You might also want to replace that call with fdatasync() for older distros. Thanks, Mathieu > > 2013-03-13 > > > > zhengchen > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From mathieu.desnoyers at efficios.com Wed Mar 13 10:06:10 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 13 Mar 2013 10:06:10 -0400 Subject: [lttng-dev] [PATCH babeltrace 1/2] Added Python 3.0 or better requirement to the README file In-Reply-To: References: <1359640251-6133-1-git-send-email-jeremie.galarneau@efficios.com> <510BA252.3020604@gmail.com> <513E9904.2050201@gmail.com> Message-ID: <20130313140610.GC16186@Krystal> Hi Yannick, Please list all the distro and distro versions you care about that still ship with python 2.7 by default today, along with the time-frame for which they are going to still be supported by the vendors, and whether those distributions allow users to install python 3.0 side-by-side with 2.7 or not. Thanks, Mathieu * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: > Although I agree it can prove to be an inconvenience for some users, > most distributions provide a Python 3 package at this point. > > The reasoning is that since these bindings are still in development > and won't be integrated into the master branch for some time, the > effort needed to develop and test them while targeting two versions of > Python is hard to justify. > > On Mon, Mar 11, 2013 at 10:55 PM, Yannick Brosseau > wrote: > > On 2013-02-01 08:54, J?r?mie Galarneau wrote: > >> As for as I know, the bindings do work with Python 2.7. > >> However, we have decided to no longer explicitly support older > >> versions of Python in order to make the bindings, along with future > >> developments, easily maintainable. > >> > > My main concern is that 2.7 is still the default version for many linux > > distribution, so it might be early to drop 2.7 support. > > > > Yannick > > > > > > _______________________________________________ > > lttng-dev mailing list > > lttng-dev at lists.lttng.org > > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From yannick.brosseau at gmail.com Wed Mar 13 10:20:49 2013 From: yannick.brosseau at gmail.com (Yannick Brosseau) Date: Wed, 13 Mar 2013 10:20:49 -0400 Subject: [lttng-dev] [PATCH babeltrace 1/2] Added Python 3.0 or better requirement to the README file In-Reply-To: <20130313140610.GC16186@Krystal> References: <1359640251-6133-1-git-send-email-jeremie.galarneau@efficios.com> <510BA252.3020604@gmail.com> <513E9904.2050201@gmail.com> <20130313140610.GC16186@Krystal> Message-ID: <51408B41.6070809@gmail.com> On 2013-03-13 10:06, Mathieu Desnoyers wrote: > Hi Yannick, > > Please list all the distro and distro versions you care about that still > ship with python 2.7 by default today, along with the time-frame for > which they are going to still be supported by the vendors, and whether > those distributions allow users to install python 3.0 side-by-side with > 2.7 or not. Just to name 2: Centos/RHEL 6.x and Debian. CentOS/RHEL does not have a Python 3 package Debian is default to 2.7, can install python3, but will potentially breaks apps that rely on python 2 if I set python 3 to default. > Thanks, > > Mathieu > > * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: >> Although I agree it can prove to be an inconvenience for some users, >> most distributions provide a Python 3 package at this point. >> >> The reasoning is that since these bindings are still in development >> and won't be integrated into the master branch for some time, the >> effort needed to develop and test them while targeting two versions of >> Python is hard to justify. >> >> On Mon, Mar 11, 2013 at 10:55 PM, Yannick Brosseau >> wrote: >>> On 2013-02-01 08:54, J?r?mie Galarneau wrote: >>>> As for as I know, the bindings do work with Python 2.7. >>>> However, we have decided to no longer explicitly support older >>>> versions of Python in order to make the bindings, along with future >>>> developments, easily maintainable. >>>> >>> My main concern is that 2.7 is still the default version for many linux >>> distribution, so it might be early to drop 2.7 support. >>> >>> Yannick >>> >>> >>> _______________________________________________ >>> lttng-dev mailing list >>> lttng-dev at lists.lttng.org >>> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev >> _______________________________________________ >> lttng-dev mailing list >> lttng-dev at lists.lttng.org >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From mathieu.desnoyers at efficios.com Wed Mar 13 10:23:13 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 13 Mar 2013 10:23:13 -0400 Subject: [lttng-dev] [PATCH babeltrace 1/2] Added Python 3.0 or better requirement to the README file In-Reply-To: <514089E7.1080705@gmail.com> References: <1359640251-6133-1-git-send-email-jeremie.galarneau@efficios.com> <510BA252.3020604@gmail.com> <513E9904.2050201@gmail.com> <20130313140610.GC16186@Krystal> <514089E7.1080705@gmail.com> Message-ID: <20130313142313.GA16532@Krystal> * Yannick Brosseau (yannick.brosseau at gmail.com) wrote: > On 2013-03-13 10:06, Mathieu Desnoyers wrote: > > Hi Yannick, > > > > Please list all the distro and distro versions you care about that still > > ship with python 2.7 by default today, along with the time-frame for > > which they are going to still be supported by the vendors, and whether > > those distributions allow users to install python 3.0 side-by-side with > > 2.7 or not. > Just to name 2: Centos/RHEL 6.x and Debian. > > CentOS/RHEL does not have a Python 3 package > > Debian is default to 2.7, can install python3, but will potentially > breaks apps that rely on python 2 if I set python 3 to default. For our python scripts to work, do we need python 3 to be default ? About RHEL6, interesting links: http://www.muktware.com/5203/google-says-red-hat-enterprise-linux-6-obsolete Something to think about ;) J?r?mie: how much extra effort would be required to support python 2.7+ (only) as well as python 3 ? Thanks, Mathieu > > > > > Thanks, > > > > Mathieu > > > > * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: > >> Although I agree it can prove to be an inconvenience for some users, > >> most distributions provide a Python 3 package at this point. > >> > >> The reasoning is that since these bindings are still in development > >> and won't be integrated into the master branch for some time, the > >> effort needed to develop and test them while targeting two versions of > >> Python is hard to justify. > >> > >> On Mon, Mar 11, 2013 at 10:55 PM, Yannick Brosseau > >> wrote: > >>> On 2013-02-01 08:54, J?r?mie Galarneau wrote: > >>>> As for as I know, the bindings do work with Python 2.7. > >>>> However, we have decided to no longer explicitly support older > >>>> versions of Python in order to make the bindings, along with future > >>>> developments, easily maintainable. > >>>> > >>> My main concern is that 2.7 is still the default version for many linux > >>> distribution, so it might be early to drop 2.7 support. > >>> > >>> Yannick > >>> > >>> > >>> _______________________________________________ > >>> lttng-dev mailing list > >>> lttng-dev at lists.lttng.org > >>> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > >> _______________________________________________ > >> lttng-dev mailing list > >> lttng-dev at lists.lttng.org > >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From yannick.brosseau at gmail.com Wed Mar 13 10:28:18 2013 From: yannick.brosseau at gmail.com (Yannick Brosseau) Date: Wed, 13 Mar 2013 10:28:18 -0400 Subject: [lttng-dev] [PATCH babeltrace 1/2] Added Python 3.0 or better requirement to the README file In-Reply-To: <20130313142313.GA16532@Krystal> References: <1359640251-6133-1-git-send-email-jeremie.galarneau@efficios.com> <510BA252.3020604@gmail.com> <513E9904.2050201@gmail.com> <20130313140610.GC16186@Krystal> <514089E7.1080705@gmail.com> <20130313142313.GA16532@Krystal> Message-ID: <51408D02.2050205@gmail.com> On 2013-03-13 10:23, Mathieu Desnoyers wrote: > * Yannick Brosseau (yannick.brosseau at gmail.com) wrote: >> On 2013-03-13 10:06, Mathieu Desnoyers wrote: >>> Hi Yannick, >>> >>> Please list all the distro and distro versions you care about that still >>> ship with python 2.7 by default today, along with the time-frame for >>> which they are going to still be supported by the vendors, and whether >>> those distributions allow users to install python 3.0 side-by-side with >>> 2.7 or not. >> Just to name 2: Centos/RHEL 6.x and Debian. >> >> CentOS/RHEL does not have a Python 3 package >> >> Debian is default to 2.7, can install python3, but will potentially >> breaks apps that rely on python 2 if I set python 3 to default. > For our python scripts to work, do we need python 3 to be default ? > > About RHEL6, interesting links: > > http://www.muktware.com/5203/google-says-red-hat-enterprise-linux-6-obsolete > > Something to think about ;) > Google can say what they want, RHEL 6 is still widely used (RHEL 5 is still widely use...) Personnally, it don't affect me much, since debian will probably switch sooner or later, but seeing the number of request to have LTTng supported on RHEL, it might be something to think about. yannick From jeremie.galarneau at efficios.com Wed Mar 13 10:51:31 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Wed, 13 Mar 2013 10:51:31 -0400 Subject: [lttng-dev] [PATCH babeltrace 1/2] Added Python 3.0 or better requirement to the README file In-Reply-To: <20130313142313.GA16532@Krystal> References: <1359640251-6133-1-git-send-email-jeremie.galarneau@efficios.com> <510BA252.3020604@gmail.com> <513E9904.2050201@gmail.com> <20130313140610.GC16186@Krystal> <514089E7.1080705@gmail.com> <20130313142313.GA16532@Krystal> Message-ID: If I'm not mistaken, the scripts do work with Python 2.7. However, maintaining this compatibility comes with a significant development and testing overhead which I don't think brings that much value in the end. We're not talking about dropping support for tracing on RHEL here... we're talking about Python bindings which are completely optional and not part of the master branch. To me this is simply a case of handling a dependency just like any other... a package exists for most users, and RHEL users may have to install from source. I just don't see the problem. Anyway, RHEL/CentOS 6 does not even provide a Python 2.7 package... Only Python 2.6 is officially supported[1]. J?r?mie [1] http://mirror.centos.org/centos/6/os/x86_64/Packages/ On Wed, Mar 13, 2013 at 10:23 AM, Mathieu Desnoyers wrote: > * Yannick Brosseau (yannick.brosseau at gmail.com) wrote: >> On 2013-03-13 10:06, Mathieu Desnoyers wrote: >> > Hi Yannick, >> > >> > Please list all the distro and distro versions you care about that still >> > ship with python 2.7 by default today, along with the time-frame for >> > which they are going to still be supported by the vendors, and whether >> > those distributions allow users to install python 3.0 side-by-side with >> > 2.7 or not. >> Just to name 2: Centos/RHEL 6.x and Debian. >> >> CentOS/RHEL does not have a Python 3 package >> >> Debian is default to 2.7, can install python3, but will potentially >> breaks apps that rely on python 2 if I set python 3 to default. > > For our python scripts to work, do we need python 3 to be default ? > > About RHEL6, interesting links: > > http://www.muktware.com/5203/google-says-red-hat-enterprise-linux-6-obsolete > > Something to think about ;) > > J?r?mie: how much extra effort would be required to support python 2.7+ > (only) as well as python 3 ? > > Thanks, > > Mathieu > >> >> >> >> > Thanks, >> > >> > Mathieu >> > >> > * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: >> >> Although I agree it can prove to be an inconvenience for some users, >> >> most distributions provide a Python 3 package at this point. >> >> >> >> The reasoning is that since these bindings are still in development >> >> and won't be integrated into the master branch for some time, the >> >> effort needed to develop and test them while targeting two versions of >> >> Python is hard to justify. >> >> >> >> On Mon, Mar 11, 2013 at 10:55 PM, Yannick Brosseau >> >> wrote: >> >>> On 2013-02-01 08:54, J?r?mie Galarneau wrote: >> >>>> As for as I know, the bindings do work with Python 2.7. >> >>>> However, we have decided to no longer explicitly support older >> >>>> versions of Python in order to make the bindings, along with future >> >>>> developments, easily maintainable. >> >>>> >> >>> My main concern is that 2.7 is still the default version for many linux >> >>> distribution, so it might be early to drop 2.7 support. >> >>> >> >>> Yannick >> >>> >> >>> >> >>> _______________________________________________ >> >>> lttng-dev mailing list >> >>> lttng-dev at lists.lttng.org >> >>> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev >> >> _______________________________________________ >> >> lttng-dev mailing list >> >> lttng-dev at lists.lttng.org >> >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev >> > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com From christian.babeux at efficios.com Wed Mar 13 11:37:37 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Wed, 13 Mar 2013 11:37:37 -0400 Subject: [lttng-dev] [lttng-tools PATCH (correction)] Add a git version line in LTTng versions compiled from git sources. In-Reply-To: <58d3a93c0b404dbea2dfa196630fae58594db08f.1363141970.git.raphael.beamonte@gmail.com> References: <963e75cf2cdaa8ccf854f3d34932d5fc1f2c1103.1363140466.git.raphael.beamonte@gmail.com> <58d3a93c0b404dbea2dfa196630fae58594db08f.1363141970.git.raphael.beamonte@gmail.com> Message-ID: Hi Rapha?l, I wonder if we would like to also have the same information when running lttng-sessiond --version? > MSG("lttng version " VERSION " - " VERSION_NAME); > +#ifdef GIT_VERSION > + MSG("Git version: " GIT_VERSION); > +#endif > MSG("\n" VERSION_DESCRIPTION "\n"); > MSG("Web site: http://lttng.org"); > MSG("\nlttng is free software and under the GPL license and part LGPL"); Would it be possible to put such a define in a header file, perhaps config.h? I think the downside of this approach is that it would require a rebuild of all files that include config.h each time your git index is modified (commit, pull, etc.), though I'm not entirely sure of this. Thanks, Christian From dgoulet at efficios.com Wed Mar 13 11:40:18 2013 From: dgoulet at efficios.com (David Goulet) Date: Wed, 13 Mar 2013 11:40:18 -0400 Subject: [lttng-dev] [lttng-tools PATCH (correction)] Add a git version line in LTTng versions compiled from git sources. In-Reply-To: References: <963e75cf2cdaa8ccf854f3d34932d5fc1f2c1103.1363140466.git.raphael.beamonte@gmail.com> <58d3a93c0b404dbea2dfa196630fae58594db08f.1363141970.git.raphael.beamonte@gmail.com> Message-ID: <51409DE2.9030004@efficios.com> We could simply have let say "version.h" that is used for that and put into the right C files? (sessiond and lttng). David Christian Babeux: > Hi Rapha?l, > > I wonder if we would like to also have the same information when > running lttng-sessiond --version? > >> MSG("lttng version " VERSION " - " VERSION_NAME); >> +#ifdef GIT_VERSION >> + MSG("Git version: " GIT_VERSION); >> +#endif >> MSG("\n" VERSION_DESCRIPTION "\n"); >> MSG("Web site: http://lttng.org"); >> MSG("\nlttng is free software and under the GPL license and part LGPL"); > > Would it be possible to put such a define in a header file, perhaps > config.h? I think the downside of this approach is that it would > require a rebuild of all files that include config.h each time your > git index is modified (commit, pull, etc.), though I'm not entirely > sure of this. > > Thanks, > > Christian From raphael.beamonte at gmail.com Wed Mar 13 12:19:37 2013 From: raphael.beamonte at gmail.com (=?UTF-8?B?UmFwaGHDq2wgQmVhbW9udGU=?=) Date: Wed, 13 Mar 2013 12:19:37 -0400 Subject: [lttng-dev] [lttng-tools PATCH (correction)] Add a git version line in LTTng versions compiled from git sources. In-Reply-To: <51409DE2.9030004@efficios.com> References: <963e75cf2cdaa8ccf854f3d34932d5fc1f2c1103.1363140466.git.raphael.beamonte@gmail.com> <58d3a93c0b404dbea2dfa196630fae58594db08f.1363141970.git.raphael.beamonte@gmail.com> <51409DE2.9030004@efficios.com> Message-ID: <5140A719.6020003@gmail.com> On 2013-03-13 11:40, David Goulet wrote: > We could simply have let say "version.h" that is used for that and put > into the right C files? (sessiond and lttng). I agree, I was thinking about it since this morning's mail of Mathieu. A file that could be auto-generated by the "make" command if the value of the version is different from the one currently used. I'll give it a try and post a new patch. > Christian Babeux: >> I wonder if we would like to also have the same information when >> running lttng-sessiond --version? You're right, didn't think about it ! I'll add it right away. Thanks, Rapha?l -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From mathieu.desnoyers at efficios.com Wed Mar 13 12:30:30 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 13 Mar 2013 12:30:30 -0400 Subject: [lttng-dev] [urcu commit] list: implement cds_list_for_each_safe() Message-ID: <20130313163030.GA17870@Krystal> commit 7e5b9a4d1a4a63fac405ed74c42f93abdc223794 Author: Mathieu Desnoyers Date: Wed Mar 13 12:23:11 2013 -0400 list: implement cds_list_for_each_safe() Signed-off-by: Mathieu Desnoyers diff --git a/urcu/list.h b/urcu/list.h index 5d04394..1d1c7b5 100644 --- a/urcu/list.h +++ b/urcu/list.h @@ -140,12 +140,17 @@ cds_list_splice (struct cds_list_head *add, struct cds_list_head *head) #define cds_list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) +/* Iterate forward over the elements list. The list elements can be + removed from the list while doing this. */ +#define cds_list_for_each_safe(pos, p, head) \ + for (pos = (head)->next, p = pos->next; \ + pos != (head); \ + pos = p, p = pos->next) /* Iterate backward over the elements of the list. */ #define cds_list_for_each_prev(pos, head) \ for (pos = (head)->prev; pos != (head); pos = pos->prev) - /* Iterate backwards over the elements list. The list elements can be removed from the list while doing this. */ #define cds_list_for_each_prev_safe(pos, p, head) \ -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From paulmck at linux.vnet.ibm.com Wed Mar 13 12:46:18 2013 From: paulmck at linux.vnet.ibm.com (Paul E. McKenney) Date: Wed, 13 Mar 2013 09:46:18 -0700 Subject: [lttng-dev] [urcu commit] list: implement cds_list_for_each_safe() In-Reply-To: <20130313163030.GA17870@Krystal> References: <20130313163030.GA17870@Krystal> Message-ID: <20130313164618.GU3725@linux.vnet.ibm.com> On Wed, Mar 13, 2013 at 12:30:30PM -0400, Mathieu Desnoyers wrote: > commit 7e5b9a4d1a4a63fac405ed74c42f93abdc223794 > Author: Mathieu Desnoyers > Date: Wed Mar 13 12:23:11 2013 -0400 > > list: implement cds_list_for_each_safe() > > Signed-off-by: Mathieu Desnoyers Reviewed-by: Paul E. McKenney > diff --git a/urcu/list.h b/urcu/list.h > index 5d04394..1d1c7b5 100644 > --- a/urcu/list.h > +++ b/urcu/list.h > @@ -140,12 +140,17 @@ cds_list_splice (struct cds_list_head *add, struct cds_list_head *head) > #define cds_list_for_each(pos, head) \ > for (pos = (head)->next; pos != (head); pos = pos->next) > > +/* Iterate forward over the elements list. The list elements can be > + removed from the list while doing this. */ > +#define cds_list_for_each_safe(pos, p, head) \ > + for (pos = (head)->next, p = pos->next; \ > + pos != (head); \ > + pos = p, p = pos->next) > > /* Iterate backward over the elements of the list. */ > #define cds_list_for_each_prev(pos, head) \ > for (pos = (head)->prev; pos != (head); pos = pos->prev) > > - > /* Iterate backwards over the elements list. The list elements can be > removed from the list while doing this. */ > #define cds_list_for_each_prev_safe(pos, p, head) \ > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com > From raphael.beamonte at gmail.com Wed Mar 13 23:03:40 2013 From: raphael.beamonte at gmail.com (=?UTF-8?q?Rapha=C3=ABl=20Beamonte?=) Date: Wed, 13 Mar 2013 23:03:40 -0400 Subject: [lttng-dev] [PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <5140A719.6020003@gmail.com> References: <5140A719.6020003@gmail.com> Message-ID: <1363230220-11071-1-git-send-email-raphael.beamonte@gmail.com> Signed-off-by: Rapha?l Beamonte --- include/Makefile.am | 20 +++++++++++++++++++- include/lttng/version.h | 25 +++++++++++++++++++++++++ src/bin/lttng-sessiond/main.c | 5 +++++ src/bin/lttng/commands/version.c | 4 ++++ src/bin/lttng/lttng.c | 7 ++++++- 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 include/lttng/version.h diff --git a/include/Makefile.am b/include/Makefile.am index 0bcb6f9..6664813 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1 +1,19 @@ -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h +all-local: + (git_version=$$(git describe --long --all 2>/dev/null); \ + version_h=$(top_builddir)/include/lttng/version.h; \ + if [ -z "$${git_version}" ]; then \ + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \ + fi; \ + else \ + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + else \ + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + fi; \ + fi; \ + fi) + + +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h lttng/version.h diff --git a/include/lttng/version.h b/include/lttng/version.h new file mode 100644 index 0000000..42a509d --- /dev/null +++ b/include/lttng/version.h @@ -0,0 +1,25 @@ +/* + * version.h + * + * Linux Trace Toolkit version header file + * + * Copyright (C) 2013 - Rapha?l Beamonte + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef VERSION_H +#define VERSION_H + +#endif /* VERSION_H */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index f7bb53e..f0d5895 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -3547,7 +3548,11 @@ static int parse_args(int argc, char **argv) usage(); exit(EXIT_FAILURE); case 'V': +#ifdef GIT_VERSION + fprintf(stdout, "%s (Git: %s)\n", VERSION, GIT_VERSION); +#else /* GIT_VERSION */ fprintf(stdout, "%s\n", VERSION); +#endif /* GIT_VERSION */ exit(EXIT_SUCCESS); case 'S': opt_sig_parent = 1; diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c index 7f69de3..c6e9e10 100644 --- a/src/bin/lttng/commands/version.c +++ b/src/bin/lttng/commands/version.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "../command.h" @@ -79,6 +80,9 @@ int cmd_version(int argc, const char **argv) } MSG("lttng version " VERSION " - " VERSION_NAME); +#ifdef GIT_VERSION + MSG("Git version: " GIT_VERSION); +#endif MSG("\n" VERSION_DESCRIPTION "\n"); MSG("Web site: http://lttng.org"); MSG("\nlttng is free software and under the GPL license and part LGPL"); diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 8562144..e30a7c6 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -81,7 +82,11 @@ static struct cmd_struct commands[] = { static void usage(FILE *ofp) { - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); + fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n"); +#ifdef GIT_VERSION + fprintf(ofp, "Git version: " GIT_VERSION"\n"); +#endif + fprintf(ofp, "\n"); fprintf(ofp, "usage: lttng [OPTIONS] []\n"); fprintf(ofp, "\n"); fprintf(ofp, "Options:\n"); -- 1.7.10.4 From raphael.beamonte at gmail.com Wed Mar 13 23:16:17 2013 From: raphael.beamonte at gmail.com (=?UTF-8?B?UmFwaGHDq2wgQmVhbW9udGU=?=) Date: Wed, 13 Mar 2013 23:16:17 -0400 Subject: [lttng-dev] [PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <1363230220-11071-1-git-send-email-raphael.beamonte@gmail.com> References: <5140A719.6020003@gmail.com> <1363230220-11071-1-git-send-email-raphael.beamonte@gmail.com> Message-ID: <51414101.4080809@gmail.com> On 2013-03-13 23:03, Rapha?l Beamonte wrote: > Signed-off-by: Rapha?l Beamonte > --- > include/Makefile.am | 20 +++++++++++++++++++- > include/lttng/version.h | 25 +++++++++++++++++++++++++ > src/bin/lttng-sessiond/main.c | 5 +++++ > src/bin/lttng/commands/version.c | 4 ++++ > src/bin/lttng/lttng.c | 7 ++++++- > 5 files changed, 59 insertions(+), 2 deletions(-) > create mode 100644 include/lttng/version.h Ok, this is a new try. This one uses shell script in the Makefile of the include directory to verify and change (only if necessary) the value of the GIT_VERSION define. It allows the sessiond/main.c, commands/version.c and lttng.c files to be the only one to need re-compilation for versioning when the git version changes. I thought at first to put the content of the shell script in a version.sh file that would be called, but I wasn't sure the idea of calling an external shell script at make would be better that directly put the operations in the makefile. One thing I'm not sure about is that currently, the version.h needs to be versioned but perhaps should be in the .gitignore file to only save the "original" version file in the repository. There could be another solution if you think it's better : generating the version.h file with the bash script at first run. In this case, I think the version.sh shell script should perhaps be a better solution. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From yannick.brosseau at gmail.com Thu Mar 14 00:34:24 2013 From: yannick.brosseau at gmail.com (Brosseau, Yannick) Date: Thu, 14 Mar 2013 00:34:24 -0400 Subject: [lttng-dev] [PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <51414101.4080809@gmail.com> References: <5140A719.6020003@gmail.com> <1363230220-11071-1-git-send-email-raphael.beamonte@gmail.com> <51414101.4080809@gmail.com> Message-ID: > One thing I'm not sure about is that currently, the version.h needs to > be versioned but perhaps should be in the .gitignore file to only save > the "original" version file in the repository. There could be another > solution if you think it's better : generating the version.h file with > the bash script at first run. In this case, I think the version.sh shell > script should perhaps be a better solution. For that part, you should probably have a version.h.in or something similar that is the template and the version.h that is generated. A make dist should probably generate a version.h without the git version information. From raphael.beamonte at gmail.com Thu Mar 14 00:49:37 2013 From: raphael.beamonte at gmail.com (=?ISO-8859-1?Q?Rapha=EBl_Beamonte?=) Date: Thu, 14 Mar 2013 00:49:37 -0400 Subject: [lttng-dev] [PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: References: <5140A719.6020003@gmail.com> <1363230220-11071-1-git-send-email-raphael.beamonte@gmail.com> <51414101.4080809@gmail.com> Message-ID: <514156E1.6070300@gmail.com> On 2013-03-14 00:34, Brosseau, Yannick wrote: > For that part, you should probably have a version.h.in or something > similar that is the template and the version.h that is generated. Yes, that's an interesting idea. I'll look into that. > A make dist should probably generate a version.h without the git > version information. Right. I'll find a way to do that. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From dgoulet at efficios.com Thu Mar 14 12:53:07 2013 From: dgoulet at efficios.com (David Goulet) Date: Thu, 14 Mar 2013 12:53:07 -0400 Subject: [lttng-dev] [PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <1363230220-11071-1-git-send-email-raphael.beamonte@gmail.com> References: <5140A719.6020003@gmail.com> <1363230220-11071-1-git-send-email-raphael.beamonte@gmail.com> Message-ID: <51420073.7060005@efficios.com> Hey Rapha?l, This does not seems to work... I've applied your patch and recompile my git tree but version are still showing "2.1.0" ... ? Another thing, we really do prefer having #ifdef statement in one call site per binaries this means that you might want to use like "lttng-sessiond.h", put the ifdef there and do an inline function to print the correct version. Last thing, don't use spaces please! You can use extras/checkpatch.pl to make sure you are ok with the std we have. Thanks! David Rapha?l Beamonte: > Signed-off-by: Rapha?l Beamonte > --- > include/Makefile.am | 20 +++++++++++++++++++- > include/lttng/version.h | 25 +++++++++++++++++++++++++ > src/bin/lttng-sessiond/main.c | 5 +++++ > src/bin/lttng/commands/version.c | 4 ++++ > src/bin/lttng/lttng.c | 7 ++++++- > 5 files changed, 59 insertions(+), 2 deletions(-) > create mode 100644 include/lttng/version.h > > diff --git a/include/Makefile.am b/include/Makefile.am > index 0bcb6f9..6664813 100644 > --- a/include/Makefile.am > +++ b/include/Makefile.am > @@ -1 +1,19 @@ > -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h > +all-local: > + (git_version=$$(git describe --long --all 2>/dev/null); \ > + version_h=$(top_builddir)/include/lttng/version.h; \ > + if [ -z "$${git_version}" ]; then \ > + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ > + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \ > + fi; \ > + else \ > + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ > + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ > + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ > + else \ > + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ > + fi; \ > + fi; \ > + fi) > + > + > +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h lttng/version.h > diff --git a/include/lttng/version.h b/include/lttng/version.h > new file mode 100644 > index 0000000..42a509d > --- /dev/null > +++ b/include/lttng/version.h > @@ -0,0 +1,25 @@ > +/* > + * version.h > + * > + * Linux Trace Toolkit version header file > + * > + * Copyright (C) 2013 - Rapha?l Beamonte > + * > + * This library is free software; you can redistribute it and/or modify it > + * under the terms of the GNU Lesser General Public License, version 2.1 only, > + * as published by the Free Software Foundation. > + * > + * This library is distributed in the hope that it will be useful, but WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License > + * for more details. > + * > + * You should have received a copy of the GNU Lesser General Public License > + * along with this library; if not, write to the Free Software Foundation, > + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#ifndef VERSION_H > +#define VERSION_H > + > +#endif /* VERSION_H */ > diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c > index f7bb53e..f0d5895 100644 > --- a/src/bin/lttng-sessiond/main.c > +++ b/src/bin/lttng-sessiond/main.c > @@ -35,6 +35,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -3547,7 +3548,11 @@ static int parse_args(int argc, char **argv) > usage(); > exit(EXIT_FAILURE); > case 'V': > +#ifdef GIT_VERSION > + fprintf(stdout, "%s (Git: %s)\n", VERSION, GIT_VERSION); > +#else /* GIT_VERSION */ > fprintf(stdout, "%s\n", VERSION); > +#endif /* GIT_VERSION */ > exit(EXIT_SUCCESS); > case 'S': > opt_sig_parent = 1; > diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c > index 7f69de3..c6e9e10 100644 > --- a/src/bin/lttng/commands/version.c > +++ b/src/bin/lttng/commands/version.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > > #include "../command.h" > > @@ -79,6 +80,9 @@ int cmd_version(int argc, const char **argv) > } > > MSG("lttng version " VERSION " - " VERSION_NAME); > +#ifdef GIT_VERSION > + MSG("Git version: " GIT_VERSION); > +#endif > MSG("\n" VERSION_DESCRIPTION "\n"); > MSG("Web site: http://lttng.org"); > MSG("\nlttng is free software and under the GPL license and part LGPL"); > diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c > index 8562144..e30a7c6 100644 > --- a/src/bin/lttng/lttng.c > +++ b/src/bin/lttng/lttng.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > #include > > #include > @@ -81,7 +82,11 @@ static struct cmd_struct commands[] = { > > static void usage(FILE *ofp) > { > - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); > + fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n"); > +#ifdef GIT_VERSION > + fprintf(ofp, "Git version: " GIT_VERSION"\n"); > +#endif > + fprintf(ofp, "\n"); > fprintf(ofp, "usage: lttng [OPTIONS] []\n"); > fprintf(ofp, "\n"); > fprintf(ofp, "Options:\n"); From dgoulet at efficios.com Thu Mar 14 13:04:54 2013 From: dgoulet at efficios.com (David Goulet) Date: Thu, 14 Mar 2013 13:04:54 -0400 Subject: [lttng-dev] [PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <51420073.7060005@efficios.com> References: <5140A719.6020003@gmail.com> <1363230220-11071-1-git-send-email-raphael.beamonte@gmail.com> <51420073.7060005@efficios.com> Message-ID: <51420336.1070502@efficios.com> Oh wait it did create the version.h with the GIT_VERSION but I had to compile again so this header file could be used in the code. David David Goulet: > Hey Rapha?l, > > This does not seems to work... I've applied your patch and recompile my > git tree but version are still showing "2.1.0" ... ? > > Another thing, we really do prefer having #ifdef statement in one call > site per binaries this means that you might want to use like > "lttng-sessiond.h", put the ifdef there and do an inline function to > print the correct version. > > Last thing, don't use spaces please! You can use extras/checkpatch.pl to > make sure you are ok with the std we have. > > Thanks! > David > > Rapha?l Beamonte: >> Signed-off-by: Rapha?l Beamonte >> --- >> include/Makefile.am | 20 +++++++++++++++++++- >> include/lttng/version.h | 25 +++++++++++++++++++++++++ >> src/bin/lttng-sessiond/main.c | 5 +++++ >> src/bin/lttng/commands/version.c | 4 ++++ >> src/bin/lttng/lttng.c | 7 ++++++- >> 5 files changed, 59 insertions(+), 2 deletions(-) >> create mode 100644 include/lttng/version.h >> >> diff --git a/include/Makefile.am b/include/Makefile.am >> index 0bcb6f9..6664813 100644 >> --- a/include/Makefile.am >> +++ b/include/Makefile.am >> @@ -1 +1,19 @@ >> -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h >> +all-local: >> + (git_version=$$(git describe --long --all 2>/dev/null); \ >> + version_h=$(top_builddir)/include/lttng/version.h; \ >> + if [ -z "$${git_version}" ]; then \ >> + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ >> + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \ >> + fi; \ >> + else \ >> + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ >> + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ >> + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ >> + else \ >> + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ >> + fi; \ >> + fi; \ >> + fi) >> + >> + >> +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h lttng/version.h >> diff --git a/include/lttng/version.h b/include/lttng/version.h >> new file mode 100644 >> index 0000000..42a509d >> --- /dev/null >> +++ b/include/lttng/version.h >> @@ -0,0 +1,25 @@ >> +/* >> + * version.h >> + * >> + * Linux Trace Toolkit version header file >> + * >> + * Copyright (C) 2013 - Rapha?l Beamonte >> + * >> + * This library is free software; you can redistribute it and/or modify it >> + * under the terms of the GNU Lesser General Public License, version 2.1 only, >> + * as published by the Free Software Foundation. >> + * >> + * This library is distributed in the hope that it will be useful, but WITHOUT >> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or >> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License >> + * for more details. >> + * >> + * You should have received a copy of the GNU Lesser General Public License >> + * along with this library; if not, write to the Free Software Foundation, >> + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >> + */ >> + >> +#ifndef VERSION_H >> +#define VERSION_H >> + >> +#endif /* VERSION_H */ >> diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c >> index f7bb53e..f0d5895 100644 >> --- a/src/bin/lttng-sessiond/main.c >> +++ b/src/bin/lttng-sessiond/main.c >> @@ -35,6 +35,7 @@ >> #include >> #include >> #include >> +#include >> >> #include >> #include >> @@ -3547,7 +3548,11 @@ static int parse_args(int argc, char **argv) >> usage(); >> exit(EXIT_FAILURE); >> case 'V': >> +#ifdef GIT_VERSION >> + fprintf(stdout, "%s (Git: %s)\n", VERSION, GIT_VERSION); >> +#else /* GIT_VERSION */ >> fprintf(stdout, "%s\n", VERSION); >> +#endif /* GIT_VERSION */ >> exit(EXIT_SUCCESS); >> case 'S': >> opt_sig_parent = 1; >> diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c >> index 7f69de3..c6e9e10 100644 >> --- a/src/bin/lttng/commands/version.c >> +++ b/src/bin/lttng/commands/version.c >> @@ -24,6 +24,7 @@ >> #include >> #include >> #include >> +#include >> >> #include "../command.h" >> >> @@ -79,6 +80,9 @@ int cmd_version(int argc, const char **argv) >> } >> >> MSG("lttng version " VERSION " - " VERSION_NAME); >> +#ifdef GIT_VERSION >> + MSG("Git version: " GIT_VERSION); >> +#endif >> MSG("\n" VERSION_DESCRIPTION "\n"); >> MSG("Web site: http://lttng.org"); >> MSG("\nlttng is free software and under the GPL license and part LGPL"); >> diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c >> index 8562144..e30a7c6 100644 >> --- a/src/bin/lttng/lttng.c >> +++ b/src/bin/lttng/lttng.c >> @@ -25,6 +25,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #include >> @@ -81,7 +82,11 @@ static struct cmd_struct commands[] = { >> >> static void usage(FILE *ofp) >> { >> - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); >> + fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n"); >> +#ifdef GIT_VERSION >> + fprintf(ofp, "Git version: " GIT_VERSION"\n"); >> +#endif >> + fprintf(ofp, "\n"); >> fprintf(ofp, "usage: lttng [OPTIONS] []\n"); >> fprintf(ofp, "\n"); >> fprintf(ofp, "Options:\n"); > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From yannick.brosseau at gmail.com Thu Mar 14 13:15:07 2013 From: yannick.brosseau at gmail.com (Yannick Brosseau) Date: Thu, 14 Mar 2013 13:15:07 -0400 Subject: [lttng-dev] [PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <51420336.1070502@efficios.com> References: <5140A719.6020003@gmail.com> <1363230220-11071-1-git-send-email-raphael.beamonte@gmail.com> <51420073.7060005@efficios.com> <51420336.1070502@efficios.com> Message-ID: <5142059B.7050708@gmail.com> I think this method is really sensible on the execution order of the makefile. Maybe it should be put at the top level. On 2013-03-14 13:04, David Goulet wrote: > Oh wait it did create the version.h with the GIT_VERSION but I had to > compile again so this header file could be used in the code. > > David > > David Goulet: >> Hey Rapha?l, >> >> This does not seems to work... I've applied your patch and recompile my >> git tree but version are still showing "2.1.0" ... ? >> >> Another thing, we really do prefer having #ifdef statement in one call >> site per binaries this means that you might want to use like >> "lttng-sessiond.h", put the ifdef there and do an inline function to >> print the correct version. >> >> Last thing, don't use spaces please! You can use extras/checkpatch.pl to >> make sure you are ok with the std we have. >> >> Thanks! >> David >> >> Rapha?l Beamonte: >>> Signed-off-by: Rapha?l Beamonte >>> --- >>> include/Makefile.am | 20 +++++++++++++++++++- >>> include/lttng/version.h | 25 +++++++++++++++++++++++++ >>> src/bin/lttng-sessiond/main.c | 5 +++++ >>> src/bin/lttng/commands/version.c | 4 ++++ >>> src/bin/lttng/lttng.c | 7 ++++++- >>> 5 files changed, 59 insertions(+), 2 deletions(-) >>> create mode 100644 include/lttng/version.h >>> >>> diff --git a/include/Makefile.am b/include/Makefile.am >>> index 0bcb6f9..6664813 100644 >>> --- a/include/Makefile.am >>> +++ b/include/Makefile.am >>> @@ -1 +1,19 @@ >>> -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h >>> +all-local: >>> + (git_version=$$(git describe --long --all 2>/dev/null); \ >>> + version_h=$(top_builddir)/include/lttng/version.h; \ >>> + if [ -z "$${git_version}" ]; then \ >>> + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ >>> + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \ >>> + fi; \ >>> + else \ >>> + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ >>> + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ >>> + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ >>> + else \ >>> + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ >>> + fi; \ >>> + fi; \ >>> + fi) >>> + >>> + >>> +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h lttng/version.h >>> diff --git a/include/lttng/version.h b/include/lttng/version.h >>> new file mode 100644 >>> index 0000000..42a509d >>> --- /dev/null >>> +++ b/include/lttng/version.h >>> @@ -0,0 +1,25 @@ >>> +/* >>> + * version.h >>> + * >>> + * Linux Trace Toolkit version header file >>> + * >>> + * Copyright (C) 2013 - Rapha?l Beamonte >>> + * >>> + * This library is free software; you can redistribute it and/or modify it >>> + * under the terms of the GNU Lesser General Public License, version 2.1 only, >>> + * as published by the Free Software Foundation. >>> + * >>> + * This library is distributed in the hope that it will be useful, but WITHOUT >>> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or >>> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License >>> + * for more details. >>> + * >>> + * You should have received a copy of the GNU Lesser General Public License >>> + * along with this library; if not, write to the Free Software Foundation, >>> + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >>> + */ >>> + >>> +#ifndef VERSION_H >>> +#define VERSION_H >>> + >>> +#endif /* VERSION_H */ >>> diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c >>> index f7bb53e..f0d5895 100644 >>> --- a/src/bin/lttng-sessiond/main.c >>> +++ b/src/bin/lttng-sessiond/main.c >>> @@ -35,6 +35,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> >>> #include >>> #include >>> @@ -3547,7 +3548,11 @@ static int parse_args(int argc, char **argv) >>> usage(); >>> exit(EXIT_FAILURE); >>> case 'V': >>> +#ifdef GIT_VERSION >>> + fprintf(stdout, "%s (Git: %s)\n", VERSION, GIT_VERSION); >>> +#else /* GIT_VERSION */ >>> fprintf(stdout, "%s\n", VERSION); >>> +#endif /* GIT_VERSION */ >>> exit(EXIT_SUCCESS); >>> case 'S': >>> opt_sig_parent = 1; >>> diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c >>> index 7f69de3..c6e9e10 100644 >>> --- a/src/bin/lttng/commands/version.c >>> +++ b/src/bin/lttng/commands/version.c >>> @@ -24,6 +24,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> >>> #include "../command.h" >>> >>> @@ -79,6 +80,9 @@ int cmd_version(int argc, const char **argv) >>> } >>> >>> MSG("lttng version " VERSION " - " VERSION_NAME); >>> +#ifdef GIT_VERSION >>> + MSG("Git version: " GIT_VERSION); >>> +#endif >>> MSG("\n" VERSION_DESCRIPTION "\n"); >>> MSG("Web site: http://lttng.org"); >>> MSG("\nlttng is free software and under the GPL license and part LGPL"); >>> diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c >>> index 8562144..e30a7c6 100644 >>> --- a/src/bin/lttng/lttng.c >>> +++ b/src/bin/lttng/lttng.c >>> @@ -25,6 +25,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> #include >>> >>> #include >>> @@ -81,7 +82,11 @@ static struct cmd_struct commands[] = { >>> >>> static void usage(FILE *ofp) >>> { >>> - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); >>> + fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n"); >>> +#ifdef GIT_VERSION >>> + fprintf(ofp, "Git version: " GIT_VERSION"\n"); >>> +#endif >>> + fprintf(ofp, "\n"); >>> fprintf(ofp, "usage: lttng [OPTIONS] []\n"); >>> fprintf(ofp, "\n"); >>> fprintf(ofp, "Options:\n"); >> _______________________________________________ >> lttng-dev mailing list >> lttng-dev at lists.lttng.org >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From raphael.beamonte at gmail.com Thu Mar 14 14:50:58 2013 From: raphael.beamonte at gmail.com (=?UTF-8?B?UmFwaGHDq2wgQmVhbW9udGU=?=) Date: Thu, 14 Mar 2013 14:50:58 -0400 Subject: [lttng-dev] [PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <5142059B.7050708@gmail.com> References: <5140A719.6020003@gmail.com> <1363230220-11071-1-git-send-email-raphael.beamonte@gmail.com> <51420073.7060005@efficios.com> <51420336.1070502@efficios.com> <5142059B.7050708@gmail.com> Message-ID: <51421C12.5050907@gmail.com> On 2013-03-14 12:53, David Goulet wrote: > Another thing, we really do prefer having #ifdef statement in one call > site per binaries this means that you might want to use like > "lttng-sessiond.h", put the ifdef there and do an inline function to > print the correct version. Ok, no problem ! Will be like that in the next try of the patch. > Last thing, don't use spaces please! You can use extras/checkpatch.pl to > make sure you are ok with the std we have. Sorry, copy/paste mistake. I'll correct that. On 2013-03-14 13:04, David Goulet wrote: > Oh wait it did create the version.h with the GIT_VERSION but I had to > compile again so this header file could be used in the code. Thanks for reporting that. Didn't see it at first ! On 2013-03-14 13:15, Yannick Brosseau wrote: > I think this method is really sensible on the execution order of the > makefile. Maybe it should be put at the top level. Right, I'll do that. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From christian.babeux at efficios.com Thu Mar 14 22:22:57 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Thu, 14 Mar 2013 22:22:57 -0400 Subject: [lttng-dev] LTTng & Google Summer of Code 2013 In-Reply-To: References: Message-ID: Hi lttng-droids, As a follow up to the initial discussion, here is the detailed ideas list for the proposition for GSoC 2013: http://bugs.lttng.org/projects/lttng/wiki/Google_Summer_of_Code_2013 Feedback and corrections are quite welcome! Thanks, Christian On Fri, Feb 1, 2013 at 11:39 AM, Christian Babeux wrote: > Hi everyone, > > After some initial discussion with the LTTng developers, we think it > would be a great opportunity for the LTTng project to participate as a > mentoring organisation in Google Summer of Code 2013. > > Apparently, some attempts were made in the past years but the > application deadline was missed by a few picoseconds ;). > > Here are some of the requirements for a mentoring organisation application [1]: > > " > What is the URL for your Ideas page? > What is the main development mailing list for your organization? > What is the main IRC channel for your organization? > Does your organization have an application template you would like to > see students use? If so, please provide it now. > " > > One of the *most* important point of this list is to have an idea > pages/list ready for the application. > > Here are some projects ideas that a student or intern could > accomplish within the scope of Google Summer of Code: > > - Continue the Android port of LTTng > - Continue the work done on Python bindings for babeltrace/lttng-tools. > - Trace probe support in C++ [2]. > - A meta-command support in lttng-tools (ex: lttng --trace, see [3]). > - Improve the liblttng-ust-libc-wrapper with additionnal libc functions support. > - LTTV features. > - Implement syscalls on other architectures (maybe not relevant, see [4]) > - Hook the trace/debug infrastructure of Wine in UST. > - Etc. > > So I'm asking the community for feedback and ideas to get this > application going! > > Thanks, > > Christian > > [1] - https://www.google-melange.com/document/show/gsoc_program/google/gsoc2012/faqs#mentoring_apply > [2] - http://bugs.lttng.org/issues/338 > [3] - http://bugs.lttng.org/issues/15 > [4] - http://bugs.lttng.org/issues/33 From fdeslaur at gmail.com Thu Mar 14 20:25:32 2013 From: fdeslaur at gmail.com (Francis Deslauriers) Date: Thu, 14 Mar 2013 20:25:32 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions Message-ID: Hi, I am currently working on adding trap tracepoints in the kernel. As of now, i have an implementation of the tracepoints trap_entry and trap_exit. I have created a LTTng probe for those events as well. It would really be appreciated that you, LTTng guys, can give me your comments about my work already done. It would also be great if some of you could test it during a "not so short" amount of time, so we could perhaps propose the patches to add these tracepoints in the mainline kernel after having tested them properly. I will first send a patch concerning the implementation of the tracepoints. This will be followed by a lttng-modules patch adding the LTTng trap probe. Finally, i will send a patch about the locations of the tracepoints in the kernel itself. Feel free to give general comments and critics in reply of this email, and specific comments in reply to the patches they apply to. Thanks, Francis Deslauriers -------------- next part -------------- An HTML attachment was scrubbed... URL: From fdeslaur at gmail.com Thu Mar 14 20:26:32 2013 From: fdeslaur at gmail.com (Francis Deslauriers) Date: Thu, 14 Mar 2013 20:26:32 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: References: Message-ID: <1363307192-14522-1-git-send-email-fdeslaur@gmail.com> This patch adds new trap tracepoint definitions. Both trap entry and trap exit tracepoints can be added. Signed-off-by: Francis Deslauriers --- include/trace/events/trap.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 include/trace/events/trap.h diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h new file mode 100644 index 0000000..869c512 --- /dev/null +++ b/include/trace/events/trap.h @@ -0,0 +1,39 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM trap + +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TRAP_H + +#include + +DECLARE_EVENT_CLASS(trap, + TP_PROTO(int trap_nb), + + TP_ARGS(trap_nb), + + TP_STRUCT__entry( + __field( int, trap_nb ) + ), + TP_fast_assign( + __entry->trap_nb = trap_nb; +), + + TP_printk("number=%d", __entry->trap_nb) +); + +DEFINE_EVENT(trap, trap_entry, + + TP_PROTO(int trap_nb), + + TP_ARGS(trap_nb) +); +DEFINE_EVENT(trap, trap_exit, + + TP_PROTO(int trap_nb), + + TP_ARGS(trap_nb) +); + +#endif /* _TRACE_TRAP_H */ +/* This part must be outside protection */ +#include -- 1.7.10.4 From yao at codesourcery.com Fri Mar 15 05:52:17 2013 From: yao at codesourcery.com (Yao Qi) Date: Fri, 15 Mar 2013 17:52:17 +0800 Subject: [lttng-dev] [PATCH] Teach babeltrace understand "native" and "network" for byte_order Message-ID: <1363341137-26956-1-git-send-email-yao@codesourcery.com> Hi, We wrote byte_order in metadata either "le" or "be", according to the host endianness. Today, when I check the ctf specification, I find "native" fits our needs well. However, after I replace "le" with "native" in metadata, I got the following error message: [error] get_trace_byte_order: unexpected string "native". Should be "native", "network", "be" or "le". This patch teaches babeltrace understand "native" and "network". With this patch applied, the output looks right now. Let me know if I need run testsuite, and how. Signed-off-by: Yao Qi --- .../ctf/metadata/ctf-visitor-generate-io-struct.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c index 9bcc170..cea2877 100644 --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c @@ -1227,6 +1227,10 @@ int get_trace_byte_order(FILE *fd, int depth, struct ctf_node *unary_expression) byte_order = BIG_ENDIAN; else if (!strcmp(unary_expression->u.unary_expression.u.string, "le")) byte_order = LITTLE_ENDIAN; + else if (!strcmp(unary_expression->u.unary_expression.u.string, "native")) + byte_order = BYTE_ORDER; + else if (!strcmp(unary_expression->u.unary_expression.u.string, "network")) + byte_order = BIG_ENDIAN; else { fprintf(fd, "[error] %s: unexpected string \"%s\". Should be \"be\" or \"le\".\n", __func__, unary_expression->u.unary_expression.u.string); -- 1.7.7.6 From mathieu.desnoyers at efficios.com Fri Mar 15 08:07:53 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Fri, 15 Mar 2013 08:07:53 -0400 Subject: [lttng-dev] [PATCH] Teach babeltrace understand "native" and "network" for byte_order In-Reply-To: <1363341137-26956-1-git-send-email-yao@codesourcery.com> References: <1363341137-26956-1-git-send-email-yao@codesourcery.com> Message-ID: <20130315120753.GA30973@Krystal> * Yao Qi (yao at codesourcery.com) wrote: > Hi, > We wrote byte_order in metadata either "le" or "be", according to the > host endianness. Today, when I check the ctf specification, I find > "native" fits our needs well. However, after I replace "le" with > "native" in metadata, I got the following error message: > > [error] get_trace_byte_order: unexpected string "native". Should be "native", "network", "be" or "le". > > This patch teaches babeltrace understand "native" and "network". With > this patch applied, the output looks right now. Let me know if I need > run testsuite, and how. your interpretation of what the byte order should accept is based on section 4.1.3 of the CTF spec, which discusses what byte order can be accepted by a type. However, here you are proposing to change the byte order recognised at the trace declaration level. Unfortunately, we cannot assume anything about native endianness of the traced machine until we have the endianness information at the trace declaration level, as the trace can come from any source. Possibly that the CTF spec would need to be clarified. Currently, we need to look at: 7.4 TSDL Examples trace { ... byte_order = be OR le; /* Endianness (required) */ ... }; to understand that only be and le should be expected in the trace description. Thoughts ? Thanks, Mathieu > > Signed-off-by: Yao Qi > --- > .../ctf/metadata/ctf-visitor-generate-io-struct.c | 4 ++++ > 1 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c > index 9bcc170..cea2877 100644 > --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c > +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c > @@ -1227,6 +1227,10 @@ int get_trace_byte_order(FILE *fd, int depth, struct ctf_node *unary_expression) > byte_order = BIG_ENDIAN; > else if (!strcmp(unary_expression->u.unary_expression.u.string, "le")) > byte_order = LITTLE_ENDIAN; > + else if (!strcmp(unary_expression->u.unary_expression.u.string, "native")) > + byte_order = BYTE_ORDER; > + else if (!strcmp(unary_expression->u.unary_expression.u.string, "network")) > + byte_order = BIG_ENDIAN; > else { > fprintf(fd, "[error] %s: unexpected string \"%s\". Should be \"be\" or \"le\".\n", > __func__, unary_expression->u.unary_expression.u.string); > -- > 1.7.7.6 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From mathieu.desnoyers at efficios.com Fri Mar 15 09:08:09 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Fri, 15 Mar 2013 09:08:09 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: <1363307192-14522-1-git-send-email-fdeslaur@gmail.com> References: <1363307192-14522-1-git-send-email-fdeslaur@gmail.com> Message-ID: <20130315130809.GA31329@Krystal> * Francis Deslauriers (fdeslaur at gmail.com) wrote: > This patch adds new trap tracepoint definitions. Both trap entry and trap exit > tracepoints can be added. > > Signed-off-by: Francis Deslauriers > --- > include/trace/events/trap.h | 39 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 39 insertions(+) > create mode 100644 include/trace/events/trap.h > > diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h > new file mode 100644 > index 0000000..869c512 > --- /dev/null > +++ b/include/trace/events/trap.h > @@ -0,0 +1,39 @@ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM trap > + > +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_TRAP_H > + > +#include > + > +DECLARE_EVENT_CLASS(trap, > + TP_PROTO(int trap_nb), > + > + TP_ARGS(trap_nb), you might want TP_PROTO(struct pt_regs *regs, long trap); why trap instead of trap_nb: based on include/trace/events/irq.h. "irq" is used and not "irq_nb". Why long instead of int ? Because s390 represents its trap number in a long. why having the regs there ? It's the context of the trap, was passed as parameter to the original lttng 0.x patchset. See https://git.lttng.org/?p=linux-2.6-lttng.git;a=shortlog;h=refs/heads/2.6.38.6-lttng-0.249 > + > + TP_STRUCT__entry( > + __field( int, trap_nb ) Please split entry and exit events into two different event (without class). And add, for entry: __field( unsigned long, ip) > + ), > + TP_fast_assign( > + __entry->trap_nb = trap_nb; entry: __entry->ip = regs ? instruction_pointer(regs) : 0UL; This would be a good generic starting point to make the trap instrumentation useful. In a later step, this will allow us to dump all registers if need be as we specialize the trap header on a per-architecture basis. But this should come later: let's start simple, get the entire chain working and push the feature into mainline Linux, and only then expand if necessary. With the "ip" field, we'd get the same feature set as lttng 0.x, see e.g. https://git.lttng.org/?p=lttng-modules.git;a=blob;f=probes/trap-trace.c;h=397254cd700779b3333d7593c33f9660eec2ffc5;hb=refs/heads/v0.19-stable Thanks, Mathieu > +), > + > + TP_printk("number=%d", __entry->trap_nb) > +); > + > +DEFINE_EVENT(trap, trap_entry, > + > + TP_PROTO(int trap_nb), > + > + TP_ARGS(trap_nb) > +); > +DEFINE_EVENT(trap, trap_exit, > + > + TP_PROTO(int trap_nb), > + > + TP_ARGS(trap_nb) > +); > + > +#endif /* _TRACE_TRAP_H */ > +/* This part must be outside protection */ > +#include > -- > 1.7.10.4 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From mathieu.desnoyers at efficios.com Fri Mar 15 10:33:37 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Fri, 15 Mar 2013 10:33:37 -0400 Subject: [lttng-dev] [PATCH] Teach babeltrace understand "native" and "network" for byte_order In-Reply-To: <20130315120753.GA30973@Krystal> References: <1363341137-26956-1-git-send-email-yao@codesourcery.com> <20130315120753.GA30973@Krystal> Message-ID: <20130315143337.GA959@Krystal> * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote: > * Yao Qi (yao at codesourcery.com) wrote: > > Hi, > > We wrote byte_order in metadata either "le" or "be", according to the > > host endianness. Today, when I check the ctf specification, I find > > "native" fits our needs well. However, after I replace "le" with > > "native" in metadata, I got the following error message: > > > > [error] get_trace_byte_order: unexpected string "native". Should be "native", "network", "be" or "le". > > > > This patch teaches babeltrace understand "native" and "network". With > > this patch applied, the output looks right now. Let me know if I need > > run testsuite, and how. > > your interpretation of what the byte order should accept is based on > section 4.1.3 of the CTF spec, which discusses what byte order can be > accepted by a type. > > However, here you are proposing to change the byte order recognised at > the trace declaration level. Unfortunately, we cannot assume anything > about native endianness of the traced machine until we have the > endianness information at the trace declaration level, as the trace can > come from any source. > > Possibly that the CTF spec would need to be clarified. Currently, we > need to look at: > > 7.4 TSDL Examples > > trace { > ... > byte_order = be OR le; /* Endianness (required) */ > ... > }; > > to understand that only be and le should be expected in the trace > description. > > Thoughts ? Clarified with CTF commit: commit 7e58b8bfd86eea7b2929f2ee37dad7e167e11500 Author: Mathieu Desnoyers Date: Fri Mar 15 10:31:37 2013 -0400 Clarify trace byte_order Signed-off-by: Mathieu Desnoyers diff --git a/common-trace-format-specification.txt b/common-trace-format-specification.txt index 1cd3c3d..4ab3ed9 100644 --- a/common-trace-format-specification.txt +++ b/common-trace-format-specification.txt @@ -181,6 +181,11 @@ TSDL meta-data representation: byte_order = native OR network OR be OR le; /* network and be are aliases */ +Even though the trace description section is not per se a type, for sake +of clarity, it should be noted that native and network byte orders are +only allowed within type declaration. The byte_order specified in the +trace description section only accepts be OR le values. + 4.1.4 Size Type size, in bits, for integers and floats is that returned by "sizeof()" in C > > Thanks, > > Mathieu > > > > > Signed-off-by: Yao Qi > > --- > > .../ctf/metadata/ctf-visitor-generate-io-struct.c | 4 ++++ > > 1 files changed, 4 insertions(+), 0 deletions(-) > > > > diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c > > index 9bcc170..cea2877 100644 > > --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c > > +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c > > @@ -1227,6 +1227,10 @@ int get_trace_byte_order(FILE *fd, int depth, struct ctf_node *unary_expression) > > byte_order = BIG_ENDIAN; > > else if (!strcmp(unary_expression->u.unary_expression.u.string, "le")) > > byte_order = LITTLE_ENDIAN; > > + else if (!strcmp(unary_expression->u.unary_expression.u.string, "native")) > > + byte_order = BYTE_ORDER; > > + else if (!strcmp(unary_expression->u.unary_expression.u.string, "network")) > > + byte_order = BIG_ENDIAN; > > else { > > fprintf(fd, "[error] %s: unexpected string \"%s\". Should be \"be\" or \"le\".\n", > > __func__, unary_expression->u.unary_expression.u.string); > > -- > > 1.7.7.6 > > > > > > _______________________________________________ > > lttng-dev mailing list > > lttng-dev at lists.lttng.org > > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From pierre-luc.st-charles at polymtl.ca Fri Mar 15 10:33:49 2013 From: pierre-luc.st-charles at polymtl.ca (Pierre-Luc St-Charles) Date: Fri, 15 Mar 2013 10:33:49 -0400 Subject: [lttng-dev] Fwd: compiling LTTng for android In-Reply-To: References: Message-ID: Good news! After peeking yesterday through the different glibc/SysV implementations (wrappers...) of splice I could find, I realized that those are not actually necessary for what we intend to do: from what I found out, they only redefine/wrap/redeclare the sys_splice system call that's implemented directly in the kernel (in any architecture). Considering we don't need anything more than the default (kernel-space) splice, we can simply rewire the 'splice' declaration we use/have to syscall(__NR_splice,...), just like what was needed for epoll_create1 earlier. For example : (doing this from memory... I don't have access to the code atm) > in src/common/compat/fcntl.h, inside the linux ifdef, top of the file: #ifdef __ANDROID__ #define SPLICE_F_MOVE 0x01 #define SPLICE_F_NONBLOCK 0x02 #define SPLICE_F_MORE 0x04 #define SPLICE_F_GIFT 0x08 static inline ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) { return syscall(__NR_splice,fd_in,loff_in,fd_out,loff_out,len,flags); } #endif Result? Boom, traces. The rest of the project seems to work without any other visible problem, and we can finally obtain traces when asking the tools nicely. In fact, we can obtain traces from any device without even having to modify the kernel/system image at all (except to add module and tracepoints support, which should already be there), which is pretty surprising, but also very useful, considering we can just ship the required binaries anywhere and start tracing. Once we confirm that the traces are actually good and we haven't broken anything else (we're still not sure liburcu works 100%, we're trying to run all the tests), we'll start sending in results for anyone who might be interested. - PL On Tue, Mar 12, 2013 at 6:51 PM, Pierre-Luc St-Charles < pierre-luc.st-charles at polymtl.ca> wrote: > Hey Amit, > > Here's a small update on my latest findings regarding the broken *splice* > / bad Bionic impl problem: > > Although it didn't really cross my mind earlier, we had seen this exact > problem before, but in another project; we had also investigated a bit at > the time, but to no avail. It seems the issue is known by the > Android/Bionic community, but it's simply not on their immediate todo list > (and hasn't been for at least the past two years -- see > https://code.google.com/p/android/issues/detail?id=11330). The solutions > we are now considering are: adding splice support (and whatever else might > also be needed) to Bionic ourselves (saving BILLIONS of broken lives in the > process, IF the changes are accepted), or simply inserting glibc (and > building against it) in our device images. > > In the next few days, we'll be studying how much time the first solution > would actually take (as we're not really experts in that domain at all), > but considering the nature/objective of this project, it might be the > wisest decision (as it would not require too much swerving away from the > default images people have on their devices for LTTng to actually work). If > we deem it 'impossible/out of our league', we'll simply try to get a > working tool asap using glibc, which should not be very complicated itself > (many people have actually successfully done it before). > > In any case, I'll keep you updated, and I'll also post any big updates on > the mailing list. > > -PL > > On Wed, Mar 6, 2013 at 8:04 PM, Pierre-Luc St-Charles < > pierre-luc.st-charles at polymtl.ca> wrote: > >> Great findings! >> >> I'll also try to look into this new problem by next monday; I'm falling a >> bit behind on my 'investigations', but I'll keep you updated if anything >> comes up. >> >> -PL >> On Mar 6, 2013 6:09 PM, "Amit Balboul" wrote: >> >>> Hi All, >>> >>> Regarding the last mail about tracing system calls on Android using >>> LTTng, >>> The issue of not receiving enabled event to trace from the kernel can be >>> fixed patching src/bin/lttng-sessiond/kernel.c (patch attached) >>> In the function *kernel_list_events,* fscanf-ing the events exported by >>> the kernel using the fp must not use the syntax *%m* as it is obsolete >>> (in Android), >>> thus the fscanf returns 0 and won't read the kernel events (first >>> condition false). >>> Instead I use a pre-allocated buffer for the string and use the *%[^;]*syntax, and omitting the memory free (attached is the patch). >>> >>> The resulting output is (sessiond is run with verbose debug prints): >>> >>> root at android:/data/lttng/bin # *./lttng list -k* >>> DEBUG1 [10239/10290]: Wait for client response (in >>> thread_manage_clients() at main.c:3242) >>> DEBUG1 [10239/10290]: Receiving data from client ... (in >>> thread_manage_clients() at main.c:3287) >>> DEBUG1 [10239/10290]: Nothing recv() from client... continuing (in >>> thread_manage_clients() at main.c:3291) >>> DEBUG1 [10239/10290]: Clean command context structure (in >>> clean_command_ctx() at main.c:482) >>> DEBUG1 [10239/10290]: Accepting client command ... (in >>> thread_manage_clients() at main.c:3200) >>> DEBUG1 [10239/10290]: Wait for client response (in >>> thread_manage_clients() at main.c:3242) >>> DEBUG1 [10239/10290]: Receiving data from client ... (in >>> thread_manage_clients() at main.c:3287) >>> DEBUG1 [10239/10290]: Processing client command 14 (in >>> process_client_msg() at main.c:2227) >>> DEBUG1 [10239/10290]: Kernel list events done (61 events) (in >>> kernel_list_events() at kernel.c:653) >>> DEBUG1 [10239/10290]: Sending response (size: 35640, retcode: Success) >>> (in thread_manage_clients() at main.c:3338) >>> DEBUG1 [10239/10290]: Clean command context structure (in >>> clean_command_ctx() at main.c:482) >>> DEBUG1 [10239/10290]: Accepting client command ... (in >>> thread_manage_clients() at main.c:3200) >>> Kernel events: >>> ------------- >>> block_rq_abort (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_rq_requeue (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_rq_complete (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_rq_insert (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_rq_issue (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_bio_bounce (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_bio_complete (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_bio_backmerge (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_bio_frontmerge (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_bio_queue (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_getrq (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_sleeprq (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_plug (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_unplug (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_split (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> irq_handler_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> irq_handler_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> softirq_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> softirq_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> softirq_raise (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: >>> tracepoint) >>> sched_wakeup (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_switch (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_migrate_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_process_free (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_process_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_wait_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_process_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_process_fork (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_stat_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_stat_sleep (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_stat_iowait (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_stat_runtime (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> sched_pi_setprio (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> signal_generate (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> signal_deliver (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> signal_overflow_fail (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> signal_lose_info (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> lttng_statedump_start (loglevel: TRACE_EMERG (0)) (type: >>> tracepoint) >>> lttng_statedump_end (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> lttng_statedump_process_state (loglevel: TRACE_EMERG (0)) (type: >>> tracepoint) >>> lttng_statedump_file_descriptor (loglevel: TRACE_EMERG (0)) (type: >>> tracepoint) >>> lttng_statedump_vm_map (loglevel: TRACE_EMERG (0)) (type: >>> tracepoint) >>> lttng_statedump_network_interface (loglevel: TRACE_EMERG (0)) >>> (type: tracepoint) >>> lttng_statedump_interrupt (loglevel: TRACE_EMERG (0)) (type: >>> tracepoint) >>> timer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> timer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> timer_expire_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> timer_expire_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> timer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> hrtimer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> hrtimer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> hrtimer_expire_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> hrtimer_expire_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> hrtimer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> itimer_state (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> itimer_expire (loglevel: TRACE_EMERG (0)) (type: tracepoint) >>> >>> root at android:/data/lttng/bin # >>> >>> Now I'm facing the issue of starting the traces: >>> debugging the sessiond, consumerd and lttng I concluded that the issue >>> is due to splice system call failure. >>> even using a MMAP output type channel, the metadata channel is SPLICE >>> type (hard-coded). >>> Problem persists also when using relayd to pass the traces through the >>> network. >>> Ignoring the splice failure means closing of the metadata channel >>> (maybe??) but need not affect the traces channel (right ?) >>> Attached is a debug log of each thread of the sessiond, right after >>> invoking "*./lttng start*". (with extra informative my prints) >>> >>> Please keep me in touch with any progress in this issue, >>> Thank you, >>> Amit. >>> >>> >>> >>> >>> >>> >>> ---------- Forwarded message ---------- >>> From: Amit Balboul >>> Date: Wed, Feb 27, 2013 at 4:37 PM >>> Subject: Re: [lttng-dev] compiling LTTng for android >>> To: PLSTC >>> >>> >>> Hey Pierre, >>> >>> Some major progress has been achieved, following is the summary: >>> >>> 1. Modules issue: >>> I built (for ARM/Android) and installed latest stable version of busybox >>> on the device. >>> Seeing the code tries to run (hardcoded) /sbin/modprobe, made a soft >>> link to busybox's modeprobe. >>> Also, created /lib/modules/ directory and pushed the >>> directory from /lib/modules on the machine. >>> Now session daemon modprobes the desired modules successfully, (some are >>> not present though as mentioned before) - no need to use insmod. >>> >>> 2. epoll_create1 issue: >>> epoll_create1 patch was OK, I accidentally defined EPOLL_CLOEXEC as >>> 0x02000000 instead of 02000000 (fixed). >>> >>> The running scenario: >>> >>> 1. Run ./lttng-sessiond -d -vvv >>> >>> Then: (commands are in bold, output is in blue for readability) >>> >>> root at android:/data/lttng/install_sysroot/bin # *./lttng create s1* >>> >>> Session s1 created. >>> Traces will be written in /data/lttng-traces/s1-20130227-161145 >>> root at android:/data/lttng/install_sysroot/bin # *./lttng enable-channel >>> ch -k* >>> Kernel channel ch enabled for session s1 >>> root at android:/data/lttng/install_sysroot/bin # *./lttng enable-event ev >>> -k -a* >>> All kernel events are enabled in channel channel0 >>> root at android:/data/lttng/install_sysroot/bin # *./lttng list s1* >>> Tracing session s1: [inactive] >>> Trace path: /data/lttng-traces/s1-20130227-161145 >>> >>> === Domain: Kernel === >>> >>> Channels: >>> ------------- >>> - channel0: [enabled] >>> >>> Attributes: >>> overwrite mode: 0 >>> subbufers size: 262144 >>> number of subbufers: 4 >>> switch timer interval: 0 >>> read timer interval: 200 >>> output: splice() >>> >>> Events: >>> None >>> >>> - ch: [enabled] >>> >>> Attributes: >>> overwrite mode: 0 >>> subbufers size: 262144 >>> number of subbufers: 4 >>> switch timer interval: 0 >>> read timer interval: 200 >>> output: splice() >>> >>> Events: >>> None >>> >>> root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * >>> >>> Kernel events: >>> ------------- >>> >>> root at android:/data/lttng/install_sysroot/bin # *./lttng start* >>> Tracing started for session s1 >>> root at android:/data/lttng/install_sysroot/bin # *./lttng stop * >>> >>> Waiting for data availability >>> Tracing stopped for session s1 >>> root at android:/data/lttng/install_sysroot/bin # >>> >>> *Now: (this is not surprising because the kernel events list is >>> empty...)* >>> the folder /data/lttng-traces/s1-20130227-161145/kernel contains: >>> total 0 >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_0 >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_1 >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_0 >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_1 >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 metadata >>> >>> *By the way:* >>> When running the same scenario but creating the channel with *--output >>> mmap*, still no data but the size of the first two files in the traces >>> directory are 4Kb (I didn't bother to investigate them as I assume it is >>> just the header - not the traces payload). >>> >>> Another issue: at this point, listing the sessions gives: >>> root at android:/data/lttng/install_sysroot/bin # *./lttng list s1 * >>> >>> Tracing session s1: [inactive] >>> Trace path: /data/lttng-traces/s1-20130227-161145 >>> >>> === Domain: Kernel === >>> >>> Error: No kernel consumer detected >>> 99|root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * >>> >>> Error: Unable to list kernel events >>> Error: Command error >>> 1|root at android:/data/lttng/install_sysroot/bin # >>> >>> So currently I'm facing these issues: >>> 1. Kernel events list is empty. >>> 2. Listing the session/ kernel events after creating session, channel, >>> event, start, stop - results in "no kernel consumer detected" >>> >>> If you have some insights please share them with me.. >>> >>> Thanks >>> >>> Amit. >>> >>> >>> On Tue, Feb 26, 2013 at 7:35 PM, PLSTC wrote: >>> >>>> The modules you can't find are the same I am also missing I believe; I >>>> think they are only compiled when certain kernel config defines are met >>>> (and those might simply be unavailable under ARM). >>>> >>>> As for what you pointed in your first mail, I believe modprobe isn't >>>> available on ARM, did you mean that some modules were not found when using >>>> insmod? >>>> >>>> For the epoll_create1 problem, what kind of patch did you apply to add >>>> support for the epoll_create1 function? >>>> >>>> >>>> On Tue, Feb 26, 2013 at 11:29 AM, Amit Balboul < >>>> amit.balboul at shinesec.com> wrote: >>>> >>>>> Ok I got : >>>>> lttng-kretprobes.ko >>>>> lttng-kprobes.ko >>>>> , the other two are missing. >>>>> >>>>> >>>>> ---------- Forwarded message ---------- >>>>> From: Amit Balboul >>>>> Date: Tue, Feb 26, 2013 at 5:49 PM >>>>> Subject: Re: [lttng-dev] compiling LTTng for android >>>>> To: PLSTC >>>>> >>>>> >>>>> One more thing: >>>>> >>>>> The list of modules you gave my is not identical to mine: >>>>> a. I pushed the modules from my machine to my folder in the device >>>>> (not to /system/lib) as you directed me, and insmoded them manually. >>>>> b. I pushed the whole tree under /lib/modules// >>>>> which includes the modules.* and the sub directories: >>>>> >>>>> /lib/modules/3.0.31-gd5a18e0/extra$ ll >>>>> total 2464 >>>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ./ >>>>> drwxr-xr-x 3 root root 4096 Feb 26 15:58 ../ >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 lib/ >>>>> -rw-r--r-- 1 root root 167184 Feb 26 15:58 >>>>> lttng-ring-buffer-client-discard.ko >>>>> -rw-r--r-- 1 root root 167206 Feb 26 15:58 >>>>> lttng-ring-buffer-client-mmap-discard.ko >>>>> -rw-r--r-- 1 root root 178586 Feb 26 15:58 >>>>> lttng-ring-buffer-client-mmap-overwrite.ko >>>>> -rw-r--r-- 1 root root 178564 Feb 26 15:58 >>>>> lttng-ring-buffer-client-overwrite.ko >>>>> -rw-r--r-- 1 root root 137179 Feb 26 15:58 >>>>> lttng-ring-buffer-metadata-client.ko >>>>> -rw-r--r-- 1 root root 137233 Feb 26 15:58 >>>>> lttng-ring-buffer-metadata-mmap-client.ko >>>>> -rw-r--r-- 1 root root 213451 Feb 26 15:58 lttng-statedump.ko >>>>> -rw-r--r-- 1 root root 1314235 Feb 26 15:58 lttng-tracer.ko >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 probes/ >>>>> >>>>> /lib/modules/3.0.31-gd5a18e0/extra/lib$ ll >>>>> total 732 >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ >>>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ >>>>> -rw-r--r-- 1 root root 738964 Feb 26 15:58 lttng-lib-ring-buffer.ko >>>>> >>>>> /lib/modules/3.0.31-gd5a18e0/extra/probes$ ll >>>>> total 2872 >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ >>>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ >>>>> -rw-r--r-- 1 root root 162872 Feb 26 15:58 lttng-probe-asoc.ko >>>>> -rw-r--r-- 1 root root 171049 Feb 26 15:58 lttng-probe-block.ko >>>>> -rw-r--r-- 1 root root 81165 Feb 26 15:58 lttng-probe-compaction.ko >>>>> -rw-r--r-- 1 root root 333215 Feb 26 15:58 lttng-probe-ext4.ko >>>>> -rw-r--r-- 1 root root 80413 Feb 26 15:58 lttng-probe-gpio.ko >>>>> -rw-r--r-- 1 root root 84256 Feb 26 15:58 lttng-probe-irq.ko >>>>> -rw-r--r-- 1 root root 135453 Feb 26 15:58 lttng-probe-jbd2.ko >>>>> -rw-r--r-- 1 root root 105399 Feb 26 15:58 lttng-probe-kmem.ko >>>>> -rw-r--r-- 1 root root 76240 Feb 26 15:58 lttng-probe-lttng.ko >>>>> -rw-r--r-- 1 root root 88059 Feb 26 15:58 lttng-probe-module.ko >>>>> -rw-r--r-- 1 root root 154032 Feb 26 15:58 lttng-probe-napi.ko >>>>> -rw-r--r-- 1 root root 142038 Feb 26 15:58 lttng-probe-net.ko >>>>> -rw-r--r-- 1 root root 93564 Feb 26 15:58 lttng-probe-power.ko >>>>> -rw-r--r-- 1 root root 85530 Feb 26 15:58 lttng-probe-regulator.ko >>>>> -rw-r--r-- 1 root root 138121 Feb 26 15:58 lttng-probe-sched.ko >>>>> -rw-r--r-- 1 root root 152909 Feb 26 15:58 lttng-probe-scsi.ko >>>>> -rw-r--r-- 1 root root 107491 Feb 26 15:58 lttng-probe-signal.ko >>>>> -rw-r--r-- 1 root root 142711 Feb 26 15:58 lttng-probe-skb.ko >>>>> -rw-r--r-- 1 root root 181983 Feb 26 15:58 lttng-probe-statedump.ko >>>>> -rw-r--r-- 1 root root 126731 Feb 26 15:58 lttng-probe-timer.ko >>>>> -rw-r--r-- 1 root root 86591 Feb 26 15:58 lttng-probe-workqueue.ko >>>>> -rw-r--r-- 1 root root 133886 Feb 26 15:58 lttng-probe-writeback.ko >>>>> -rw-r--r-- 1 root root 30863 Feb 26 15:58 lttng-types.ko >>>>> >>>>> Looking at the files shows I miss: >>>>> lttng-kretprobes.ko >>>>> lttng-kprobes.ko >>>>> lttng-ftrace.ko >>>>> lttng-probe-kvm.ko >>>>> >>>>> >>>>> On Tue, Feb 26, 2013 at 3:56 PM, PLSTC wrote: >>>>> >>>>>> Back on the last email: >>>>>> >>>>>> Here's the insmod list I ended up building; you might not have >>>>>> compiled all those modules, depending on your kernel config and on the >>>>>> architecture used, so some might simply be absent from your output >>>>>> directory. >>>>>> >>>>>> insmod /system/lib/modules/lttng-types.ko >>>>>> insmod /system/lib/modules/lttng-kretprobes.ko >>>>>> insmod /system/lib/modules/lttng-kprobes.ko >>>>>> insmod /system/lib/modules/lttng-ftrace.ko >>>>>> insmod /system/lib/modules/lttng-lib-ring-buffer.ko >>>>>> insmod /system/lib/modules/lttng-statedump.ko >>>>>> insmod /system/lib/modules/lttng-tracer.ko >>>>>> insmod /system/lib/modules/lttng-probe-timer.ko >>>>>> insmod /system/lib/modules/lttng-probe-statedump.ko >>>>>> insmod /system/lib/modules/lttng-probe-signal.ko >>>>>> insmod /system/lib/modules/lttng-probe-sched.ko >>>>>> insmod /system/lib/modules/lttng-probe-lttng.ko >>>>>> insmod /system/lib/modules/lttng-probe-kvm.ko >>>>>> insmod /system/lib/modules/lttng-probe-irq.ko >>>>>> insmod /system/lib/modules/lttng-probe-block.ko >>>>>> insmod /system/lib/modules/lttng-ring-buffer-metadata-mmap-client.ko >>>>>> insmod /system/lib/modules/lttng-ring-buffer-metadata-client.ko >>>>>> insmod /system/lib/modules/lttng-ring-buffer-client-overwrite.ko >>>>>> insmod /system/lib/modules/lttng-ring-buffer-client-mmap-overwrite.ko >>>>>> insmod /system/lib/modules/lttng-ring-buffer-client-mmap-discard.ko >>>>>> insmod /system/lib/modules/lttng-ring-buffer-client-discard.ko >>>>>> >>>>>> >>>>>> We also haven't had time recently to test if the kprobes/kretprobes >>>>>> worked, but they probably do; we decided to focus a bit more on the >>>>>> 'tracepoints' aspect instead. >>>>>> >>>>>> Anyway, good luck with your exploration, and if you find something >>>>>> interesting, I'd love to know more about it! >>>>>> >>>>>> -PL >>>>>> >>>>>> On Tue, Feb 26, 2013 at 8:06 AM, PLSTC wrote: >>>>>> >>>>>>> Hey Amit, >>>>>>> >>>>>>> Good news indeed it seems! >>>>>>> >>>>>>> When it comes to pushing the libs/bin, we haven't found any better >>>>>>> way than using adb push yet; of course, if all the projects were included >>>>>>> directly in Android's external, we would simply flash the device after each >>>>>>> build, but currently we're still having trouble generating the correct >>>>>>> Android makefiles. >>>>>>> >>>>>>> As for the modules, I might still have a dep load list somewhere I >>>>>>> could send you in a few hours, I remember fighting to get the order right... >>>>>>> >>>>>>> Also, once everything loads, could you tell me what kind of output >>>>>>> 'lttng list -k' provides you? Here, we're having trouble listing the >>>>>>> 'default' kernel trace points provided by HAVE_TRACEPOINTS, and the >>>>>>> returned list is simply empty (which is a bit strange). >>>>>>> >>>>>>> -PL >>>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> >>> >>> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yao at codesourcery.com Fri Mar 15 10:55:32 2013 From: yao at codesourcery.com (Yao Qi) Date: Fri, 15 Mar 2013 22:55:32 +0800 Subject: [lttng-dev] [PATCH] Teach babeltrace understand "native" and "network" for byte_order In-Reply-To: <20130315120753.GA30973@Krystal> References: <1363341137-26956-1-git-send-email-yao@codesourcery.com> <20130315120753.GA30973@Krystal> Message-ID: <51433664.30605@codesourcery.com> On 03/15/2013 08:07 PM, Mathieu Desnoyers wrote: > your interpretation of what the byte order should accept is based on > section 4.1.3 of the CTF spec, which discusses what byte order can be > accepted by a type. > > However, here you are proposing to change the byte order recognised at > the trace declaration level. Unfortunately, we cannot assume anything > about native endianness of the traced machine until we have the > endianness information at the trace declaration level, as the trace can > come from any source. It is clear to me now. Thanks for the clarification. > > Possibly that the CTF spec would need to be clarified. Currently, we > need to look at: The doc part is fine, but this error message is confusing, [error] get_trace_byte_order: unexpected string "native". Should be "native", "network", "be" or "le". Looks it was fixed. When I update my tree, the error message is updated. I'll give a comment in your comment to CTF spec. -- Yao (??) From mathieu.desnoyers at efficios.com Fri Mar 15 11:08:06 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Fri, 15 Mar 2013 11:08:06 -0400 Subject: [lttng-dev] Fwd: compiling LTTng for android In-Reply-To: References: Message-ID: <20130315150806.GA1467@Krystal> * Pierre-Luc St-Charles (pierre-luc.st-charles at polymtl.ca) wrote: > Good news! > > After peeking yesterday through the different glibc/SysV implementations > (wrappers...) of splice I could find, I realized that those are not > actually necessary for what we intend to do: from what I found out, they > only redefine/wrap/redeclare the sys_splice system call that's implemented > directly in the kernel (in any architecture). Considering we don't need > anything more than the default (kernel-space) splice, we can simply rewire > the 'splice' declaration we use/have to syscall(__NR_splice,...), just like > what was needed for epoll_create1 earlier. > > For example : (doing this from memory... I don't have access to the code > atm) > > in src/common/compat/fcntl.h, inside the linux ifdef, top of the file: > > #ifdef __ANDROID__ > #define SPLICE_F_MOVE 0x01 > #define SPLICE_F_NONBLOCK 0x02 > #define SPLICE_F_MORE 0x04 > #define SPLICE_F_GIFT 0x08 > static inline ssize_t splice(int fd_in, loff_t *off_in, int fd_out, > loff_t *off_out, > size_t len, unsigned int flags) > { > return syscall(__NR_splice,fd_in,loff_in,fd_out,loff_out,len,flags); > } > #endif > > > Result? Boom, traces. > > The rest of the project seems to work without any other visible problem, > and we can finally obtain traces when asking the tools nicely. In fact, we > can obtain traces from any device without even having to modify the > kernel/system image at all (except to add module and tracepoints support, > which should already be there), which is pretty surprising, but also very > useful, considering we can just ship the required binaries anywhere and > start tracing. > > Once we confirm that the traces are actually good and we haven't broken > anything else (we're still not sure liburcu works 100%, we're trying to run > all the tests), we'll start sending in results for anyone who might be > interested. That's great news! So I understand that you got lttng-modules Linux kernel tracing to work on Android. I look forward to see patches we could merge into lttng-tools. I guess the next step will be to look into LTTng-UST user-space tracing. Thanks, Mathieu > > - PL > > On Tue, Mar 12, 2013 at 6:51 PM, Pierre-Luc St-Charles < > pierre-luc.st-charles at polymtl.ca> wrote: > > > Hey Amit, > > > > Here's a small update on my latest findings regarding the broken *splice* > > / bad Bionic impl problem: > > > > Although it didn't really cross my mind earlier, we had seen this exact > > problem before, but in another project; we had also investigated a bit at > > the time, but to no avail. It seems the issue is known by the > > Android/Bionic community, but it's simply not on their immediate todo list > > (and hasn't been for at least the past two years -- see > > https://code.google.com/p/android/issues/detail?id=11330). The solutions > > we are now considering are: adding splice support (and whatever else might > > also be needed) to Bionic ourselves (saving BILLIONS of broken lives in the > > process, IF the changes are accepted), or simply inserting glibc (and > > building against it) in our device images. > > > > In the next few days, we'll be studying how much time the first solution > > would actually take (as we're not really experts in that domain at all), > > but considering the nature/objective of this project, it might be the > > wisest decision (as it would not require too much swerving away from the > > default images people have on their devices for LTTng to actually work). If > > we deem it 'impossible/out of our league', we'll simply try to get a > > working tool asap using glibc, which should not be very complicated itself > > (many people have actually successfully done it before). > > > > In any case, I'll keep you updated, and I'll also post any big updates on > > the mailing list. > > > > -PL > > > > On Wed, Mar 6, 2013 at 8:04 PM, Pierre-Luc St-Charles < > > pierre-luc.st-charles at polymtl.ca> wrote: > > > >> Great findings! > >> > >> I'll also try to look into this new problem by next monday; I'm falling a > >> bit behind on my 'investigations', but I'll keep you updated if anything > >> comes up. > >> > >> -PL > >> On Mar 6, 2013 6:09 PM, "Amit Balboul" wrote: > >> > >>> Hi All, > >>> > >>> Regarding the last mail about tracing system calls on Android using > >>> LTTng, > >>> The issue of not receiving enabled event to trace from the kernel can be > >>> fixed patching src/bin/lttng-sessiond/kernel.c (patch attached) > >>> In the function *kernel_list_events,* fscanf-ing the events exported by > >>> the kernel using the fp must not use the syntax *%m* as it is obsolete > >>> (in Android), > >>> thus the fscanf returns 0 and won't read the kernel events (first > >>> condition false). > >>> Instead I use a pre-allocated buffer for the string and use the *%[^;]*syntax, and omitting the memory free (attached is the patch). > >>> > >>> The resulting output is (sessiond is run with verbose debug prints): > >>> > >>> root at android:/data/lttng/bin # *./lttng list -k* > >>> DEBUG1 [10239/10290]: Wait for client response (in > >>> thread_manage_clients() at main.c:3242) > >>> DEBUG1 [10239/10290]: Receiving data from client ... (in > >>> thread_manage_clients() at main.c:3287) > >>> DEBUG1 [10239/10290]: Nothing recv() from client... continuing (in > >>> thread_manage_clients() at main.c:3291) > >>> DEBUG1 [10239/10290]: Clean command context structure (in > >>> clean_command_ctx() at main.c:482) > >>> DEBUG1 [10239/10290]: Accepting client command ... (in > >>> thread_manage_clients() at main.c:3200) > >>> DEBUG1 [10239/10290]: Wait for client response (in > >>> thread_manage_clients() at main.c:3242) > >>> DEBUG1 [10239/10290]: Receiving data from client ... (in > >>> thread_manage_clients() at main.c:3287) > >>> DEBUG1 [10239/10290]: Processing client command 14 (in > >>> process_client_msg() at main.c:2227) > >>> DEBUG1 [10239/10290]: Kernel list events done (61 events) (in > >>> kernel_list_events() at kernel.c:653) > >>> DEBUG1 [10239/10290]: Sending response (size: 35640, retcode: Success) > >>> (in thread_manage_clients() at main.c:3338) > >>> DEBUG1 [10239/10290]: Clean command context structure (in > >>> clean_command_ctx() at main.c:482) > >>> DEBUG1 [10239/10290]: Accepting client command ... (in > >>> thread_manage_clients() at main.c:3200) > >>> Kernel events: > >>> ------------- > >>> block_rq_abort (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_rq_requeue (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_rq_complete (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_rq_insert (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_rq_issue (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_bio_bounce (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_bio_complete (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_bio_backmerge (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_bio_frontmerge (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_bio_queue (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_getrq (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_sleeprq (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_plug (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_unplug (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_split (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> irq_handler_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> irq_handler_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> softirq_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> softirq_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> softirq_raise (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: > >>> tracepoint) > >>> sched_wakeup (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_switch (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_migrate_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_process_free (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_process_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_wait_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_process_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_process_fork (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_stat_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_stat_sleep (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_stat_iowait (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_stat_runtime (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> sched_pi_setprio (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> signal_generate (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> signal_deliver (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> signal_overflow_fail (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> signal_lose_info (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> lttng_statedump_start (loglevel: TRACE_EMERG (0)) (type: > >>> tracepoint) > >>> lttng_statedump_end (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> lttng_statedump_process_state (loglevel: TRACE_EMERG (0)) (type: > >>> tracepoint) > >>> lttng_statedump_file_descriptor (loglevel: TRACE_EMERG (0)) (type: > >>> tracepoint) > >>> lttng_statedump_vm_map (loglevel: TRACE_EMERG (0)) (type: > >>> tracepoint) > >>> lttng_statedump_network_interface (loglevel: TRACE_EMERG (0)) > >>> (type: tracepoint) > >>> lttng_statedump_interrupt (loglevel: TRACE_EMERG (0)) (type: > >>> tracepoint) > >>> timer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> timer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> timer_expire_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> timer_expire_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> timer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> hrtimer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> hrtimer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> hrtimer_expire_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> hrtimer_expire_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> hrtimer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> itimer_state (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> itimer_expire (loglevel: TRACE_EMERG (0)) (type: tracepoint) > >>> > >>> root at android:/data/lttng/bin # > >>> > >>> Now I'm facing the issue of starting the traces: > >>> debugging the sessiond, consumerd and lttng I concluded that the issue > >>> is due to splice system call failure. > >>> even using a MMAP output type channel, the metadata channel is SPLICE > >>> type (hard-coded). > >>> Problem persists also when using relayd to pass the traces through the > >>> network. > >>> Ignoring the splice failure means closing of the metadata channel > >>> (maybe??) but need not affect the traces channel (right ?) > >>> Attached is a debug log of each thread of the sessiond, right after > >>> invoking "*./lttng start*". (with extra informative my prints) > >>> > >>> Please keep me in touch with any progress in this issue, > >>> Thank you, > >>> Amit. > >>> > >>> > >>> > >>> > >>> > >>> > >>> ---------- Forwarded message ---------- > >>> From: Amit Balboul > >>> Date: Wed, Feb 27, 2013 at 4:37 PM > >>> Subject: Re: [lttng-dev] compiling LTTng for android > >>> To: PLSTC > >>> > >>> > >>> Hey Pierre, > >>> > >>> Some major progress has been achieved, following is the summary: > >>> > >>> 1. Modules issue: > >>> I built (for ARM/Android) and installed latest stable version of busybox > >>> on the device. > >>> Seeing the code tries to run (hardcoded) /sbin/modprobe, made a soft > >>> link to busybox's modeprobe. > >>> Also, created /lib/modules/ directory and pushed the > >>> directory from /lib/modules on the machine. > >>> Now session daemon modprobes the desired modules successfully, (some are > >>> not present though as mentioned before) - no need to use insmod. > >>> > >>> 2. epoll_create1 issue: > >>> epoll_create1 patch was OK, I accidentally defined EPOLL_CLOEXEC as > >>> 0x02000000 instead of 02000000 (fixed). > >>> > >>> The running scenario: > >>> > >>> 1. Run ./lttng-sessiond -d -vvv > >>> > >>> Then: (commands are in bold, output is in blue for readability) > >>> > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng create s1* > >>> > >>> Session s1 created. > >>> Traces will be written in /data/lttng-traces/s1-20130227-161145 > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng enable-channel > >>> ch -k* > >>> Kernel channel ch enabled for session s1 > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng enable-event ev > >>> -k -a* > >>> All kernel events are enabled in channel channel0 > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng list s1* > >>> Tracing session s1: [inactive] > >>> Trace path: /data/lttng-traces/s1-20130227-161145 > >>> > >>> === Domain: Kernel === > >>> > >>> Channels: > >>> ------------- > >>> - channel0: [enabled] > >>> > >>> Attributes: > >>> overwrite mode: 0 > >>> subbufers size: 262144 > >>> number of subbufers: 4 > >>> switch timer interval: 0 > >>> read timer interval: 200 > >>> output: splice() > >>> > >>> Events: > >>> None > >>> > >>> - ch: [enabled] > >>> > >>> Attributes: > >>> overwrite mode: 0 > >>> subbufers size: 262144 > >>> number of subbufers: 4 > >>> switch timer interval: 0 > >>> read timer interval: 200 > >>> output: splice() > >>> > >>> Events: > >>> None > >>> > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * > >>> > >>> Kernel events: > >>> ------------- > >>> > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng start* > >>> Tracing started for session s1 > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng stop * > >>> > >>> Waiting for data availability > >>> Tracing stopped for session s1 > >>> root at android:/data/lttng/install_sysroot/bin # > >>> > >>> *Now: (this is not surprising because the kernel events list is > >>> empty...)* > >>> the folder /data/lttng-traces/s1-20130227-161145/kernel contains: > >>> total 0 > >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_0 > >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_1 > >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_0 > >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_1 > >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 metadata > >>> > >>> *By the way:* > >>> When running the same scenario but creating the channel with *--output > >>> mmap*, still no data but the size of the first two files in the traces > >>> directory are 4Kb (I didn't bother to investigate them as I assume it is > >>> just the header - not the traces payload). > >>> > >>> Another issue: at this point, listing the sessions gives: > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng list s1 * > >>> > >>> Tracing session s1: [inactive] > >>> Trace path: /data/lttng-traces/s1-20130227-161145 > >>> > >>> === Domain: Kernel === > >>> > >>> Error: No kernel consumer detected > >>> 99|root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * > >>> > >>> Error: Unable to list kernel events > >>> Error: Command error > >>> 1|root at android:/data/lttng/install_sysroot/bin # > >>> > >>> So currently I'm facing these issues: > >>> 1. Kernel events list is empty. > >>> 2. Listing the session/ kernel events after creating session, channel, > >>> event, start, stop - results in "no kernel consumer detected" > >>> > >>> If you have some insights please share them with me.. > >>> > >>> Thanks > >>> > >>> Amit. > >>> > >>> > >>> On Tue, Feb 26, 2013 at 7:35 PM, PLSTC wrote: > >>> > >>>> The modules you can't find are the same I am also missing I believe; I > >>>> think they are only compiled when certain kernel config defines are met > >>>> (and those might simply be unavailable under ARM). > >>>> > >>>> As for what you pointed in your first mail, I believe modprobe isn't > >>>> available on ARM, did you mean that some modules were not found when using > >>>> insmod? > >>>> > >>>> For the epoll_create1 problem, what kind of patch did you apply to add > >>>> support for the epoll_create1 function? > >>>> > >>>> > >>>> On Tue, Feb 26, 2013 at 11:29 AM, Amit Balboul < > >>>> amit.balboul at shinesec.com> wrote: > >>>> > >>>>> Ok I got : > >>>>> lttng-kretprobes.ko > >>>>> lttng-kprobes.ko > >>>>> , the other two are missing. > >>>>> > >>>>> > >>>>> ---------- Forwarded message ---------- > >>>>> From: Amit Balboul > >>>>> Date: Tue, Feb 26, 2013 at 5:49 PM > >>>>> Subject: Re: [lttng-dev] compiling LTTng for android > >>>>> To: PLSTC > >>>>> > >>>>> > >>>>> One more thing: > >>>>> > >>>>> The list of modules you gave my is not identical to mine: > >>>>> a. I pushed the modules from my machine to my folder in the device > >>>>> (not to /system/lib) as you directed me, and insmoded them manually. > >>>>> b. I pushed the whole tree under /lib/modules// > >>>>> which includes the modules.* and the sub directories: > >>>>> > >>>>> /lib/modules/3.0.31-gd5a18e0/extra$ ll > >>>>> total 2464 > >>>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ./ > >>>>> drwxr-xr-x 3 root root 4096 Feb 26 15:58 ../ > >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 lib/ > >>>>> -rw-r--r-- 1 root root 167184 Feb 26 15:58 > >>>>> lttng-ring-buffer-client-discard.ko > >>>>> -rw-r--r-- 1 root root 167206 Feb 26 15:58 > >>>>> lttng-ring-buffer-client-mmap-discard.ko > >>>>> -rw-r--r-- 1 root root 178586 Feb 26 15:58 > >>>>> lttng-ring-buffer-client-mmap-overwrite.ko > >>>>> -rw-r--r-- 1 root root 178564 Feb 26 15:58 > >>>>> lttng-ring-buffer-client-overwrite.ko > >>>>> -rw-r--r-- 1 root root 137179 Feb 26 15:58 > >>>>> lttng-ring-buffer-metadata-client.ko > >>>>> -rw-r--r-- 1 root root 137233 Feb 26 15:58 > >>>>> lttng-ring-buffer-metadata-mmap-client.ko > >>>>> -rw-r--r-- 1 root root 213451 Feb 26 15:58 lttng-statedump.ko > >>>>> -rw-r--r-- 1 root root 1314235 Feb 26 15:58 lttng-tracer.ko > >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 probes/ > >>>>> > >>>>> /lib/modules/3.0.31-gd5a18e0/extra/lib$ ll > >>>>> total 732 > >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ > >>>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ > >>>>> -rw-r--r-- 1 root root 738964 Feb 26 15:58 lttng-lib-ring-buffer.ko > >>>>> > >>>>> /lib/modules/3.0.31-gd5a18e0/extra/probes$ ll > >>>>> total 2872 > >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ > >>>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ > >>>>> -rw-r--r-- 1 root root 162872 Feb 26 15:58 lttng-probe-asoc.ko > >>>>> -rw-r--r-- 1 root root 171049 Feb 26 15:58 lttng-probe-block.ko > >>>>> -rw-r--r-- 1 root root 81165 Feb 26 15:58 lttng-probe-compaction.ko > >>>>> -rw-r--r-- 1 root root 333215 Feb 26 15:58 lttng-probe-ext4.ko > >>>>> -rw-r--r-- 1 root root 80413 Feb 26 15:58 lttng-probe-gpio.ko > >>>>> -rw-r--r-- 1 root root 84256 Feb 26 15:58 lttng-probe-irq.ko > >>>>> -rw-r--r-- 1 root root 135453 Feb 26 15:58 lttng-probe-jbd2.ko > >>>>> -rw-r--r-- 1 root root 105399 Feb 26 15:58 lttng-probe-kmem.ko > >>>>> -rw-r--r-- 1 root root 76240 Feb 26 15:58 lttng-probe-lttng.ko > >>>>> -rw-r--r-- 1 root root 88059 Feb 26 15:58 lttng-probe-module.ko > >>>>> -rw-r--r-- 1 root root 154032 Feb 26 15:58 lttng-probe-napi.ko > >>>>> -rw-r--r-- 1 root root 142038 Feb 26 15:58 lttng-probe-net.ko > >>>>> -rw-r--r-- 1 root root 93564 Feb 26 15:58 lttng-probe-power.ko > >>>>> -rw-r--r-- 1 root root 85530 Feb 26 15:58 lttng-probe-regulator.ko > >>>>> -rw-r--r-- 1 root root 138121 Feb 26 15:58 lttng-probe-sched.ko > >>>>> -rw-r--r-- 1 root root 152909 Feb 26 15:58 lttng-probe-scsi.ko > >>>>> -rw-r--r-- 1 root root 107491 Feb 26 15:58 lttng-probe-signal.ko > >>>>> -rw-r--r-- 1 root root 142711 Feb 26 15:58 lttng-probe-skb.ko > >>>>> -rw-r--r-- 1 root root 181983 Feb 26 15:58 lttng-probe-statedump.ko > >>>>> -rw-r--r-- 1 root root 126731 Feb 26 15:58 lttng-probe-timer.ko > >>>>> -rw-r--r-- 1 root root 86591 Feb 26 15:58 lttng-probe-workqueue.ko > >>>>> -rw-r--r-- 1 root root 133886 Feb 26 15:58 lttng-probe-writeback.ko > >>>>> -rw-r--r-- 1 root root 30863 Feb 26 15:58 lttng-types.ko > >>>>> > >>>>> Looking at the files shows I miss: > >>>>> lttng-kretprobes.ko > >>>>> lttng-kprobes.ko > >>>>> lttng-ftrace.ko > >>>>> lttng-probe-kvm.ko > >>>>> > >>>>> > >>>>> On Tue, Feb 26, 2013 at 3:56 PM, PLSTC wrote: > >>>>> > >>>>>> Back on the last email: > >>>>>> > >>>>>> Here's the insmod list I ended up building; you might not have > >>>>>> compiled all those modules, depending on your kernel config and on the > >>>>>> architecture used, so some might simply be absent from your output > >>>>>> directory. > >>>>>> > >>>>>> insmod /system/lib/modules/lttng-types.ko > >>>>>> insmod /system/lib/modules/lttng-kretprobes.ko > >>>>>> insmod /system/lib/modules/lttng-kprobes.ko > >>>>>> insmod /system/lib/modules/lttng-ftrace.ko > >>>>>> insmod /system/lib/modules/lttng-lib-ring-buffer.ko > >>>>>> insmod /system/lib/modules/lttng-statedump.ko > >>>>>> insmod /system/lib/modules/lttng-tracer.ko > >>>>>> insmod /system/lib/modules/lttng-probe-timer.ko > >>>>>> insmod /system/lib/modules/lttng-probe-statedump.ko > >>>>>> insmod /system/lib/modules/lttng-probe-signal.ko > >>>>>> insmod /system/lib/modules/lttng-probe-sched.ko > >>>>>> insmod /system/lib/modules/lttng-probe-lttng.ko > >>>>>> insmod /system/lib/modules/lttng-probe-kvm.ko > >>>>>> insmod /system/lib/modules/lttng-probe-irq.ko > >>>>>> insmod /system/lib/modules/lttng-probe-block.ko > >>>>>> insmod /system/lib/modules/lttng-ring-buffer-metadata-mmap-client.ko > >>>>>> insmod /system/lib/modules/lttng-ring-buffer-metadata-client.ko > >>>>>> insmod /system/lib/modules/lttng-ring-buffer-client-overwrite.ko > >>>>>> insmod /system/lib/modules/lttng-ring-buffer-client-mmap-overwrite.ko > >>>>>> insmod /system/lib/modules/lttng-ring-buffer-client-mmap-discard.ko > >>>>>> insmod /system/lib/modules/lttng-ring-buffer-client-discard.ko > >>>>>> > >>>>>> > >>>>>> We also haven't had time recently to test if the kprobes/kretprobes > >>>>>> worked, but they probably do; we decided to focus a bit more on the > >>>>>> 'tracepoints' aspect instead. > >>>>>> > >>>>>> Anyway, good luck with your exploration, and if you find something > >>>>>> interesting, I'd love to know more about it! > >>>>>> > >>>>>> -PL > >>>>>> > >>>>>> On Tue, Feb 26, 2013 at 8:06 AM, PLSTC wrote: > >>>>>> > >>>>>>> Hey Amit, > >>>>>>> > >>>>>>> Good news indeed it seems! > >>>>>>> > >>>>>>> When it comes to pushing the libs/bin, we haven't found any better > >>>>>>> way than using adb push yet; of course, if all the projects were included > >>>>>>> directly in Android's external, we would simply flash the device after each > >>>>>>> build, but currently we're still having trouble generating the correct > >>>>>>> Android makefiles. > >>>>>>> > >>>>>>> As for the modules, I might still have a dep load list somewhere I > >>>>>>> could send you in a few hours, I remember fighting to get the order right... > >>>>>>> > >>>>>>> Also, once everything loads, could you tell me what kind of output > >>>>>>> 'lttng list -k' provides you? Here, we're having trouble listing the > >>>>>>> 'default' kernel trace points provided by HAVE_TRACEPOINTS, and the > >>>>>>> returned list is simply empty (which is a bit strange). > >>>>>>> > >>>>>>> -PL > >>>>>>> > >>>>>> > >>>>>> > >>>>> > >>>>> > >>>> > >>> > >>> > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From yao at codesourcery.com Fri Mar 15 11:16:08 2013 From: yao at codesourcery.com (Yao Qi) Date: Fri, 15 Mar 2013 23:16:08 +0800 Subject: [lttng-dev] [PATCH] Teach babeltrace understand "native" and "network" for byte_order In-Reply-To: <20130315143337.GA959@Krystal> References: <1363341137-26956-1-git-send-email-yao@codesourcery.com> <20130315120753.GA30973@Krystal> <20130315143337.GA959@Krystal> Message-ID: <51433B38.3080805@codesourcery.com> On 03/15/2013 10:33 PM, Mathieu Desnoyers wrote: > byte_order = native OR network OR be OR le; /* network and be are aliases */ > > +Even though the trace description section is not per se a type, for sake > +of clarity, it should be noted that native and network byte orders are > +only allowed within type declaration. The byte_order specified in the > +trace description section only accepts be OR le values. > + The first and last sentence below is a little bit confusing to me. 4.1.3 Byte order By default, the native endianness of the source architecture is used. .... If not specified, the byte order is native. 1. "native endianness" appear in the spec for the first time, without a precise explanation. After your explanation in the last mail, I got to know it is the endianess described in the trace description. 2. "source architecture" is not clear to me. Maybe, we can say something like: "By default, byte order of a basic type is the byte order described in the trace description. It can be overridden by specifying a "byte_order" attribute for a basic type. Typical use-case is to specify the network byte order (big endian: "be") to save data captured from the network into the trace without conversion." I also suggest that we get rid of the term "native" here. IIUC, we have four options for byte order, default, network, le and be. The latter three are easy to understand, and if attribute "byte_order" is not specified, it is the default. On the other hand, "native endianness" means the endianness of underlying machine, which is a little different. I am not good at documentation, nor a native English speaker. My suggestion can be wrong. -- Yao (??) From mathieu.desnoyers at efficios.com Fri Mar 15 11:33:20 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Fri, 15 Mar 2013 11:33:20 -0400 Subject: [lttng-dev] [PATCH] Teach babeltrace understand "native" and "network" for byte_order In-Reply-To: <51433B38.3080805@codesourcery.com> References: <1363341137-26956-1-git-send-email-yao@codesourcery.com> <20130315120753.GA30973@Krystal> <20130315143337.GA959@Krystal> <51433B38.3080805@codesourcery.com> Message-ID: <20130315153320.GA1659@Krystal> * Yao Qi (yao at codesourcery.com) wrote: > On 03/15/2013 10:33 PM, Mathieu Desnoyers wrote: >> byte_order = native OR network OR be OR le; /* network and be are aliases */ >> >> +Even though the trace description section is not per se a type, for sake >> +of clarity, it should be noted that native and network byte orders are >> +only allowed within type declaration. The byte_order specified in the >> +trace description section only accepts be OR le values. >> + > > The first and last sentence below is a little bit confusing to me. > > 4.1.3 Byte order > > By default, the native endianness of the source architecture is used. > .... > If not specified, the byte order is native. > > > 1. "native endianness" appear in the spec for the first time, without a > precise explanation. After your explanation in the last mail, I got to > know it is the endianess described in the trace description. > > 2. "source architecture" is not clear to me. > > Maybe, we can say something like: > > "By default, byte order of a basic type is the byte order described in > the trace description. It can be overridden by specifying a > "byte_order" attribute for a basic type. Typical use-case is to specify > the network byte order (big endian: "be") to save data captured from the > network into the trace without conversion." > > I also suggest that we get rid of the term "native" here. IIUC, we have > four options for byte order, default, network, le and be. The latter > three are easy to understand, and if attribute "byte_order" is not > specified, it is the default. On the other hand, "native endianness" > means the endianness of underlying machine, which is a little different. I added an explanatory paragraph for "native" in addition to your recommended changes. We cannot remove an keyword from the specification lightly, because this would break compatibility. > > I am not good at documentation, nor a native English speaker. My > suggestion can be wrong. Here is the update. Comments are welcome! Thanks, Mathieu commit 237324a20398c5c8eaf92aff0eace177ef8a747f Author: Mathieu Desnoyers Date: Fri Mar 15 11:32:03 2013 -0400 Clarify byte order section Signed-off-by: Mathieu Desnoyers diff --git a/common-trace-format-specification.txt b/common-trace-format-specification.txt index 4ab3ed9..797dec1 100644 --- a/common-trace-format-specification.txt +++ b/common-trace-format-specification.txt @@ -171,20 +171,23 @@ TSDL meta-data attribute representation of a specific alignment: 4.1.3 Byte order -By default, the native endianness of the source architecture is used. -Byte order can be overridden for a basic type by specifying a "byte_order" -attribute. Typical use-case is to specify the network byte order (big endian: -"be") to save data captured from the network into the trace without conversion. -If not specified, the byte order is native. +By default, byte order of a basic type is the byte order described in +the trace description. It can be overridden by specifying a +"byte_order" attribute for a basic type. Typical use-case is to specify +the network byte order (big endian: "be") to save data captured from the +network into the trace without conversion. TSDL meta-data representation: byte_order = native OR network OR be OR le; /* network and be are aliases */ +The "native" keyword selects the byte order described in the trace +description. The "network" byte order is an alias for big endian. + Even though the trace description section is not per se a type, for sake -of clarity, it should be noted that native and network byte orders are -only allowed within type declaration. The byte_order specified in the -trace description section only accepts be OR le values. +of clarity, it should be noted that "native" and "network" byte orders +are only allowed within type declaration. The byte_order specified in +the trace description section only accepts "be" or "le" values. 4.1.4 Size -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From Daniel.Thibault at drdc-rddc.gc.ca Fri Mar 15 12:41:49 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Fri, 15 Mar 2013 16:41:49 +0000 Subject: [lttng-dev] dlopen, gcc -l and LD_PRELOAD Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD027A2C@VAL-E-01.valcartier.drdc-rddc.gc.ca> In the lttng-ust man pages, there is a paragraph that reads: Note about dlopen() usage: Due to locking side-effects caused by the way libc lazily resolves Thread-Local Storage (TLS) symbols when a library is dlopened, linking the tracepoint probe or liblttng-ust with dlopen() is discouraged. They should be linked with the application using "-llibname" or loaded with LD_PRELOAD. I'm confused by the LD_PRELOAD bit: as far as I know, LD_PRELOAD serves only to substitute a dynamic library (the LD_PRELOAD argument) for another (the one the executable was linked against). I don't see how one could compile an instrumented application and leave its tracepoint provider unlinked, which is what the stated -llibname <-> LD_PRELOAD opposition implies. (Also, shouldn't that paragraph drop 'lazily', assuming the locking problems also arise if dlopen is used with RTLD_NOW? Because if RTLD_NOW fixed the locking problem, that's what would be recommended here, no?) Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC? G3J 1X5 CANADA Vox?: (418) 844-4000 x4245 Fax?: (418) 844-4538 NAC?: 918V QSDJ Gouvernement du Canada?/ Government of Canada From gbastien+lttng at versatic.net Fri Mar 15 12:55:31 2013 From: gbastien+lttng at versatic.net (=?UTF-8?q?Genevi=C3=A8ve=20Bastien?=) Date: Fri, 15 Mar 2013 12:55:31 -0400 Subject: [lttng-dev] [RFC-PATCH] Add packet details to net_* tracepoints Message-ID: <1363366532-28892-1-git-send-email-gbastien+lttng@versatic.net> Hi, I'm working on the trace synchronization in the TMF viewer. For this I need to match network packets from all machines. The net_dev_queue and netif_receive_skb tracepoints are ideal candidates for this, but they do not record enough information and from their location in the kernel code, they do not yet have all the required information easily available (see comment in the patch). This patch proposes an approach to get this information without having too much packet processing to do. For now, I plan to use only tcp header information to match packets. Eventually I'd like to change the metadata of those events for a variant type so the bytes of the packet headers already map to their fields in the struct. I'd like some feedback on the approach. Or if there is another approach to this (network packet matching) that seems more appropriate with lttng 2.x Thanks, Genevi?ve Bastien From gbastien+lttng at versatic.net Fri Mar 15 12:55:32 2013 From: gbastien+lttng at versatic.net (=?UTF-8?q?Genevi=C3=A8ve=20Bastien?=) Date: Fri, 15 Mar 2013 12:55:32 -0400 Subject: [lttng-dev] [RFC-PATCH] Add packet details to net_* tracepoints In-Reply-To: <1363366532-28892-1-git-send-email-gbastien+lttng@versatic.net> References: <1363366532-28892-1-git-send-email-gbastien+lttng@versatic.net> Message-ID: <1363366532-28892-2-git-send-email-gbastien+lttng@versatic.net> This patch adds some packet header details to the net_* tracepoints: the network header and transport header if it is tcp. Signed-off-by: Genevi?ve Bastien --- instrumentation/events/lttng-module/net.h | 96 +++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/instrumentation/events/lttng-module/net.h b/instrumentation/events/lttng-module/net.h index e552cf7..5830160 100644 --- a/instrumentation/events/lttng-module/net.h +++ b/instrumentation/events/lttng-module/net.h @@ -7,9 +7,50 @@ #include #include #include +#include +#include #include #include +#ifndef _TRACE_NET_DEF_ +#define _TRACE_NET_DEF_ + +static inline unsigned int __get_network_header_len(struct sk_buff *skb) +{ + if (skb_network_header(skb) == skb->head) { + /* Is the network header initialized */ + return 0; + } else if (skb->transport_header > skb->network_header) { + /* is the transport header initialized */ + return skb->transport_header - skb->network_header; + } else { /* Don't know where to stop */ + return 0; + } +} + +static inline unsigned int __get_transport_header_len(struct sk_buff *skb) +{ + if (skb_network_header(skb) == skb->head) { + /* Is the network header initialized */ + return 0; + } else if (skb->transport_header <= skb->network_header) { + /* is the transport header initialized */ + return 0; + } else if ( + ((ip_hdr(skb)->version == 4) + && (ip_hdr(skb)->protocol == 6)) || + ((ipv6_hdr(skb)->version == 6) && + (ipv6_hdr(skb)->nexthdr == 6))) { + /* tcp over ipv4 or ipv6 */ + return sizeof(struct tcphdr); + } else { + /* Other protocol */ + return 0; + } +} + +#endif /* _TRACE_NET_DEF_ */ + TRACE_EVENT(net_dev_xmit, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40)) @@ -57,6 +98,27 @@ TRACE_EVENT(net_dev_xmit, __get_str(name), __entry->skbaddr, __entry->len, __entry->rc) ) +/* + * This has to be safe: we need as much information from the headers as + * possible, but these tracepoints are early after the skb reception and + * just before sending, so we do not have yet full skb information. + * We will need to do some packet treatment to be able to get all the info we + * need. + * + * At this point, sometimes the network header (nh) and/or transport header + * (th) is not initialized. And we do not know the length of those headers. + * + * The idea is to copy header only if we know where it starts and where it + * ends. + * + * For nh, we copy th-nh bytes, if both th and nh are initialized. + * + * For th, we never know its length, so we copy it only if we know where to + * start and if it's a tcp header. To know that, we check the first bits of + * nh (assuming it's a ip header) whether it's v4 or v6 and depending on the + * ip version, check the transport protocol. If it's tcp (6), then we know + * the th is a (struct tcphdr) + */ DECLARE_EVENT_CLASS(net_dev_template, TP_PROTO(struct sk_buff *skb), @@ -64,19 +126,43 @@ DECLARE_EVENT_CLASS(net_dev_template, TP_ARGS(skb), TP_STRUCT__entry( - __field( void *, skbaddr ) - __field( unsigned int, len ) - __string( name, skb->dev->name ) + __field_hex(void *, skbaddr) + __field(unsigned int, len) + __string(name, skb->dev->name) + __field_network_hex(uint32_t, saddr) + __field(unsigned char*, mh) + __field(unsigned char*, nh) + __field(unsigned char*, th) + __field(unsigned char*, tail) + __field(unsigned char*, end) + __field(unsigned char*, head) + __field(unsigned char*, data) + __dynamic_array_hex(unsigned char, nhdata, + __get_network_header_len(skb)) + __dynamic_array_hex(unsigned char, thdata, + __get_transport_header_len(skb)) ), TP_fast_assign( tp_assign(skbaddr, skb) tp_assign(len, skb->len) tp_strcpy(name, skb->dev->name) + tp_assign(saddr, ip_hdr(skb)->saddr) + tp_assign(mh, skb->mac_header) + tp_assign(nh, skb->network_header) + tp_assign(th, skb->transport_header) + tp_assign(tail, skb->tail) + tp_assign(end, skb->end) + tp_assign(head, skb->head) + tp_assign(data, skb->data) + tp_memcpy_dyn(nhdata, skb_network_header(skb)) + tp_memcpy_dyn(thdata, skb_transport_header(skb)) ), - TP_printk("dev=%s skbaddr=%p len=%u", - __get_str(name), __entry->skbaddr, __entry->len) + TP_printk("dev=%s skbaddr=%x len=%u saddr=%x %x %x %x %x %x %x %x", + __get_str(name), __entry->skbaddr, __entry->len, __entry->saddr, + __entry->th, __entry->nh, __entry->mh, __entry->tail, + __entry->end, __entry->head, __entry->data) ) DEFINE_EVENT(net_dev_template, net_dev_queue, -- 1.8.1.5 From raphael.beamonte at gmail.com Fri Mar 15 14:40:40 2013 From: raphael.beamonte at gmail.com (=?UTF-8?q?Rapha=C3=ABl=20Beamonte?=) Date: Fri, 15 Mar 2013 14:40:40 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <51421C12.5050907@gmail.com> References: <51421C12.5050907@gmail.com> Message-ID: <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com> Signed-off-by: Rapha?l Beamonte --- .gitignore | 2 ++ include/Makefile.am | 26 +++++++++++++++++++++++++- include/version.h.tmpl | 27 +++++++++++++++++++++++++++ src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++++++ src/bin/lttng-sessiond/main.c | 2 +- src/bin/lttng/commands/version.c | 4 +++- src/bin/lttng/lttng.c | 5 ++++- src/bin/lttng/utils.h | 13 +++++++++++++ 8 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 include/version.h.tmpl diff --git a/.gitignore b/.gitignore index ac72bf4..a36f0b9 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,8 @@ config/ !config/epoll.m4 !config/config_feature.m4 +include/version.h + src/bin/lttng-sessiond/lttng-sessiond src/bin/lttng/lttng src/bin/lttng-consumerd/lttng-consumerd diff --git a/include/Makefile.am b/include/Makefile.am index 0bcb6f9..b46c1e2 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1 +1,25 @@ -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h +version.h: version.h.tmpl + (git_version="$$(git describe --long --all 2>/dev/null)"; \ + version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \ + version_h="$(top_builddir)/include/version.h"; \ + if [ ! -e "$${version_h}" ] || \ + [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \ + cp "$${version_h_tmpl}" "$${version_h}"; \ + fi; \ + if [ -z "$${git_version}" ]; then \ + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \ + fi; \ + else \ + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + else \ + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + fi; \ + fi; \ + fi) + +.PHONY: version.h + +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h version.h diff --git a/include/version.h.tmpl b/include/version.h.tmpl new file mode 100644 index 0000000..c42789c --- /dev/null +++ b/include/version.h.tmpl @@ -0,0 +1,27 @@ +/* + * version.h + * + * Linux Trace Toolkit version header file + * + * Copyright (C) 2013 - Rapha?l Beamonte + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef VERSION_H +#define VERSION_H + +#define GIT_VERSION + +#endif /* VERSION_H */ diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h index 9258f38..e91918a 100644 --- a/src/bin/lttng-sessiond/lttng-sessiond.h +++ b/src/bin/lttng-sessiond/lttng-sessiond.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - David Goulet + * Copyright (C) 2013 - Rapha?l Beamonte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only, @@ -28,6 +29,8 @@ #include "session.h" #include "ust-app.h" +#include "version.h" + extern const char default_home_dir[], default_tracing_group[], @@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2]; int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size); int sessiond_check_thread_quit_pipe(int fd, uint32_t events); +/* + * This static const char allows to return the version number depending + * whether or not the GIT_VERSION value is available + */ +#ifdef GIT_VERSION +static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")"; +#else /* GIT_VERSION */ +static const char lttng_sessiond_version[] = VERSION; +#endif /* GIT_VERSION */ + + #endif /* _LTT_SESSIOND_H */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index f7bb53e..857a20d 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3547,7 +3547,7 @@ static int parse_args(int argc, char **argv) usage(); exit(EXIT_FAILURE); case 'V': - fprintf(stdout, "%s\n", VERSION); + fprintf(stdout, "%s\n", lttng_sessiond_version); exit(EXIT_SUCCESS); case 'S': opt_sig_parent = 1; diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c index 7f69de3..2170d00 100644 --- a/src/bin/lttng/commands/version.c +++ b/src/bin/lttng/commands/version.c @@ -26,6 +26,7 @@ #include #include "../command.h" +#include "../utils.h" enum { OPT_HELP = 1, @@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv) } MSG("lttng version " VERSION " - " VERSION_NAME); - MSG("\n" VERSION_DESCRIPTION "\n"); + MSG("%s", lttng_version); + MSG(VERSION_DESCRIPTION "\n"); MSG("Web site: http://lttng.org"); MSG("\nlttng is free software and under the GPL license and part LGPL"); diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 8562144..002bf4e 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -31,6 +31,7 @@ #include #include "command.h" +#include "utils.h" /* Variables */ static char *progname; @@ -81,7 +82,9 @@ static struct cmd_struct commands[] = { static void usage(FILE *ofp) { - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); + fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n"); + fprintf(ofp, lttng_version); + fprintf(ofp, "\n"); fprintf(ofp, "usage: lttng [OPTIONS] []\n"); fprintf(ofp, "\n"); fprintf(ofp, "Options:\n"); diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h index 9f7bfcc..12ee7c0 100644 --- a/src/bin/lttng/utils.h +++ b/src/bin/lttng/utils.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - David Goulet + * Copyright (C) 2013 - Rapha?l Beamonte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only, @@ -19,8 +20,20 @@ #define _LTTNG_UTILS_H #include +#include char *get_session_name(void); void list_cmd_options(FILE *ofp, struct poptOption *options); +/* + * This static const char allows to return the version number depending + * whether or not the GIT_VERSION value is available + */ +#ifdef GIT_VERSION +static const char lttng_version[] = "Git version: " GIT_VERSION "\n"; +#else /* GIT_VERSION */ +static const char lttng_version[] = ""; +#endif /* GIT_VERSION */ + + #endif /* _LTTNG_UTILS_H */ -- 1.7.10.4 From raphael.beamonte at gmail.com Fri Mar 15 14:44:05 2013 From: raphael.beamonte at gmail.com (=?UTF-8?B?UmFwaGHDq2wgQmVhbW9udGU=?=) Date: Fri, 15 Mar 2013 14:44:05 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com> References: <51421C12.5050907@gmail.com> <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com> Message-ID: <51436BF5.4000501@gmail.com> On 2013-03-15 14:40, Rapha?l Beamonte wrote: > Signed-off-by: Rapha?l Beamonte > --- > .gitignore | 2 ++ > include/Makefile.am | 26 +++++++++++++++++++++++++- > include/version.h.tmpl | 27 +++++++++++++++++++++++++++ > src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++++++ > src/bin/lttng-sessiond/main.c | 2 +- > src/bin/lttng/commands/version.c | 4 +++- > src/bin/lttng/lttng.c | 5 ++++- > src/bin/lttng/utils.h | 13 +++++++++++++ > 8 files changed, 89 insertions(+), 4 deletions(-) > create mode 100644 include/version.h.tmpl This new version of the patch should answer to your last comments. Feel free to give new comments and critics ! I just wasn't able to check the "make dist" as it seems broken in the last commit of lttng-tools. Rapha?l -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From jeremie.galarneau at efficios.com Fri Mar 15 15:33:11 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Fri, 15 Mar 2013 15:33:11 -0400 Subject: [lttng-dev] dlopen, gcc -l and LD_PRELOAD In-Reply-To: <48CF5AC71E61DB46B70D0F388054EFFD027A2C@VAL-E-01.valcartier.drdc-rddc.gc.ca> References: <48CF5AC71E61DB46B70D0F388054EFFD027A2C@VAL-E-01.valcartier.drdc-rddc.gc.ca> Message-ID: On Fri, Mar 15, 2013 at 12:41 PM, Thibault, Daniel wrote: > In the lttng-ust man pages, there is a paragraph that reads: > > Note about dlopen() usage: Due to locking side-effects caused by the way libc lazily resolves Thread-Local Storage (TLS) symbols when a library is dlopened, linking the tracepoint probe or liblttng-ust with dlopen() is discouraged. They should be linked with the application using "-llibname" or loaded with LD_PRELOAD. > > I'm confused by the LD_PRELOAD bit: as far as I know, LD_PRELOAD serves only to substitute a dynamic library (the LD_PRELOAD argument) for another (the one the executable was linked against). I don't see how one could compile an instrumented application and leave its tracepoint provider unlinked, which is what the stated -llibname <-> LD_PRELOAD opposition implies. > You may want to have a look at the comment at lttng-ust/include/lttng/tracepoint.h:229 which explains how this is accomplished. Basically, the tracepoint provider symbols are initialised and the probe is registered when the provider's shared object constructor is invoked. See ust-tracepoint-event.h:671 if you are interested in the actual implementation. > (Also, shouldn't that paragraph drop 'lazily', assuming the locking problems also arise if dlopen is used with RTLD_NOW? Because if RTLD_NOW fixed the locking problem, that's what would be recommended here, no?) Good question. I think this problem has been fixed as part of the 2.1 release. However, I do know there are other issues related to "dlopen()"-ing probe providers; details on the bug tracker[1]. J?r?mie [1] https://bugs.lttng.org/issues/447 > > Daniel U. Thibault > R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) > Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) > Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) > 2459 route de la Bravoure > Qu?bec, QC G3J 1X5 > CANADA > Vox : (418) 844-4000 x4245 > Fax : (418) 844-4538 > NAC : 918V QSDJ > Gouvernement du Canada / Government of Canada > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From jeremie.galarneau at efficios.com Fri Mar 15 17:16:04 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Fri, 15 Mar 2013 17:16:04 -0400 Subject: [lttng-dev] [PATCH ctf] Typo fix in the tracers requirements Message-ID: <1363382164-12487-1-git-send-email-jeremie.galarneau@efficios.com> Signed-off-by: J?r?mie Galarneau --- common-trace-format-reqs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-trace-format-reqs.txt b/common-trace-format-reqs.txt index 66fe55a..e5e7c7a 100644 --- a/common-trace-format-reqs.txt +++ b/common-trace-format-reqs.txt @@ -268,7 +268,7 @@ Enumerating these higher-level requirements influence the trace format in many ways. For instance, a requirement for compactness leads to schemes where all information repetition should be eliminated. Thus the need for optional per-section context information. Another example is the requirement for speed -and streaming. The requirement for speed ans treaming leads to zero-copy +and streaming. The requirement for speed and streaming leads to zero-copy implementations, which imply that the trace format should be written natively by the tracer. The tracer requirements stated in this section are stated to ensure that the trace format structure makes it possible for a tracer to cope with the -- 1.8.1.5 From mathieu.desnoyers at efficios.com Fri Mar 15 17:37:12 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Fri, 15 Mar 2013 17:37:12 -0400 Subject: [lttng-dev] [PATCH ctf] Typo fix in the tracers requirements In-Reply-To: <1363382164-12487-1-git-send-email-jeremie.galarneau@efficios.com> References: <1363382164-12487-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <20130315213712.GA5443@Krystal> * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: > Signed-off-by: J?r?mie Galarneau merged, thanks! Mathieu > --- > common-trace-format-reqs.txt | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/common-trace-format-reqs.txt b/common-trace-format-reqs.txt > index 66fe55a..e5e7c7a 100644 > --- a/common-trace-format-reqs.txt > +++ b/common-trace-format-reqs.txt > @@ -268,7 +268,7 @@ Enumerating these higher-level requirements influence the trace format in many > ways. For instance, a requirement for compactness leads to schemes where all > information repetition should be eliminated. Thus the need for optional > per-section context information. Another example is the requirement for speed > -and streaming. The requirement for speed ans treaming leads to zero-copy > +and streaming. The requirement for speed and streaming leads to zero-copy > implementations, which imply that the trace format should be written natively by > the tracer. The tracer requirements stated in this section are stated to ensure > that the trace format structure makes it possible for a tracer to cope with the > -- > 1.8.1.5 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From kalyanasv at yahoo.com Sat Mar 16 19:36:47 2013 From: kalyanasv at yahoo.com (Kalyana Sundaram Venkataraman) Date: Sat, 16 Mar 2013 16:36:47 -0700 (PDT) Subject: [lttng-dev] link Message-ID: <1363477007.53900.YahooMailNeo@web164903.mail.bf1.yahoo.com> http://reklam-grafika.hu/bxl/jcopryatla -------------- next part -------------- An HTML attachment was scrubbed... URL: From raphael.beamonte at gmail.com Sat Mar 16 19:49:54 2013 From: raphael.beamonte at gmail.com (=?UTF-8?q?Rapha=C3=ABl=20Beamonte?=) Date: Sat, 16 Mar 2013 19:49:54 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com> References: <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com> Message-ID: <16a0408728b4c746985844ecd893bd569b599641.1363477794.git.raphael.beamonte@gmail.com> Signed-off-by: Rapha?l Beamonte --- .gitignore | 2 ++ include/Makefile.am | 45 ++++++++++++++++++++++++++++++- include/version.h.tmpl | 27 +++++++++++++++++++ src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++ src/bin/lttng-sessiond/main.c | 2 +- src/bin/lttng/commands/version.c | 4 ++- src/bin/lttng/lttng.c | 5 +++- src/bin/lttng/utils.h | 13 +++++++++ 8 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 include/version.h.tmpl diff --git a/.gitignore b/.gitignore index ac72bf4..a36f0b9 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,8 @@ config/ !config/epoll.m4 !config/config_feature.m4 +include/version.h + src/bin/lttng-sessiond/lttng-sessiond src/bin/lttng/lttng src/bin/lttng-consumerd/lttng-consumerd diff --git a/include/Makefile.am b/include/Makefile.am index 0bcb6f9..fce6276 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1 +1,44 @@ -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h +## The version.h file must be verified and generated or updated if the +## git commit id (called git version here) changed since the last build +## of lttng-tools. +version.h: version.h.tmpl + ## We first create variables for the current git version and + ## the locations of the version.h and version.h.tmpl files + (git_version="$$(git describe --long --all 2>/dev/null)"; \ + version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \ + version_h="$(top_builddir)/include/version.h"; \ + ## If the version.h file doesn't exist or is not up to date, + ## We replace it by the version.h.tmpl file + if [ ! -e "$${version_h}" ] || \ + [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \ + cp "$${version_h_tmpl}" "$${version_h}"; \ + fi; \ + if [ -z "$${git_version}" ]; then \ + ## If we don't have a git version, we verify that there is + ## not any define of GIT_VERSION in the version.h file, or + ## we remove it. + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \ + fi; \ + else \ + ## If we have a git version, we verify that it isn't the same + ## as the one currently in the file (if there is one), as we + ## don't want to update the file if it is already up to date + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ + ## If there is already a GIT_VERSION defined, + ## we just replace it by the new version + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + else \ + ## Else, we add a GIT_VERSION define + ## containing our new version. + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + fi; \ + fi; \ + fi) + +## version.h is defined as a .PHONY file even if it's a real file as +## we want our routine to be runned for each build. +.PHONY: version.h + +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h version.h diff --git a/include/version.h.tmpl b/include/version.h.tmpl new file mode 100644 index 0000000..c42789c --- /dev/null +++ b/include/version.h.tmpl @@ -0,0 +1,27 @@ +/* + * version.h + * + * Linux Trace Toolkit version header file + * + * Copyright (C) 2013 - Rapha?l Beamonte + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef VERSION_H +#define VERSION_H + +#define GIT_VERSION + +#endif /* VERSION_H */ diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h index 9258f38..e91918a 100644 --- a/src/bin/lttng-sessiond/lttng-sessiond.h +++ b/src/bin/lttng-sessiond/lttng-sessiond.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - David Goulet + * Copyright (C) 2013 - Rapha?l Beamonte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only, @@ -28,6 +29,8 @@ #include "session.h" #include "ust-app.h" +#include "version.h" + extern const char default_home_dir[], default_tracing_group[], @@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2]; int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size); int sessiond_check_thread_quit_pipe(int fd, uint32_t events); +/* + * This static const char allows to return the version number depending + * whether or not the GIT_VERSION value is available + */ +#ifdef GIT_VERSION +static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")"; +#else /* GIT_VERSION */ +static const char lttng_sessiond_version[] = VERSION; +#endif /* GIT_VERSION */ + + #endif /* _LTT_SESSIOND_H */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index f7bb53e..857a20d 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3547,7 +3547,7 @@ static int parse_args(int argc, char **argv) usage(); exit(EXIT_FAILURE); case 'V': - fprintf(stdout, "%s\n", VERSION); + fprintf(stdout, "%s\n", lttng_sessiond_version); exit(EXIT_SUCCESS); case 'S': opt_sig_parent = 1; diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c index 7f69de3..2170d00 100644 --- a/src/bin/lttng/commands/version.c +++ b/src/bin/lttng/commands/version.c @@ -26,6 +26,7 @@ #include #include "../command.h" +#include "../utils.h" enum { OPT_HELP = 1, @@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv) } MSG("lttng version " VERSION " - " VERSION_NAME); - MSG("\n" VERSION_DESCRIPTION "\n"); + MSG("%s", lttng_version); + MSG(VERSION_DESCRIPTION "\n"); MSG("Web site: http://lttng.org"); MSG("\nlttng is free software and under the GPL license and part LGPL"); diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 8562144..002bf4e 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -31,6 +31,7 @@ #include #include "command.h" +#include "utils.h" /* Variables */ static char *progname; @@ -81,7 +82,9 @@ static struct cmd_struct commands[] = { static void usage(FILE *ofp) { - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); + fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n"); + fprintf(ofp, lttng_version); + fprintf(ofp, "\n"); fprintf(ofp, "usage: lttng [OPTIONS] []\n"); fprintf(ofp, "\n"); fprintf(ofp, "Options:\n"); diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h index 9f7bfcc..12ee7c0 100644 --- a/src/bin/lttng/utils.h +++ b/src/bin/lttng/utils.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - David Goulet + * Copyright (C) 2013 - Rapha?l Beamonte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only, @@ -19,8 +20,20 @@ #define _LTTNG_UTILS_H #include +#include char *get_session_name(void); void list_cmd_options(FILE *ofp, struct poptOption *options); +/* + * This static const char allows to return the version number depending + * whether or not the GIT_VERSION value is available + */ +#ifdef GIT_VERSION +static const char lttng_version[] = "Git version: " GIT_VERSION "\n"; +#else /* GIT_VERSION */ +static const char lttng_version[] = ""; +#endif /* GIT_VERSION */ + + #endif /* _LTTNG_UTILS_H */ -- 1.7.10.4 From raphael.beamonte at gmail.com Sat Mar 16 19:55:42 2013 From: raphael.beamonte at gmail.com (=?UTF-8?B?UmFwaGHDq2wgQmVhbW9udGU=?=) Date: Sat, 16 Mar 2013 19:55:42 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <16a0408728b4c746985844ecd893bd569b599641.1363477794.git.raphael.beamonte@gmail.com> References: <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com> <16a0408728b4c746985844ecd893bd569b599641.1363477794.git.raphael.beamonte@gmail.com> Message-ID: <5145067E.7020609@gmail.com> On 2013-03-16 19:49, Rapha?l Beamonte wrote: > Signed-off-by: Rapha?l Beamonte > --- > .gitignore | 2 ++ > include/Makefile.am | 45 ++++++++++++++++++++++++++++++- > include/version.h.tmpl | 27 +++++++++++++++++++ > src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++ > src/bin/lttng-sessiond/main.c | 2 +- > src/bin/lttng/commands/version.c | 4 ++- > src/bin/lttng/lttng.c | 5 +++- > src/bin/lttng/utils.h | 13 +++++++++ > 8 files changed, 108 insertions(+), 4 deletions(-) > create mode 100644 include/version.h.tmpl This new version of the patch adds comments in the Makefile.am to help to understand the work of the shell routine. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From amit.balboul at shinesec.com Sun Mar 17 03:17:32 2013 From: amit.balboul at shinesec.com (Amit Balboul) Date: Sun, 17 Mar 2013 09:17:32 +0200 Subject: [lttng-dev] Fwd: compiling LTTng for android In-Reply-To: <20130315150806.GA1467@Krystal> References: <20130315150806.GA1467@Krystal> Message-ID: That's great news !!! Glad to hear that this is the last hurdle to pass, Thanks, Amit. On Fri, Mar 15, 2013 at 5:08 PM, Mathieu Desnoyers < mathieu.desnoyers at efficios.com> wrote: > * Pierre-Luc St-Charles (pierre-luc.st-charles at polymtl.ca) wrote: > > Good news! > > > > After peeking yesterday through the different glibc/SysV implementations > > (wrappers...) of splice I could find, I realized that those are not > > actually necessary for what we intend to do: from what I found out, they > > only redefine/wrap/redeclare the sys_splice system call that's > implemented > > directly in the kernel (in any architecture). Considering we don't need > > anything more than the default (kernel-space) splice, we can simply > rewire > > the 'splice' declaration we use/have to syscall(__NR_splice,...), just > like > > what was needed for epoll_create1 earlier. > > > > For example : (doing this from memory... I don't have access to the code > > atm) > > > in src/common/compat/fcntl.h, inside the linux ifdef, top of the file: > > > > #ifdef __ANDROID__ > > #define SPLICE_F_MOVE 0x01 > > #define SPLICE_F_NONBLOCK 0x02 > > #define SPLICE_F_MORE 0x04 > > #define SPLICE_F_GIFT 0x08 > > static inline ssize_t splice(int fd_in, loff_t *off_in, int fd_out, > > loff_t *off_out, > > size_t len, unsigned int flags) > > { > > return syscall(__NR_splice,fd_in,loff_in,fd_out,loff_out,len,flags); > > } > > #endif > > > > > > Result? Boom, traces. > > > > The rest of the project seems to work without any other visible problem, > > and we can finally obtain traces when asking the tools nicely. In fact, > we > > can obtain traces from any device without even having to modify the > > kernel/system image at all (except to add module and tracepoints support, > > which should already be there), which is pretty surprising, but also very > > useful, considering we can just ship the required binaries anywhere and > > start tracing. > > > > Once we confirm that the traces are actually good and we haven't broken > > anything else (we're still not sure liburcu works 100%, we're trying to > run > > all the tests), we'll start sending in results for anyone who might be > > interested. > > That's great news! So I understand that you got lttng-modules Linux > kernel tracing to work on Android. I look forward to see patches we > could merge into lttng-tools. > > I guess the next step will be to look into LTTng-UST user-space tracing. > > Thanks, > > Mathieu > > > > > - PL > > > > On Tue, Mar 12, 2013 at 6:51 PM, Pierre-Luc St-Charles < > > pierre-luc.st-charles at polymtl.ca> wrote: > > > > > Hey Amit, > > > > > > Here's a small update on my latest findings regarding the broken > *splice* > > > / bad Bionic impl problem: > > > > > > Although it didn't really cross my mind earlier, we had seen this exact > > > problem before, but in another project; we had also investigated a bit > at > > > the time, but to no avail. It seems the issue is known by the > > > Android/Bionic community, but it's simply not on their immediate todo > list > > > (and hasn't been for at least the past two years -- see > > > https://code.google.com/p/android/issues/detail?id=11330). The > solutions > > > we are now considering are: adding splice support (and whatever else > might > > > also be needed) to Bionic ourselves (saving BILLIONS of broken lives > in the > > > process, IF the changes are accepted), or simply inserting glibc (and > > > building against it) in our device images. > > > > > > In the next few days, we'll be studying how much time the first > solution > > > would actually take (as we're not really experts in that domain at > all), > > > but considering the nature/objective of this project, it might be the > > > wisest decision (as it would not require too much swerving away from > the > > > default images people have on their devices for LTTng to actually > work). If > > > we deem it 'impossible/out of our league', we'll simply try to get a > > > working tool asap using glibc, which should not be very complicated > itself > > > (many people have actually successfully done it before). > > > > > > In any case, I'll keep you updated, and I'll also post any big updates > on > > > the mailing list. > > > > > > -PL > > > > > > On Wed, Mar 6, 2013 at 8:04 PM, Pierre-Luc St-Charles < > > > pierre-luc.st-charles at polymtl.ca> wrote: > > > > > >> Great findings! > > >> > > >> I'll also try to look into this new problem by next monday; I'm > falling a > > >> bit behind on my 'investigations', but I'll keep you updated if > anything > > >> comes up. > > >> > > >> -PL > > >> On Mar 6, 2013 6:09 PM, "Amit Balboul" > wrote: > > >> > > >>> Hi All, > > >>> > > >>> Regarding the last mail about tracing system calls on Android using > > >>> LTTng, > > >>> The issue of not receiving enabled event to trace from the kernel > can be > > >>> fixed patching src/bin/lttng-sessiond/kernel.c (patch attached) > > >>> In the function *kernel_list_events,* fscanf-ing the events exported > by > > >>> the kernel using the fp must not use the syntax *%m* as it is > obsolete > > >>> (in Android), > > >>> thus the fscanf returns 0 and won't read the kernel events (first > > >>> condition false). > > >>> Instead I use a pre-allocated buffer for the string and use the > *%[^;]*syntax, and omitting the memory free (attached is the patch). > > >>> > > >>> The resulting output is (sessiond is run with verbose debug prints): > > >>> > > >>> root at android:/data/lttng/bin # *./lttng list -k* > > >>> DEBUG1 [10239/10290]: Wait for client response (in > > >>> thread_manage_clients() at main.c:3242) > > >>> DEBUG1 [10239/10290]: Receiving data from client ... (in > > >>> thread_manage_clients() at main.c:3287) > > >>> DEBUG1 [10239/10290]: Nothing recv() from client... continuing (in > > >>> thread_manage_clients() at main.c:3291) > > >>> DEBUG1 [10239/10290]: Clean command context structure (in > > >>> clean_command_ctx() at main.c:482) > > >>> DEBUG1 [10239/10290]: Accepting client command ... (in > > >>> thread_manage_clients() at main.c:3200) > > >>> DEBUG1 [10239/10290]: Wait for client response (in > > >>> thread_manage_clients() at main.c:3242) > > >>> DEBUG1 [10239/10290]: Receiving data from client ... (in > > >>> thread_manage_clients() at main.c:3287) > > >>> DEBUG1 [10239/10290]: Processing client command 14 (in > > >>> process_client_msg() at main.c:2227) > > >>> DEBUG1 [10239/10290]: Kernel list events done (61 events) (in > > >>> kernel_list_events() at kernel.c:653) > > >>> DEBUG1 [10239/10290]: Sending response (size: 35640, retcode: > Success) > > >>> (in thread_manage_clients() at main.c:3338) > > >>> DEBUG1 [10239/10290]: Clean command context structure (in > > >>> clean_command_ctx() at main.c:482) > > >>> DEBUG1 [10239/10290]: Accepting client command ... (in > > >>> thread_manage_clients() at main.c:3200) > > >>> Kernel events: > > >>> ------------- > > >>> block_rq_abort (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_rq_requeue (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_rq_complete (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> block_rq_insert (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_rq_issue (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_bio_bounce (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_bio_complete (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> block_bio_backmerge (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> block_bio_frontmerge (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> block_bio_queue (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_getrq (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_sleeprq (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_plug (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_unplug (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_split (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> irq_handler_entry (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> irq_handler_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> softirq_entry (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> softirq_exit (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> softirq_raise (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: > > >>> tracepoint) > > >>> sched_wakeup (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> sched_switch (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> sched_migrate_task (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> sched_process_free (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> sched_process_exit (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> sched_wait_task (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> sched_process_wait (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> sched_process_fork (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> sched_stat_wait (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> sched_stat_sleep (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> sched_stat_iowait (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> sched_stat_runtime (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> sched_pi_setprio (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> signal_generate (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> signal_deliver (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> signal_overflow_fail (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> signal_lose_info (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> lttng_statedump_start (loglevel: TRACE_EMERG (0)) (type: > > >>> tracepoint) > > >>> lttng_statedump_end (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> lttng_statedump_process_state (loglevel: TRACE_EMERG (0)) > (type: > > >>> tracepoint) > > >>> lttng_statedump_file_descriptor (loglevel: TRACE_EMERG (0)) > (type: > > >>> tracepoint) > > >>> lttng_statedump_vm_map (loglevel: TRACE_EMERG (0)) (type: > > >>> tracepoint) > > >>> lttng_statedump_network_interface (loglevel: TRACE_EMERG (0)) > > >>> (type: tracepoint) > > >>> lttng_statedump_interrupt (loglevel: TRACE_EMERG (0)) (type: > > >>> tracepoint) > > >>> timer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> timer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> timer_expire_entry (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> timer_expire_exit (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> timer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> hrtimer_init (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> hrtimer_start (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> hrtimer_expire_entry (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> hrtimer_expire_exit (loglevel: TRACE_EMERG (0)) (type: > tracepoint) > > >>> hrtimer_cancel (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> itimer_state (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> itimer_expire (loglevel: TRACE_EMERG (0)) (type: tracepoint) > > >>> > > >>> root at android:/data/lttng/bin # > > >>> > > >>> Now I'm facing the issue of starting the traces: > > >>> debugging the sessiond, consumerd and lttng I concluded that the > issue > > >>> is due to splice system call failure. > > >>> even using a MMAP output type channel, the metadata channel is SPLICE > > >>> type (hard-coded). > > >>> Problem persists also when using relayd to pass the traces through > the > > >>> network. > > >>> Ignoring the splice failure means closing of the metadata channel > > >>> (maybe??) but need not affect the traces channel (right ?) > > >>> Attached is a debug log of each thread of the sessiond, right after > > >>> invoking "*./lttng start*". (with extra informative my prints) > > >>> > > >>> Please keep me in touch with any progress in this issue, > > >>> Thank you, > > >>> Amit. > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> ---------- Forwarded message ---------- > > >>> From: Amit Balboul > > >>> Date: Wed, Feb 27, 2013 at 4:37 PM > > >>> Subject: Re: [lttng-dev] compiling LTTng for android > > >>> To: PLSTC > > >>> > > >>> > > >>> Hey Pierre, > > >>> > > >>> Some major progress has been achieved, following is the summary: > > >>> > > >>> 1. Modules issue: > > >>> I built (for ARM/Android) and installed latest stable version of > busybox > > >>> on the device. > > >>> Seeing the code tries to run (hardcoded) /sbin/modprobe, made a soft > > >>> link to busybox's modeprobe. > > >>> Also, created /lib/modules/ directory and pushed the > > >>> directory from /lib/modules on the machine. > > >>> Now session daemon modprobes the desired modules successfully, (some > are > > >>> not present though as mentioned before) - no need to use insmod. > > >>> > > >>> 2. epoll_create1 issue: > > >>> epoll_create1 patch was OK, I accidentally defined EPOLL_CLOEXEC as > > >>> 0x02000000 instead of 02000000 (fixed). > > >>> > > >>> The running scenario: > > >>> > > >>> 1. Run ./lttng-sessiond -d -vvv > > >>> > > >>> Then: (commands are in bold, output is in blue for readability) > > >>> > > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng create s1* > > >>> > > >>> Session s1 created. > > >>> Traces will be written in /data/lttng-traces/s1-20130227-161145 > > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng > enable-channel > > >>> ch -k* > > >>> Kernel channel ch enabled for session s1 > > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng > enable-event ev > > >>> -k -a* > > >>> All kernel events are enabled in channel channel0 > > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng list s1* > > >>> Tracing session s1: [inactive] > > >>> Trace path: /data/lttng-traces/s1-20130227-161145 > > >>> > > >>> === Domain: Kernel === > > >>> > > >>> Channels: > > >>> ------------- > > >>> - channel0: [enabled] > > >>> > > >>> Attributes: > > >>> overwrite mode: 0 > > >>> subbufers size: 262144 > > >>> number of subbufers: 4 > > >>> switch timer interval: 0 > > >>> read timer interval: 200 > > >>> output: splice() > > >>> > > >>> Events: > > >>> None > > >>> > > >>> - ch: [enabled] > > >>> > > >>> Attributes: > > >>> overwrite mode: 0 > > >>> subbufers size: 262144 > > >>> number of subbufers: 4 > > >>> switch timer interval: 0 > > >>> read timer interval: 200 > > >>> output: splice() > > >>> > > >>> Events: > > >>> None > > >>> > > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng list -k * > > >>> > > >>> Kernel events: > > >>> ------------- > > >>> > > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng start* > > >>> Tracing started for session s1 > > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng stop * > > >>> > > >>> Waiting for data availability > > >>> Tracing stopped for session s1 > > >>> root at android:/data/lttng/install_sysroot/bin # > > >>> > > >>> *Now: (this is not surprising because the kernel events list is > > >>> empty...)* > > >>> the folder /data/lttng-traces/s1-20130227-161145/kernel contains: > > >>> total 0 > > >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_0 > > >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 ch_1 > > >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_0 > > >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 channel0_1 > > >>> -rwxrwxrwx 1 0 0 0 Feb 27 14:18 metadata > > >>> > > >>> *By the way:* > > >>> When running the same scenario but creating the channel with > *--output > > >>> mmap*, still no data but the size of the first two files in the > traces > > >>> directory are 4Kb (I didn't bother to investigate them as I assume > it is > > >>> just the header - not the traces payload). > > >>> > > >>> Another issue: at this point, listing the sessions gives: > > >>> root at android:/data/lttng/install_sysroot/bin # *./lttng list s1 * > > >>> > > >>> Tracing session s1: [inactive] > > >>> Trace path: /data/lttng-traces/s1-20130227-161145 > > >>> > > >>> === Domain: Kernel === > > >>> > > >>> Error: No kernel consumer detected > > >>> 99|root at android:/data/lttng/install_sysroot/bin # *./lttng list -k > * > > >>> > > >>> Error: Unable to list kernel events > > >>> Error: Command error > > >>> 1|root at android:/data/lttng/install_sysroot/bin # > > >>> > > >>> So currently I'm facing these issues: > > >>> 1. Kernel events list is empty. > > >>> 2. Listing the session/ kernel events after creating session, > channel, > > >>> event, start, stop - results in "no kernel consumer detected" > > >>> > > >>> If you have some insights please share them with me.. > > >>> > > >>> Thanks > > >>> > > >>> Amit. > > >>> > > >>> > > >>> On Tue, Feb 26, 2013 at 7:35 PM, PLSTC wrote: > > >>> > > >>>> The modules you can't find are the same I am also missing I > believe; I > > >>>> think they are only compiled when certain kernel config defines are > met > > >>>> (and those might simply be unavailable under ARM). > > >>>> > > >>>> As for what you pointed in your first mail, I believe modprobe isn't > > >>>> available on ARM, did you mean that some modules were not found > when using > > >>>> insmod? > > >>>> > > >>>> For the epoll_create1 problem, what kind of patch did you apply to > add > > >>>> support for the epoll_create1 function? > > >>>> > > >>>> > > >>>> On Tue, Feb 26, 2013 at 11:29 AM, Amit Balboul < > > >>>> amit.balboul at shinesec.com> wrote: > > >>>> > > >>>>> Ok I got : > > >>>>> lttng-kretprobes.ko > > >>>>> lttng-kprobes.ko > > >>>>> , the other two are missing. > > >>>>> > > >>>>> > > >>>>> ---------- Forwarded message ---------- > > >>>>> From: Amit Balboul > > >>>>> Date: Tue, Feb 26, 2013 at 5:49 PM > > >>>>> Subject: Re: [lttng-dev] compiling LTTng for android > > >>>>> To: PLSTC > > >>>>> > > >>>>> > > >>>>> One more thing: > > >>>>> > > >>>>> The list of modules you gave my is not identical to mine: > > >>>>> a. I pushed the modules from my machine to my folder in the device > > >>>>> (not to /system/lib) as you directed me, and insmoded them > manually. > > >>>>> b. I pushed the whole tree under /lib/modules// > > >>>>> which includes the modules.* and the sub directories: > > >>>>> > > >>>>> /lib/modules/3.0.31-gd5a18e0/extra$ ll > > >>>>> total 2464 > > >>>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ./ > > >>>>> drwxr-xr-x 3 root root 4096 Feb 26 15:58 ../ > > >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 lib/ > > >>>>> -rw-r--r-- 1 root root 167184 Feb 26 15:58 > > >>>>> lttng-ring-buffer-client-discard.ko > > >>>>> -rw-r--r-- 1 root root 167206 Feb 26 15:58 > > >>>>> lttng-ring-buffer-client-mmap-discard.ko > > >>>>> -rw-r--r-- 1 root root 178586 Feb 26 15:58 > > >>>>> lttng-ring-buffer-client-mmap-overwrite.ko > > >>>>> -rw-r--r-- 1 root root 178564 Feb 26 15:58 > > >>>>> lttng-ring-buffer-client-overwrite.ko > > >>>>> -rw-r--r-- 1 root root 137179 Feb 26 15:58 > > >>>>> lttng-ring-buffer-metadata-client.ko > > >>>>> -rw-r--r-- 1 root root 137233 Feb 26 15:58 > > >>>>> lttng-ring-buffer-metadata-mmap-client.ko > > >>>>> -rw-r--r-- 1 root root 213451 Feb 26 15:58 lttng-statedump.ko > > >>>>> -rw-r--r-- 1 root root 1314235 Feb 26 15:58 lttng-tracer.ko > > >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 probes/ > > >>>>> > > >>>>> /lib/modules/3.0.31-gd5a18e0/extra/lib$ ll > > >>>>> total 732 > > >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ > > >>>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ > > >>>>> -rw-r--r-- 1 root root 738964 Feb 26 15:58 lttng-lib-ring-buffer.ko > > >>>>> > > >>>>> /lib/modules/3.0.31-gd5a18e0/extra/probes$ ll > > >>>>> total 2872 > > >>>>> drwxr-xr-x 2 root root 4096 Feb 26 15:58 ./ > > >>>>> drwxr-xr-x 4 root root 4096 Feb 26 15:58 ../ > > >>>>> -rw-r--r-- 1 root root 162872 Feb 26 15:58 lttng-probe-asoc.ko > > >>>>> -rw-r--r-- 1 root root 171049 Feb 26 15:58 lttng-probe-block.ko > > >>>>> -rw-r--r-- 1 root root 81165 Feb 26 15:58 > lttng-probe-compaction.ko > > >>>>> -rw-r--r-- 1 root root 333215 Feb 26 15:58 lttng-probe-ext4.ko > > >>>>> -rw-r--r-- 1 root root 80413 Feb 26 15:58 lttng-probe-gpio.ko > > >>>>> -rw-r--r-- 1 root root 84256 Feb 26 15:58 lttng-probe-irq.ko > > >>>>> -rw-r--r-- 1 root root 135453 Feb 26 15:58 lttng-probe-jbd2.ko > > >>>>> -rw-r--r-- 1 root root 105399 Feb 26 15:58 lttng-probe-kmem.ko > > >>>>> -rw-r--r-- 1 root root 76240 Feb 26 15:58 lttng-probe-lttng.ko > > >>>>> -rw-r--r-- 1 root root 88059 Feb 26 15:58 lttng-probe-module.ko > > >>>>> -rw-r--r-- 1 root root 154032 Feb 26 15:58 lttng-probe-napi.ko > > >>>>> -rw-r--r-- 1 root root 142038 Feb 26 15:58 lttng-probe-net.ko > > >>>>> -rw-r--r-- 1 root root 93564 Feb 26 15:58 lttng-probe-power.ko > > >>>>> -rw-r--r-- 1 root root 85530 Feb 26 15:58 lttng-probe-regulator.ko > > >>>>> -rw-r--r-- 1 root root 138121 Feb 26 15:58 lttng-probe-sched.ko > > >>>>> -rw-r--r-- 1 root root 152909 Feb 26 15:58 lttng-probe-scsi.ko > > >>>>> -rw-r--r-- 1 root root 107491 Feb 26 15:58 lttng-probe-signal.ko > > >>>>> -rw-r--r-- 1 root root 142711 Feb 26 15:58 lttng-probe-skb.ko > > >>>>> -rw-r--r-- 1 root root 181983 Feb 26 15:58 lttng-probe-statedump.ko > > >>>>> -rw-r--r-- 1 root root 126731 Feb 26 15:58 lttng-probe-timer.ko > > >>>>> -rw-r--r-- 1 root root 86591 Feb 26 15:58 lttng-probe-workqueue.ko > > >>>>> -rw-r--r-- 1 root root 133886 Feb 26 15:58 lttng-probe-writeback.ko > > >>>>> -rw-r--r-- 1 root root 30863 Feb 26 15:58 lttng-types.ko > > >>>>> > > >>>>> Looking at the files shows I miss: > > >>>>> lttng-kretprobes.ko > > >>>>> lttng-kprobes.ko > > >>>>> lttng-ftrace.ko > > >>>>> lttng-probe-kvm.ko > > >>>>> > > >>>>> > > >>>>> On Tue, Feb 26, 2013 at 3:56 PM, PLSTC > wrote: > > >>>>> > > >>>>>> Back on the last email: > > >>>>>> > > >>>>>> Here's the insmod list I ended up building; you might not have > > >>>>>> compiled all those modules, depending on your kernel config and > on the > > >>>>>> architecture used, so some might simply be absent from your output > > >>>>>> directory. > > >>>>>> > > >>>>>> insmod /system/lib/modules/lttng-types.ko > > >>>>>> insmod /system/lib/modules/lttng-kretprobes.ko > > >>>>>> insmod /system/lib/modules/lttng-kprobes.ko > > >>>>>> insmod /system/lib/modules/lttng-ftrace.ko > > >>>>>> insmod /system/lib/modules/lttng-lib-ring-buffer.ko > > >>>>>> insmod /system/lib/modules/lttng-statedump.ko > > >>>>>> insmod /system/lib/modules/lttng-tracer.ko > > >>>>>> insmod /system/lib/modules/lttng-probe-timer.ko > > >>>>>> insmod /system/lib/modules/lttng-probe-statedump.ko > > >>>>>> insmod /system/lib/modules/lttng-probe-signal.ko > > >>>>>> insmod /system/lib/modules/lttng-probe-sched.ko > > >>>>>> insmod /system/lib/modules/lttng-probe-lttng.ko > > >>>>>> insmod /system/lib/modules/lttng-probe-kvm.ko > > >>>>>> insmod /system/lib/modules/lttng-probe-irq.ko > > >>>>>> insmod /system/lib/modules/lttng-probe-block.ko > > >>>>>> insmod > /system/lib/modules/lttng-ring-buffer-metadata-mmap-client.ko > > >>>>>> insmod /system/lib/modules/lttng-ring-buffer-metadata-client.ko > > >>>>>> insmod /system/lib/modules/lttng-ring-buffer-client-overwrite.ko > > >>>>>> insmod > /system/lib/modules/lttng-ring-buffer-client-mmap-overwrite.ko > > >>>>>> insmod > /system/lib/modules/lttng-ring-buffer-client-mmap-discard.ko > > >>>>>> insmod /system/lib/modules/lttng-ring-buffer-client-discard.ko > > >>>>>> > > >>>>>> > > >>>>>> We also haven't had time recently to test if the > kprobes/kretprobes > > >>>>>> worked, but they probably do; we decided to focus a bit more on > the > > >>>>>> 'tracepoints' aspect instead. > > >>>>>> > > >>>>>> Anyway, good luck with your exploration, and if you find something > > >>>>>> interesting, I'd love to know more about it! > > >>>>>> > > >>>>>> -PL > > >>>>>> > > >>>>>> On Tue, Feb 26, 2013 at 8:06 AM, PLSTC > wrote: > > >>>>>> > > >>>>>>> Hey Amit, > > >>>>>>> > > >>>>>>> Good news indeed it seems! > > >>>>>>> > > >>>>>>> When it comes to pushing the libs/bin, we haven't found any > better > > >>>>>>> way than using adb push yet; of course, if all the projects were > included > > >>>>>>> directly in Android's external, we would simply flash the device > after each > > >>>>>>> build, but currently we're still having trouble generating the > correct > > >>>>>>> Android makefiles. > > >>>>>>> > > >>>>>>> As for the modules, I might still have a dep load list somewhere > I > > >>>>>>> could send you in a few hours, I remember fighting to get the > order right... > > >>>>>>> > > >>>>>>> Also, once everything loads, could you tell me what kind of > output > > >>>>>>> 'lttng list -k' provides you? Here, we're having trouble listing > the > > >>>>>>> 'default' kernel trace points provided by HAVE_TRACEPOINTS, and > the > > >>>>>>> returned list is simply empty (which is a bit strange). > > >>>>>>> > > >>>>>>> -PL > > >>>>>>> > > >>>>>> > > >>>>>> > > >>>>> > > >>>>> > > >>>> > > >>> > > >>> > > > > > > _______________________________________________ > > lttng-dev mailing list > > lttng-dev at lists.lttng.org > > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From christian.babeux at efficios.com Mon Mar 18 15:00:09 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Mon, 18 Mar 2013 15:00:09 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Tests: Fix nprocesses applications shutdown Message-ID: <1363633209-7528-1-git-send-email-christian.babeux@efficios.com> The nprocesses test is using the SIGPIPE signal to shutdown the spawned child applications. This is done in order to silence the shell message such as this one: "nprocesses/test_nprocesses: line 79: 26458 Terminated" This mechanism is broken on systems where the SIGPIPE default handler is overriden (thus no application shutdown occurs) in the executing environment. This could lead to stale applications polluting the system and causing heratic behavior in subsequent tests. This commit add a loop and check that all the spawned applications have been successfully killed. Signed-off-by: Christian Babeux --- tests/regression/ust/nprocesses/test_nprocesses | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/regression/ust/nprocesses/test_nprocesses b/tests/regression/ust/nprocesses/test_nprocesses index e89d02e..23d9a0a 100755 --- a/tests/regression/ust/nprocesses/test_nprocesses +++ b/tests/regression/ust/nprocesses/test_nprocesses @@ -74,8 +74,10 @@ destroy_lttng_session $SESSION_NAME rm -rf $TRACE_PATH -# Send SIGPIPE to 'silence' bash process status such as "Process as terminated" -killall -s PIPE -q $TEST_BIN_NAME >/dev/null 2>&1 +while [ -n "$(pidof $TEST_BIN_NAME)" ]; do + killall -q $TEST_BIN_NAME >/dev/null 2>&1 + sleep 0.5 +done pass "Kill all spawned applications" -- 1.8.1.3 From jeremie.galarneau at efficios.com Mon Mar 18 16:58:08 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Mon, 18 Mar 2013 16:58:08 -0400 Subject: [lttng-dev] dlopen, gcc -l and LD_PRELOAD In-Reply-To: <48CF5AC71E61DB46B70D0F388054EFFD028674@VAL-E-01.valcartier.drdc-rddc.gc.ca> References: <48CF5AC71E61DB46B70D0F388054EFFD027A2C@VAL-E-01.valcartier.drdc-rddc.gc.ca> <48CF5AC71E61DB46B70D0F388054EFFD028674@VAL-E-01.valcartier.drdc-rddc.gc.ca> Message-ID: On Mon, Mar 18, 2013 at 3:07 PM, Thibault, Daniel wrote: > -----Message d'origine----- > Envoy? : 15 mars 2013 15:33 > > On Fri, Mar 15, 2013 at 12:41 PM, Thibault, Daniel wrote: >> In the lttng-ust man pages, there is a paragraph that reads: >> >> Note about dlopen() usage: Due to locking side-effects caused by the way libc lazily resolves Thread-Local Storage (TLS) symbols when a library is dlopened, linking the tracepoint probe or liblttng-ust with dlopen() is discouraged. They should be linked with the application using "-llibname" or loaded with LD_PRELOAD. >> >> I'm confused by the LD_PRELOAD bit: as far as I know, LD_PRELOAD serves only to substitute a dynamic library (the LD_PRELOAD argument) for another (the one the executable was linked against). I don't see how one could compile an instrumented application and leave its tracepoint provider unlinked, which is what the stated -llibname <-> LD_PRELOAD opposition implies. >> > > You may want to have a look at the comment at > lttng-ust/include/lttng/tracepoint.h:229 which explains how this is accomplished. Basically, the tracepoint provider symbols are initialised and the probe is registered when the provider's shared object constructor is invoked. See ust-tracepoint-event.h:671 if you are interested in the actual implementation. > >> (Also, shouldn't that paragraph drop 'lazily', assuming the locking >> problems also arise if dlopen is used with RTLD_NOW? Because if >> RTLD_NOW fixed the locking problem, that's what would be recommended >> here, no?) > > Good question. I think this problem has been fixed as part of the 2.1 release. However, I do know there are other issues related to "dlopen()"-ing probe providers; details on the bug tracker[1]. > > J?r?mie > [1] https://bugs.lttng.org/issues/447 > -----Fin du message d'origine----- > > Bug 447 concerns dlclose(), not dlopen(). It's a legitimate concern (that has yet to be addressed, it seems), but it has nothing to do with potential delays or deadlocks upon calling dlopen() on a tracepoint provider. > Indeed, hence why I have mentioned there were _other_ potential issues with the dynamic linking loader interface of which you should be aware before using it to load the providers. > I'm not concerned with how the tracepoint provider initialises its symbols and registers its probe(s) with the session daemons when its constructor is invoked, I'm just trying to figure out what "They [the tracepoint provider and liblttng-ust] should be linked with the application using '-llibname' or loaded with LD_PRELOAD" means. The first part of the (apparently exclusive) or clearly refers to implementing the tracepoint provider as an .so but making the instrumented application statically aware of it (I'm dubious anyone would try to use liblttng-ust through dlopen(), though). Is the second part saying that if the app explicitly loads the tracepoint provider .so through dlopen(), setting LD_PRELOAD when calling the app will fix (circumvent) the locking problems? > Typically, you would want to do one or the other [dlopen or LD_PRELOAD]. But to answer your question, yes, this would workaround the locking problem described in the man page that affected prior versions of lttng-ust (before 2.1). > For that matter, I have yet to successfully divine what a tracepoint provider .so makefile should look like (the lttng-ust man pages don't give an understandable example, and my experience with dynamic libraries has mostly been under Windows). If you could provide one, I'd be grateful. Here's as far as I've got, using lttng-ust/doc/example/easy-ust: > Have a look at the Makefiles and sources in lttng-ust/tests/demo and lttng-ust/tests/daemon which respectively demonstrate the use of tracepoint providers that are dynamically linked and built as part of the traced application. > The normal Makefile: > > CC = gcc > LIBS = -ldl -llttng-ust # On Linux > #LIBS = -lc -llttng-ust # On BSD > CFLAGS = -I. > LDFLAGS = -L/usr/local/lib > > all: sample > > sample: sample.o tp.o > $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) > > sample.o: sample.c sample_component_provider.h > $(CC) $(CFLAGS) -c -o $@ $(LDFLAGS) $< > > tp.o: tp.c sample_component_provider.h > $(CC) $(CFLAGS) -c -o $@ $(LDFLAGS) $< > [...] > > Yields: > gcc -I. -c -o sample.o -L/usr/local/lib sample.c > gcc -I. -c -o tp.o -L/usr/local/lib tp.c > gcc -o sample sample.o tp.o -L/usr/local/lib -ldl -llttng-ust > > I can make sample using a static library instead, by changing the Makefile thus: > > AR = ar > CC = gcc > [...] > sample: sample.o libtp.a > $(CC) -o $@ $^ $(LDFLAGS) -L. $(LIBS) > > sample.o: sample.c sample_component_provider.h > $(CC) $(CFLAGS) -c -o $@ $(LDFLAGS) $< > > libtp.a: tp.o > $(AR) -cq $@ $< > > tp.o: tp.c sample_component_provider.h > $(CC) $(CFLAGS) -c -o $@ $(LDFLAGS) $< > [...] > > Which yields: > gcc -I. -c -o sample.o -L/usr/local/lib sample.c > gcc -I. -c -o tp.o -L/usr/local/lib tp.c > ar -cq libtp.a tp.o > gcc -o sample sample.o libtp.a -L/usr/local/lib -L. -ldl -llttng-ust > > In switching to a statically aware dynamic library, I first modify sample.c by adding '#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE' right after '#define TRACEPOINT_DEFINE'. > > Then I've tried to use this Makefile: > > CC = gcc > LIBS = -ldl -llttng-ust # On Linux > #LIBS = -lc -llttng-ust # On BSD > CFLAGS = -I. > SOFLAGS = -fPIC > SOVERSION_MAJOR = 1 > SOVERSION_MINOR = 0 > LDFLAGS = -L/usr/local/lib > > all: libtp.so sample > > sample: sample.o > $(CC) -o $@ $< $(LDFLAGS) $(LIBS) -L. -ltp > > sample.o: sample_so.c sample_component_provider.h > $(CC) $(CFLAGS) -c -o $@ $(LDFLAGS) $(LIBS) -L. -ltp $< > > libtp.so: tp.o > $(CC) -shared -W1,-soname,$@.$(SOVERSION_MAJOR) -o $@.$(SOVERSION_MAJOR).$(SOVERSION_MINOR) $(LDFLAGS) $(LIBS) $< > ln -sf $@.$(SOVERSION_MAJOR).$(SOVERSION_MINOR) $@.$(SOVERSION_MAJOR) > ln -sf $@.$(SOVERSION_MAJOR) $@ > > tp.o: tp.c sample_component_provider.h > $(CC) $(CFLAGS) $(SOFLAGS) $(LDFLAGS) $(LIBS) -c -o $@ $< > > Which yields: > gcc -I. -fPIC -L/usr/local/lib -ldl -llttng-ust -c -o tp.o tp.c > gcc -shared -W1,-soname,libtp.so.1 -o libtp.so.1.0 -L/usr/local/lib -ldl -llttng-ust tp.o > ln -sf libtp.so.1.0 libtp.so.1 > ln -sf libtp.so.1 libtp.so > gcc -I. -c -o sample.o -L/usr/local/lib -ldl -llttng-ust -L. -ltp sample.c > gcc -o sample sample.o -L/usr/local/lib -ldl -llttng-ust -L. -ltp > /usr/bin/ld: warning: hidden symbol 'tracepoint_dlopen' in sample.o is referenced by DSO ./libtp.so > > I've tried a number of things to get rid of the warning. For some reason the 'tracepoint_dlopen' struct symbol in tp.o gets linked (when building 'sample' in the last step) to the one in sample.o (which has the same source: the sample_component_provider.h) instead of the one in liblttng-ust. If I try a command like 'LD_PRELOAD=./libtp.so ./sample', I get "symbol lookup error: ./libtp.so: undefined symbol: tracepoint_dlopen". > > I'm sure this is a very simple, obvious, dumb mistake, so please point it out to me! > > lttng-ust/tests/demo/demo-trace, although built by lttng-ust's make, also has the tracepoint_dlopen problem. This now looks like a bug introduced somewhen since the demos were written (and last tested, it seems). I don't see this warning and error here. Which release are you using? > Daniel U. Thibault > R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) > Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) > Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) > 2459 route de la Bravoure > Qu?bec, QC G3J 1X5 > CANADA > Vox : (418) 844-4000 x4245 > Fax : (418) 844-4538 > NAC : 918V QSDJ > Gouvernement du Canada / Government of Canada > From nathanm2 at linux.vnet.ibm.com Mon Mar 18 19:58:10 2013 From: nathanm2 at linux.vnet.ibm.com (nathanm2 at linux.vnet.ibm.com) Date: Mon, 18 Mar 2013 19:58:10 -0400 Subject: [lttng-dev] Extracting LTTng ring buffers from a vmcore? Message-ID: <20130318195810.Horde.Fv0FZZir309RR6oS2LPiI2A@imap.linux.ibm.com> While reading through the lib_ring_buffer_commit function I came across the following comment: /* * Update used size at each commit. It's needed only for extracting * ring_buffer buffers from vmcore, after crash. */ I need something exactly like this, but didn't see anything while looking through the lttng tools. Did I miss something? Thanks Nate From yao at codesourcery.com Mon Mar 18 21:01:45 2013 From: yao at codesourcery.com (Yao Qi) Date: Tue, 19 Mar 2013 09:01:45 +0800 Subject: [lttng-dev] [PATCH] Teach babeltrace understand "native" and "network" for byte_order In-Reply-To: <20130315153320.GA1659@Krystal> References: <1363341137-26956-1-git-send-email-yao@codesourcery.com> <20130315120753.GA30973@Krystal> <20130315143337.GA959@Krystal> <51433B38.3080805@codesourcery.com> <20130315153320.GA1659@Krystal> Message-ID: <5147B8F9.3050308@codesourcery.com> On 03/15/2013 11:33 PM, Mathieu Desnoyers wrote: > I added an explanatory paragraph for "native" in addition to your > recommended changes. We cannot remove an keyword from the specification > lightly, because this would break compatibility. It looks pretty good. Thanks for doing this. -- Yao (??) From David.OShea at quantum.com Tue Mar 19 00:54:05 2013 From: David.OShea at quantum.com (David OShea) Date: Tue, 19 Mar 2013 04:54:05 +0000 Subject: [lttng-dev] dlopen, gcc -l and LD_PRELOAD In-Reply-To: References: <48CF5AC71E61DB46B70D0F388054EFFD027A2C@VAL-E-01.valcartier.drdc-rddc.gc.ca> <48CF5AC71E61DB46B70D0F388054EFFD028674@VAL-E-01.valcartier.drdc-rddc.gc.ca> Message-ID: <20998D40D9A2B7499CA5A3A2666CB1EB23FCD7EF@ZURMSG1.QUANTUM.com> Hi all, > -----Original Message----- > From: J?r?mie Galarneau [mailto:jeremie.galarneau at efficios.com] > Sent: Tuesday, 19 March 2013 7:28 AM > To: Thibault, Daniel > Cc: lttng-dev at lists.lttng.org > Subject: Re: [lttng-dev] dlopen, gcc -l and LD_PRELOAD > > Good question. I think this problem has been fixed as part of the 2.1 > release. However, I do know there are other issues related to > "dlopen()"-ing probe providers; details on the bug tracker[1]. > > > > J?r?mie > > [1] https://bugs.lttng.org/issues/447 > > -----Fin du message d'origine----- > > > > Bug 447 concerns dlclose(), not dlopen(). It's a legitimate > concern (that has yet to be addressed, it seems), but it has nothing to > do with potential delays or deadlocks upon calling dlopen() on a > tracepoint provider. [...] > Typically, you would want to do one or the other [dlopen or > LD_PRELOAD]. But to answer your question, yes, this would workaround > the locking problem described in the man page that affected prior > versions of lttng-ust (before 2.1). FYI I mentioned my email to this list dated 25/Feb/2013 that: "I noticed that commit ID b834deadbfa8a78ae1d00440fd91c41dfd351eba changed README to remove a note suggesting that dlopen() not be used. It looks like the same change should be made to doc/man/lttng-ust.3, which still suggests that you not use dlopen()." Just a reminder that it does appear to have been intended that that note be removed, so it should probably be disregarded. Also, if anyone is able to provide explanations for the questions in my previous email, that might serve to address the topic of this thread too. Thanks, David ---------------------------------------------------------------------- The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt. From Daniel.Thibault at drdc-rddc.gc.ca Tue Mar 19 10:03:21 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Tue, 19 Mar 2013 14:03:21 +0000 Subject: [lttng-dev] dlopen, gcc -l and LD_PRELOAD In-Reply-To: <20998D40D9A2B7499CA5A3A2666CB1EB23FCD7EF@ZURMSG1.QUANTUM.com> References: <48CF5AC71E61DB46B70D0F388054EFFD027A2C@VAL-E-01.valcartier.drdc-rddc.gc.ca> <48CF5AC71E61DB46B70D0F388054EFFD028674@VAL-E-01.valcartier.drdc-rddc.gc.ca> <20998D40D9A2B7499CA5A3A2666CB1EB23FCD7EF@ZURMSG1.QUANTUM.com> Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD028844@VAL-E-01.valcartier.drdc-rddc.gc.ca> > "I noticed that commit ID b834deadbfa8a78ae1d00440fd91c41dfd351eba changed README to remove a note suggesting that dlopen() not be used. It looks like the same change should be made to doc/man/lttng-ust.3, which still suggests that you not use dlopen()." > > Just a reminder that it does appear to have been intended that that note be removed, so it should probably be disregarded. > You may want to have a look at the comment at > lttng-ust/include/lttng/tracepoint.h:229 which explains how this is accomplished. Basically, the tracepoint provider symbols are initialised and the probe is registered when the provider's shared object constructor is invoked. See ust-tracepoint-event.h:671 if you are interested in the actual implementation. > Have a look at the Makefiles and sources in lttng-ust/tests/demo and lttng-ust/tests/daemon which respectively demonstrate the use of tracepoint providers that are dynamically linked and built as part of the traced application. The Makefile in lttng-ust/tests/demo is generated by automake and therefore horrendously large and complicated. If there is a simple series of compile and link commands in there concerning the demo, that fish is thoroughly drowned. I spotted one demo$(EXEXT) target which looked promising. After oodles of substitutions and presuming six undefined variables were blank, it resolves to: demo : demo.o @rm -f demo @echo " CCLD " $@;/bin/bash ../../libtool --silent --tag=CC --mode=link gcc -Wall -g -02 -L/usr/local/lib -o $@ demo.o -ldl ...which isn't very enlightening (in the sense that it looks pretty plain). There is in fact no trace of '.so' or '-fPIC' in the make. What is needed is a pared-down makefile like the one in easy-ust. I think I have figured out the correct outline, except for the tracepoint_dlopen problem. But since the package's demo-trace runs smack into the same error, I'm suspecting the fault may not be mine. Googling for this error turns up mostly cases where -shared was omitted from the lib*.so gcc call, resulting in pieces of static libraries being imported into dynamic ones. This is not what's going on here. > > /usr/bin/ld: warning: hidden symbol 'tracepoint_dlopen' in sample.o is referenced by DSO ./libtp.so > > > > lttng-ust/tests/demo/demo-trace, although built by lttng-ust's make, also has the tracepoint_dlopen problem. This now looks like a bug introduced somewhen since the demos were written (and last tested, it seems). > > I don't see this warning and error here. Which release are you using? lttng-modules 2.1.1+ (74b9312, 2013-02-27) lttng-tools 2.1.1+ (e58727c, 2013-03-01) lttng-ust 2.1.1+ (009769c, 2013-03-05) userspace-rcu 0.7.6+ (108a92e, 2013-02-22) (All are moderately dated by now, but none of the later commit comments seem pertinent) If I run lttng-ust/tests/demo/demo-trace, I get: ./demo: symbol lookup error: .libs/liblttng-ust-provider-ust-tests-demo3.so: undefined symbol: tracepoint_dlopen All that demo-trace does is LD_PRELOAD .libs/liblttng-ust-provider-ust-tests-demo.so and .libs/liblttng-ust-provider-ust-tests-demo3.so before running ./demo The make of lttng-ust, when it compiled demo.o, only warned that struct mmsghdr was declared inside a parameter list (/usr/include/x86_64-linux-gnu/bits/socket.h so it's not even an lttng problem). Are you saying you can't reproduce this? Your demo-trace runs and generates events? Meanwhile I'll dive in and try to untangle what TRACEPOINT_PROBE_DYNAMIC_LINKAGE does. Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC? G3J 1X5 CANADA Vox?: (418) 844-4000 x4245 Fax?: (418) 844-4538 NAC?: 918V QSDJ Gouvernement du Canada?/ Government of Canada From jeremie.galarneau at efficios.com Tue Mar 19 11:51:29 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Tue, 19 Mar 2013 11:51:29 -0400 Subject: [lttng-dev] dlopen, gcc -l and LD_PRELOAD In-Reply-To: <48CF5AC71E61DB46B70D0F388054EFFD028844@VAL-E-01.valcartier.drdc-rddc.gc.ca> References: <48CF5AC71E61DB46B70D0F388054EFFD027A2C@VAL-E-01.valcartier.drdc-rddc.gc.ca> <48CF5AC71E61DB46B70D0F388054EFFD028674@VAL-E-01.valcartier.drdc-rddc.gc.ca> <20998D40D9A2B7499CA5A3A2666CB1EB23FCD7EF@ZURMSG1.QUANTUM.com> <48CF5AC71E61DB46B70D0F388054EFFD028844@VAL-E-01.valcartier.drdc-rddc.gc.ca> Message-ID: On Tue, Mar 19, 2013 at 10:03 AM, Thibault, Daniel wrote: >> "I noticed that commit ID b834deadbfa8a78ae1d00440fd91c41dfd351eba changed README to remove a note suggesting that dlopen() not be used. It looks like the same change should be made to doc/man/lttng-ust.3, which still suggests that you not use dlopen()." >> >> Just a reminder that it does appear to have been intended that that note be removed, so it should probably be disregarded. > >> You may want to have a look at the comment at >> lttng-ust/include/lttng/tracepoint.h:229 which explains how this is accomplished. Basically, the tracepoint provider symbols are initialised and the probe is registered when the provider's shared object constructor is invoked. See ust-tracepoint-event.h:671 if you are interested in the actual implementation. > >> Have a look at the Makefiles and sources in lttng-ust/tests/demo and lttng-ust/tests/daemon which respectively demonstrate the use of tracepoint providers that are dynamically linked and built as part of the traced application. > > The Makefile in lttng-ust/tests/demo is generated by automake and therefore horrendously large and complicated. If there is a simple series of compile and link commands in there concerning the demo, that fish is thoroughly drowned. I spotted one demo$(EXEXT) target which looked promising. After oodles of substitutions and presuming six undefined variables were blank, it resolves to: > > demo : demo.o > @rm -f demo > @echo " CCLD " $@;/bin/bash ../../libtool --silent --tag=CC --mode=link gcc -Wall -g -02 -L/usr/local/lib -o $@ demo.o -ldl > > ...which isn't very enlightening (in the sense that it looks pretty plain). There is in fact no trace of '.so' or '-fPIC' in the make. What is needed is a pared-down makefile like the one in easy-ust. I think I have figured out the correct outline, except for the tracepoint_dlopen problem. But since the package's demo-trace runs smack into the same error, I'm suspecting the fault may not be mine. Googling for this error turns up mostly cases where -shared was omitted from the lib*.so gcc call, resulting in pieces of static libraries being imported into dynamic ones. This is not what's going on here. > >> > /usr/bin/ld: warning: hidden symbol 'tracepoint_dlopen' in sample.o is referenced by DSO ./libtp.so >> > >> > lttng-ust/tests/demo/demo-trace, although built by lttng-ust's make, also has the tracepoint_dlopen problem. This now looks like a bug introduced somewhen since the demos were written (and last tested, it seems). >> >> I don't see this warning and error here. Which release are you using? > > lttng-modules 2.1.1+ (74b9312, 2013-02-27) > lttng-tools 2.1.1+ (e58727c, 2013-03-01) > lttng-ust 2.1.1+ (009769c, 2013-03-05) > userspace-rcu 0.7.6+ (108a92e, 2013-02-22) > I can confirm I'm able to reproduce the problem with these versions. > (All are moderately dated by now, but none of the later commit comments seem pertinent) > This revision fixed the "undefined symbol: tracepoint_dlopen" problem: https://bugs.lttng.org/projects/lttng-ust/repository/revisions/558b9d86247004f8e9bbaf8c982f3b2b182093d1 > If I run lttng-ust/tests/demo/demo-trace, I get: > > ./demo: symbol lookup error: .libs/liblttng-ust-provider-ust-tests-demo3.so: undefined symbol: tracepoint_dlopen > > All that demo-trace does is LD_PRELOAD .libs/liblttng-ust-provider-ust-tests-demo.so and .libs/liblttng-ust-provider-ust-tests-demo3.so before running ./demo > > The make of lttng-ust, when it compiled demo.o, only warned that struct mmsghdr was declared inside a parameter list (/usr/include/x86_64-linux-gnu/bits/socket.h so it's not even an lttng problem). > > Are you saying you can't reproduce this? Your demo-trace runs and generates events? > > Meanwhile I'll dive in and try to untangle what TRACEPOINT_PROBE_DYNAMIC_LINKAGE does. > > Daniel U. Thibault > R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) > Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) > Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) > 2459 route de la Bravoure > Qu?bec, QC G3J 1X5 > CANADA > Vox : (418) 844-4000 x4245 > Fax : (418) 844-4538 > NAC : 918V QSDJ > Gouvernement du Canada / Government of Canada > From dgoulet at efficios.com Tue Mar 19 12:05:43 2013 From: dgoulet at efficios.com (David Goulet) Date: Tue, 19 Mar 2013 12:05:43 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Tests: Fix nprocesses applications shutdown In-Reply-To: <1363633209-7528-1-git-send-email-christian.babeux@efficios.com> References: <1363633209-7528-1-git-send-email-christian.babeux@efficios.com> Message-ID: <51488CD7.5050200@efficios.com> I have a problem with that. This gets printed for every application: ./test_nprocesses: line 80: 30283 Terminated ./$CURDIR/$TEST_BIN_NAME 1000 > /dev/null 2>&1 The output is not pretty :P I'm having overall problem with this test for two reasons. First, with the new changes, registering an application takes a bit longer because of the back and forth notification event to register events and channels. This makes the "list application validation" fail most of the time. Increasing the sleep time helps but it is VERY ARBITRARY. The second thing is that running this test with a normal user, too many open files is hit in the consumer and the test of course fails. So, I think I'll have to find a clever way to validate applications so not to wait an arbitrary amount of time and probably drop the applications from 100 to 50. David Christian Babeux: > The nprocesses test is using the SIGPIPE signal to shutdown the > spawned child applications. This is done in order to silence > the shell message such as this one: > > "nprocesses/test_nprocesses: line 79: 26458 Terminated" > > This mechanism is broken on systems where the SIGPIPE default handler > is overriden (thus no application shutdown occurs) in the executing > environment. This could lead to stale applications polluting the system > and causing heratic behavior in subsequent tests. > > This commit add a loop and check that all the spawned applications have > been successfully killed. > > Signed-off-by: Christian Babeux > --- > tests/regression/ust/nprocesses/test_nprocesses | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/tests/regression/ust/nprocesses/test_nprocesses b/tests/regression/ust/nprocesses/test_nprocesses > index e89d02e..23d9a0a 100755 > --- a/tests/regression/ust/nprocesses/test_nprocesses > +++ b/tests/regression/ust/nprocesses/test_nprocesses > @@ -74,8 +74,10 @@ destroy_lttng_session $SESSION_NAME > > rm -rf $TRACE_PATH > > -# Send SIGPIPE to 'silence' bash process status such as "Process as terminated" > -killall -s PIPE -q $TEST_BIN_NAME >/dev/null 2>&1 > +while [ -n "$(pidof $TEST_BIN_NAME)" ]; do > + killall -q $TEST_BIN_NAME >/dev/null 2>&1 > + sleep 0.5 > +done > > pass "Kill all spawned applications" > From simon.marchi at polymtl.ca Tue Mar 19 14:10:25 2013 From: simon.marchi at polymtl.ca (Simon Marchi) Date: Tue, 19 Mar 2013 14:10:25 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Fix consumer_allocate_channel function signature Message-ID: <1363716626-25101-1-git-send-email-simon.marchi@polymtl.ca> Signed-off-by: Simon Marchi --- src/common/consumer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/consumer.c b/src/common/consumer.c index 300fd2a..8730e39 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -820,7 +820,7 @@ error: * * On error, return NULL. */ -struct lttng_consumer_channel *consumer_allocate_channel(unsigned long key, +struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, uint64_t session_id, const char *pathname, const char *name, -- 1.7.10.4 From dgoulet at efficios.com Tue Mar 19 14:12:01 2013 From: dgoulet at efficios.com (David Goulet) Date: Tue, 19 Mar 2013 14:12:01 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Fix consumer_allocate_channel function signature In-Reply-To: <1363716626-25101-1-git-send-email-simon.marchi@polymtl.ca> References: <1363716626-25101-1-git-send-email-simon.marchi@polymtl.ca> Message-ID: <5148AA71.1040701@efficios.com> Oh I did that already ;) It's fixed in my dev. branch which should be upstream soon! Thanks David Simon Marchi: > Signed-off-by: Simon Marchi > --- > src/common/consumer.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/common/consumer.c b/src/common/consumer.c > index 300fd2a..8730e39 100644 > --- a/src/common/consumer.c > +++ b/src/common/consumer.c > @@ -820,7 +820,7 @@ error: > * > * On error, return NULL. > */ > -struct lttng_consumer_channel *consumer_allocate_channel(unsigned long key, > +struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, > uint64_t session_id, > const char *pathname, > const char *name, From Bernd.Hufmann at ericsson.com Tue Mar 19 15:03:06 2013 From: Bernd.Hufmann at ericsson.com (Bernd Hufmann) Date: Tue, 19 Mar 2013 15:03:06 -0400 Subject: [lttng-dev] Error using add-context for perf counters Message-ID: <5148B66A.6080007@ericsson.com> Hello I cannot add contexts for perf counters using lttng-tools v2.1.1 and I get an error (see below). When using lttng-tools 2.0.5 (on a different computer) it works. Could somebody from lttng development team look into that? Thanks Bernd ---------------------------------------------------------------------- > lttng create mySession Session mySession created. Traces will be written in /home/bernd/lttng-traces/mySession-20130319-145021 > lttng enable-event -a -k All kernel events are enabled in channel channel0 > lttng add-context -k -t perf:branch-misses -t perf:cache-misses PERROR: add context ioctl: Invalid argument [in kernel_add_channel_context() at kernel.c:47] Error: perf:cache-misses: Add kernel context failed PERROR: add context ioctl: Invalid argument [in kernel_add_channel_context() at kernel.c:47] Error: perf:branch-misses: Add kernel context failed Warning: Some command(s) went wrong ----------------------------------------------------------------------- My setup is: Ubuntu 12.04 with kernel 3.2.0-38 lttng-modules v2.1.1 lttng-tools v2.1.1 -- This Communication is Confidential. We only send and receive email on the basis of the terms set out at www.ericsson.com/email_disclaimer From simon.marchi at polymtl.ca Tue Mar 19 15:12:12 2013 From: simon.marchi at polymtl.ca (Simon Marchi) Date: Tue, 19 Mar 2013 15:12:12 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Add with-sessiond-bin configure option In-Reply-To: <1362094937-6677-1-git-send-email-simon.marchi@polymtl.ca> References: <1362094937-6677-1-git-send-email-simon.marchi@polymtl.ca> Message-ID: Bump. On 28 February 2013 18:42, Simon Marchi wrote: > I also cleaned up the little check_sessiond function. The check using > access(2) was only done for the command line option, but I think it is a > good idea to do it wherever the path comes from. > > closes #441 > > Signed-off-by: Simon Marchi > --- > configure.ac | 17 +++++++++++++++++ > src/bin/lttng/lttng.c | 37 ++++++++++++++++++++----------------- > 2 files changed, 37 insertions(+), 17 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 71fbb60..7349713 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -91,12 +91,20 @@ AC_ARG_WITH([consumerd64-libdir], > [CONSUMERD64_LIBDIR='']) > AC_SUBST([CONSUMERD64_LIBDIR]) > > +AC_ARG_WITH([sessiond-bin], > + AS_HELP_STRING([--with-sessiond-bin], > + [Location of the sessiond executable (including the filename)]), > + [SESSIOND_BIN="$withval"], > + [SESSIOND_BIN='']) > +AC_SUBST([SESSIOND_BIN]) > + > AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD32_BIN], "$CONSUMERD32_BIN", [Location of the 32-bit consumerd executable.]) > AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD64_BIN], "$CONSUMERD64_BIN", [Location of the 64-bit consumerd executable]) > AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD32_LIBDIR], "$CONSUMERD32_LIBDIR", [Search for consumerd 32-bit libraries in this location.]) > AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD64_LIBDIR], "$CONSUMERD64_LIBDIR", [Search for consumerd 64-bit libraries in this location.]) > AC_DEFINE_UNQUOTED([CONFIG_BABELTRACE_BIN], "$BABELTRACE_BIN", [Location of the babeltrace viewer executable.]) > AC_DEFINE_UNQUOTED([CONFIG_LTTV_GUI_BIN], "$LTTV_GUI_BIN", [Location of the lttv GUI viewer executable.]) > +AC_DEFINE_UNQUOTED([CONFIG_SESSIOND_BIN], "$SESSIOND_BIN", [Location of the sessiond executable.]) > > # Check for pthread > AC_CHECK_LIB([pthread], [pthread_create], [], > @@ -383,6 +391,15 @@ AS_ECHO("`eval eval echo $libdir`") > # If we build the sessiond, print the paths it will use > AS_IF([test "x$consumerd_only" = "xno"],[ > AS_ECHO() > + AS_ECHO_N("The lttng command will look for the lttng-sessiond executable at: ") > + AS_IF([test "$SESSIOND_BIN" = ""],[ > + AS_ECHO_N("`eval eval echo $bindir`") > + AS_ECHO("/lttng-sessiond") > + ],[ > + AS_ECHO("$SESSIOND_BIN") > + ]) > + > + AS_ECHO() > AS_ECHO("The sessiond daemon will look in the following directories: ") > AS_ECHO_N("32-bit consumerd executable at: ") > AS_IF([test "$CONSUMERD32_BIN" = ""],[ > diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c > index 8562144..4097956 100644 > --- a/src/bin/lttng/lttng.c > +++ b/src/bin/lttng/lttng.c > @@ -346,35 +346,38 @@ end: > static int check_sessiond(void) > { > int ret; > - char *pathname = NULL, *alloc_pathname = NULL; > + char *pathname = NULL; > > ret = lttng_session_daemon_alive(); > if (ret == 0) { /* not alive */ > /* Try command line option path */ > - if (opt_sessiond_path != NULL) { > - ret = access(opt_sessiond_path, F_OK | X_OK); > - if (ret < 0) { > - ERR("No such file or access denied: %s", opt_sessiond_path); > - goto end; > - } > - pathname = opt_sessiond_path; > - } else { > - /* Try LTTNG_SESSIOND_PATH env variable */ > + pathname = opt_sessiond_path; > + > + /* Try LTTNG_SESSIOND_PATH env variable */ > + if (pathname == NULL) { > pathname = getenv(DEFAULT_SESSIOND_PATH_ENV); > } > > - /* Let's rock and roll */ > + /* Try with configured path */ > if (pathname == NULL) { > - ret = asprintf(&alloc_pathname, INSTALL_BIN_PATH "/lttng-sessiond"); > - if (ret < 0) { > - perror("asprintf spawn sessiond"); > - goto end; > + if (CONFIG_SESSIOND_BIN[0] != '\0') { > + pathname = CONFIG_SESSIOND_BIN; > } > - pathname = alloc_pathname; > + } > + > + /* Let's rock and roll while trying the default path */ > + if (pathname == NULL) { > + pathname = INSTALL_BIN_PATH "/lttng-sessiond"; > + } > + > + /* Check existence and permissions */ > + ret = access(pathname, F_OK | X_OK); > + if (ret < 0) { > + ERR("No such file or access denied: %s", pathname); > + goto end; > } > > ret = spawn_sessiond(pathname); > - free(alloc_pathname); > if (ret < 0) { > ERR("Problem occurred when starting %s", pathname); > goto end; > -- > 1.7.1 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From dgoulet at efficios.com Tue Mar 19 15:19:13 2013 From: dgoulet at efficios.com (David Goulet) Date: Tue, 19 Mar 2013 15:19:13 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Add with-sessiond-bin configure option In-Reply-To: References: <1362094937-6677-1-git-send-email-simon.marchi@polymtl.ca> Message-ID: <5148BA31.6060803@efficios.com> It's still on my stack. Don't worry. I have my hands full with the 2.2 development. Don't worry, this will be review and merged before the release. Thanks David Simon Marchi: > Bump. > > On 28 February 2013 18:42, Simon Marchi wrote: >> I also cleaned up the little check_sessiond function. The check using >> access(2) was only done for the command line option, but I think it is a >> good idea to do it wherever the path comes from. >> >> closes #441 >> >> Signed-off-by: Simon Marchi >> --- >> configure.ac | 17 +++++++++++++++++ >> src/bin/lttng/lttng.c | 37 ++++++++++++++++++++----------------- >> 2 files changed, 37 insertions(+), 17 deletions(-) >> >> diff --git a/configure.ac b/configure.ac >> index 71fbb60..7349713 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -91,12 +91,20 @@ AC_ARG_WITH([consumerd64-libdir], >> [CONSUMERD64_LIBDIR='']) >> AC_SUBST([CONSUMERD64_LIBDIR]) >> >> +AC_ARG_WITH([sessiond-bin], >> + AS_HELP_STRING([--with-sessiond-bin], >> + [Location of the sessiond executable (including the filename)]), >> + [SESSIOND_BIN="$withval"], >> + [SESSIOND_BIN='']) >> +AC_SUBST([SESSIOND_BIN]) >> + >> AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD32_BIN], "$CONSUMERD32_BIN", [Location of the 32-bit consumerd executable.]) >> AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD64_BIN], "$CONSUMERD64_BIN", [Location of the 64-bit consumerd executable]) >> AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD32_LIBDIR], "$CONSUMERD32_LIBDIR", [Search for consumerd 32-bit libraries in this location.]) >> AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD64_LIBDIR], "$CONSUMERD64_LIBDIR", [Search for consumerd 64-bit libraries in this location.]) >> AC_DEFINE_UNQUOTED([CONFIG_BABELTRACE_BIN], "$BABELTRACE_BIN", [Location of the babeltrace viewer executable.]) >> AC_DEFINE_UNQUOTED([CONFIG_LTTV_GUI_BIN], "$LTTV_GUI_BIN", [Location of the lttv GUI viewer executable.]) >> +AC_DEFINE_UNQUOTED([CONFIG_SESSIOND_BIN], "$SESSIOND_BIN", [Location of the sessiond executable.]) >> >> # Check for pthread >> AC_CHECK_LIB([pthread], [pthread_create], [], >> @@ -383,6 +391,15 @@ AS_ECHO("`eval eval echo $libdir`") >> # If we build the sessiond, print the paths it will use >> AS_IF([test "x$consumerd_only" = "xno"],[ >> AS_ECHO() >> + AS_ECHO_N("The lttng command will look for the lttng-sessiond executable at: ") >> + AS_IF([test "$SESSIOND_BIN" = ""],[ >> + AS_ECHO_N("`eval eval echo $bindir`") >> + AS_ECHO("/lttng-sessiond") >> + ],[ >> + AS_ECHO("$SESSIOND_BIN") >> + ]) >> + >> + AS_ECHO() >> AS_ECHO("The sessiond daemon will look in the following directories: ") >> AS_ECHO_N("32-bit consumerd executable at: ") >> AS_IF([test "$CONSUMERD32_BIN" = ""],[ >> diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c >> index 8562144..4097956 100644 >> --- a/src/bin/lttng/lttng.c >> +++ b/src/bin/lttng/lttng.c >> @@ -346,35 +346,38 @@ end: >> static int check_sessiond(void) >> { >> int ret; >> - char *pathname = NULL, *alloc_pathname = NULL; >> + char *pathname = NULL; >> >> ret = lttng_session_daemon_alive(); >> if (ret == 0) { /* not alive */ >> /* Try command line option path */ >> - if (opt_sessiond_path != NULL) { >> - ret = access(opt_sessiond_path, F_OK | X_OK); >> - if (ret < 0) { >> - ERR("No such file or access denied: %s", opt_sessiond_path); >> - goto end; >> - } >> - pathname = opt_sessiond_path; >> - } else { >> - /* Try LTTNG_SESSIOND_PATH env variable */ >> + pathname = opt_sessiond_path; >> + >> + /* Try LTTNG_SESSIOND_PATH env variable */ >> + if (pathname == NULL) { >> pathname = getenv(DEFAULT_SESSIOND_PATH_ENV); >> } >> >> - /* Let's rock and roll */ >> + /* Try with configured path */ >> if (pathname == NULL) { >> - ret = asprintf(&alloc_pathname, INSTALL_BIN_PATH "/lttng-sessiond"); >> - if (ret < 0) { >> - perror("asprintf spawn sessiond"); >> - goto end; >> + if (CONFIG_SESSIOND_BIN[0] != '\0') { >> + pathname = CONFIG_SESSIOND_BIN; >> } >> - pathname = alloc_pathname; >> + } >> + >> + /* Let's rock and roll while trying the default path */ >> + if (pathname == NULL) { >> + pathname = INSTALL_BIN_PATH "/lttng-sessiond"; >> + } >> + >> + /* Check existence and permissions */ >> + ret = access(pathname, F_OK | X_OK); >> + if (ret < 0) { >> + ERR("No such file or access denied: %s", pathname); >> + goto end; >> } >> >> ret = spawn_sessiond(pathname); >> - free(alloc_pathname); >> if (ret < 0) { >> ERR("Problem occurred when starting %s", pathname); >> goto end; >> -- >> 1.7.1 >> >> >> _______________________________________________ >> lttng-dev mailing list >> lttng-dev at lists.lttng.org >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From jeremie.galarneau at efficios.com Tue Mar 19 16:39:53 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Tue, 19 Mar 2013 16:39:53 -0400 Subject: [lttng-dev] [PATCH lttng-ust] Remove mention of locking issues associated with dlopen usage Message-ID: <1363725593-8202-1-git-send-email-jeremie.galarneau@efficios.com> This notice has been removed from the README as part of revision b834dead. Add a warning relating to dlclose() usage detailed in issue 447 in both the man page and the README file. Signed-off-by: J?r?mie Galarneau --- README | 6 +++++- doc/man/lttng-ust.3 | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README b/README index 55c72df..390a719 100644 --- a/README +++ b/README @@ -75,7 +75,7 @@ USAGE: - Include the tracepoint provider header into all C files using the provider. - Example: - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example.* + - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example.* 2) Compile the Tracepoint Provider separately from the application, using dynamic linking: @@ -97,6 +97,10 @@ USAGE: - Enable instrumentation and control tracing with the "lttng" command from lttng-tools. See lttng-tools doc/quickstart.txt. + - Note about dlclose() usage: it is not safe to use dlclose on a + provider shared object that is being actively used for tracing due + to a lack of reference counting from lttng-ust to the used shared + object. ENVIRONMENT VARIABLES: diff --git a/doc/man/lttng-ust.3 b/doc/man/lttng-ust.3 index 08927c6..7cc3bfd 100644 --- a/doc/man/lttng-ust.3 +++ b/doc/man/lttng-ust.3 @@ -265,7 +265,7 @@ carefully: - Include the tracepoint provider header into all C files using the provider. - Example: - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example + - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example 2) Compile the Tracepoint Provider separately from the application, using dynamic linking: @@ -280,15 +280,15 @@ carefully: - Link application with "\-ldl". - Set a LD_PRELOAD environment to preload the tracepoint provider shared object before starting the application when tracing is - needed. + needed. Another way is to dlopen the tracepoint probe when needed + by the application. - Example: - tests/demo/ demo.c tp*.c ust_tests_demo*.h demo-trace - - Note about dlopen() usage: due to locking side-effects due to the - way libc lazily resolves Thread-Local Storage (TLS) symbols when a - library is dlopen'd, linking the tracepoint probe or liblttng-ust - with dlopen() is discouraged. They should be linked with the - application using "\-llibname" or loaded with LD_PRELOAD. + - Note about dlclose() usage: it is not safe to use dlclose on a + provider shared object that is being actively used for tracing due + to a lack of reference counting from lttng-ust to the used shared + object. - Enable instrumentation and control tracing with the "lttng" command from lttng-tools. See lttng-tools doc/quickstart.txt. - Note for C++ support: although an application instrumented with -- 1.8.1.5 From mathieu.desnoyers at efficios.com Tue Mar 19 16:45:13 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Tue, 19 Mar 2013 16:45:13 -0400 Subject: [lttng-dev] [PATCH lttng-ust] Remove mention of locking issues associated with dlopen usage In-Reply-To: <1363725593-8202-1-git-send-email-jeremie.galarneau@efficios.com> References: <1363725593-8202-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <20130319204513.GA3261@Krystal> * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: > This notice has been removed from the README as part of revision b834dead. > > Add a warning relating to dlclose() usage detailed in issue 447 in both the > man page and the README file. merged into master and stable-2.1, thanks! Mathieu > > Signed-off-by: J?r?mie Galarneau > --- > README | 6 +++++- > doc/man/lttng-ust.3 | 14 +++++++------- > 2 files changed, 12 insertions(+), 8 deletions(-) > > diff --git a/README b/README > index 55c72df..390a719 100644 > --- a/README > +++ b/README > @@ -75,7 +75,7 @@ USAGE: > - Include the tracepoint provider header into all C files using > the provider. > - Example: > - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example.* > + - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example.* > > 2) Compile the Tracepoint Provider separately from the application, > using dynamic linking: > @@ -97,6 +97,10 @@ USAGE: > > - Enable instrumentation and control tracing with the "lttng" command > from lttng-tools. See lttng-tools doc/quickstart.txt. > + - Note about dlclose() usage: it is not safe to use dlclose on a > + provider shared object that is being actively used for tracing due > + to a lack of reference counting from lttng-ust to the used shared > + object. > > ENVIRONMENT VARIABLES: > > diff --git a/doc/man/lttng-ust.3 b/doc/man/lttng-ust.3 > index 08927c6..7cc3bfd 100644 > --- a/doc/man/lttng-ust.3 > +++ b/doc/man/lttng-ust.3 > @@ -265,7 +265,7 @@ carefully: > - Include the tracepoint provider header into all C files using > the provider. > - Example: > - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example > + - tests/hello/ hello.c tp.c ust_tests_hello.h Makefile.example > > 2) Compile the Tracepoint Provider separately from the application, > using dynamic linking: > @@ -280,15 +280,15 @@ carefully: > - Link application with "\-ldl". > - Set a LD_PRELOAD environment to preload the tracepoint provider > shared object before starting the application when tracing is > - needed. > + needed. Another way is to dlopen the tracepoint probe when needed > + by the application. > - Example: > - tests/demo/ demo.c tp*.c ust_tests_demo*.h demo-trace > > - - Note about dlopen() usage: due to locking side-effects due to the > - way libc lazily resolves Thread-Local Storage (TLS) symbols when a > - library is dlopen'd, linking the tracepoint probe or liblttng-ust > - with dlopen() is discouraged. They should be linked with the > - application using "\-llibname" or loaded with LD_PRELOAD. > + - Note about dlclose() usage: it is not safe to use dlclose on a > + provider shared object that is being actively used for tracing due > + to a lack of reference counting from lttng-ust to the used shared > + object. > - Enable instrumentation and control tracing with the "lttng" command > from lttng-tools. See lttng-tools doc/quickstart.txt. > - Note for C++ support: although an application instrumented with > -- > 1.8.1.5 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From tarcatu_dragosh at yahoo.com Wed Mar 20 08:46:46 2013 From: tarcatu_dragosh at yahoo.com (Dragos Tarcatu) Date: Wed, 20 Mar 2013 05:46:46 -0700 (PDT) Subject: [lttng-dev] [lttng-tools PATCH] Trivial build fix Message-ID: <1363783606.35366.YahooMailNeo@web120204.mail.ne1.yahoo.com> Hi all, I've got into a build error on Ubuntu 12.04 (i386) using gcc 4.6.3. The compiler seems to get confused when asked to equivalate unsigned long and uint64_t on my machine. Since the problem was pretty obvious, I've also made a patch for it. Regards, ??? Dragos -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: patch.diff Type: text/x-diff Size: 785 bytes Desc: not available URL: From dgoulet at efficios.com Wed Mar 20 10:15:10 2013 From: dgoulet at efficios.com (David Goulet) Date: Wed, 20 Mar 2013 10:15:10 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Trivial build fix In-Reply-To: <1363783606.35366.YahooMailNeo@web120204.mail.ne1.yahoo.com> References: <1363783606.35366.YahooMailNeo@web120204.mail.ne1.yahoo.com> Message-ID: <5149C46E.5010809@efficios.com> Hi, Thanks for the patch. It has been fixed and will be upstream very soon! Thanks for the patch! David Dragos Tarcatu: > Hi all, > > I've got into a build error on Ubuntu 12.04 (i386) using gcc 4.6.3. The > compiler seems to get confused when asked to equivalate unsigned long > and uint64_t on my machine. Since the problem was pretty obvious, I've > also made a patch for it. > > Regards, > Dragos > > > This body part will be downloaded on demand. From Daniel.Thibault at drdc-rddc.gc.ca Wed Mar 20 12:00:40 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Wed, 20 Mar 2013 16:00:40 +0000 Subject: [lttng-dev] dlopen, gcc -l and LD_PRELOAD Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD028AB5@VAL-E-01.valcartier.drdc-rddc.gc.ca> > Message: 1 > Date: Tue, 19 Mar 2013 11:51:29 -0400 > > >> I don't see this warning and error here. Which release are you using? >> > > lttng-modules 2.1.1+ (74b9312, 2013-02-27) > > lttng-tools 2.1.1+ (e58727c, 2013-03-01) > > lttng-ust 2.1.1+ (009769c, 2013-03-05) > > userspace-rcu 0.7.6+ (108a92e, 2013-02-22) > > > > I can confirm I'm able to reproduce the problem with these versions. > > > (All are moderately dated by now, but none of the later commit > > comments seem pertinent) > > This revision fixed the "undefined symbol: tracepoint_dlopen" problem: > https://bugs.lttng.org/projects/lttng-ust/repository/revisions/558b9d86247004f8e9bbaf8c982f3b2b182093d1 Doh! It had to be the revision right after the one I was using. Meanwhile I've been playing with some very simple examples of .so use, and found that the behaviour of LD_PRELOAD is incompletely documented. For instance, if I run: LD_LIBRARY_PATH=. ./sometest Where sometest is a simple application which uses a libwhatever.so built in the same directory, it works. But: LD_PRELOAD=./libwhatever.so ./sometest Fails with "No such file or directory". LD_PRELOAD and LD_LIBRARY_PATH are NOT interchangeable. The nitty-gritty (thanks to LD_DEBUG=libs) is as follows (my apologies if this is old-hat to fellow lttngeeks, but it was certainly new to me): Upon launching a process, the dynamic loader searches for the executable's requested libraries in the following ordered list of places, stopping as soon as a match is found: . the rpath directory (or colon-separated directories) encoded in the executable, if any, but only if runpath is not also set (e.g. gcc -Wl,-rpath,'$ORIGIN/rpath' etc.) (instead of using the linker -rpath option, you can set LD_RUN_PATH before calling the linker); . the (colon-separated) directories listed in the environment variable LD_LIBRARY_PATH, if any; . the runpath directory (or colon-separated directories) encoded in the executable, if any (e.g. gcc -Wl,-rpath,'$ORIGIN/rpath',--enable-new-dtags etc.; although it is possible to modify the binary so rpath and runpath are different, gcc sets both values to the same string); . the directories listed or included in /etc/ld.so.conf, if any; . the trusted directory /lib; and finally . the trusted directory /usr/lib. If the executable was linked with the -z nodeflib option ("no def lib"), then ld.so will not look in the last three locations for the requested shared library (that is to say, the search stops with the third bullet above). The Linux /etc/ld.so.conf typically uses an explicit include instruction to add the collection of .conf files in the /etc/ld.so.conf.d directory. The /etc/ld.so.conf.d files themselves are sorted alphabetically. (I skip over /etc/ld.so.cache and the important role of the ldconfig command). The found library is initialised, and then the dynamic loader checks in the following locations for the requested library: . the libraries (not directories) listed in the environment variable LD_PRELOAD, if any (absolute or relative paths; LD_PRELOAD accepts colon- and/or space-separated entries); and . the libraries (not directories) listed in the system file /etc/ld.so.preload, if any. If LD_PRELOAD or /etc/ld.so.preload supply a replacement library, the latter is initialised and its members pre-empt those from the previously found library. Preloading thus serves to substitute replacements for some of the "normal" library methods. Because full dynamicity (i.e. using dlopen to fetch the library) does not involve the dynamic loader, preloading does *not* work against it. Also, if the requested library is not found in the "normal" places (rpath, LD_LIBRARY_PATH, runpath, /etc/ld.so.conf, /lib, /usr/lib) the dynamic loader issues an error ("cannot open shared object file: No such file or directory") and does *not* look into LD_PRELOAD and /etc/ld.so.preload. There are additional subtleties involving set-user-ID/set-group-ID binaries, but this is otherwise as complete as I can make it. The above should explain the trouble I've been having with lttng-ust's doc/examples/easy-ust and tests/demo. Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC G3J 1X5 CANADA Vox : (418) 844-4000 x4245 Fax : (418) 844-4538 NAC : 918V QSDJ Gouvernement du Canada / Government of Canada From christian.babeux at efficios.com Wed Mar 20 12:38:59 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Wed, 20 Mar 2013 12:38:59 -0400 Subject: [lttng-dev] dlopen, gcc -l and LD_PRELOAD In-Reply-To: <48CF5AC71E61DB46B70D0F388054EFFD028AB5@VAL-E-01.valcartier.drdc-rddc.gc.ca> References: <48CF5AC71E61DB46B70D0F388054EFFD028AB5@VAL-E-01.valcartier.drdc-rddc.gc.ca> Message-ID: Hi Daniel, > Meanwhile I've been playing with some very simple examples of .so use, and found that the behaviour of LD_PRELOAD is incompletely documented. For instance, if I run: Take a look at "man 8 ld.so". It should answer most of the questions you have about the dynamic linker libraries lookup mechanism. > The above should explain the trouble I've been having with lttng-ust's doc/examples/easy-ust and tests/demo. Glad to see that you solved your issue! Thanks, Christian From Daniel.Thibault at drdc-rddc.gc.ca Wed Mar 20 12:52:41 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Wed, 20 Mar 2013 16:52:41 +0000 Subject: [lttng-dev] dlopen, gcc -l and LD_PRELOAD Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD028AF5@VAL-E-01.valcartier.drdc-rddc.gc.ca> -----Message d'origine----- Message: 6 Date: Wed, 20 Mar 2013 12:38:59 -0400 > Meanwhile I've been playing with some very simple examples of .so use, and found that the behaviour of LD_PRELOAD is incompletely documented. For instance, if I run: Take a look at "man 8 ld.so". It should answer most of the questions you have about the dynamic linker libraries lookup mechanism. > The above should explain the trouble I've been having with lttng-ust's doc/examples/easy-ust and tests/demo. Glad to see that you solved your issue! ------------------------------ That's what I meant by incompletely documented. The ld.so man pages don't mention rpath/runpath in the description, do not explain the LD_PRELOAD caveats, do not mention the nodeflib executable tag, and don't detail how the ld.so.conf inclusions are sorted. The online version (http://man7.org/linux/man-pages/man8/ld.so.8.html) is much better (though still lacking a bit) and certainly more up to date (February 2013 vs. Ubuntu's May 2007 version!). Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC G3J 1X5 CANADA Vox : (418) 844-4000 x4245 Fax : (418) 844-4538 NAC : 918V QSDJ Gouvernement du Canada / Government of Canada From fdeslaur at gmail.com Wed Mar 20 15:55:23 2013 From: fdeslaur at gmail.com (Francis Deslauriers) Date: Wed, 20 Mar 2013 15:55:23 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: References: Message-ID: <1363809323-12154-1-git-send-email-fdeslaur@gmail.com> This patch adds new trap tracepoint definitions. Both trap entry and trap exit tracepoints can be added. Signed-off-by: Francis Deslauriers --- include/trace/events/trap.h | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 include/trace/events/trap.h diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h new file mode 100644 index 0000000..e79e8c0 --- /dev/null +++ b/include/trace/events/trap.h @@ -0,0 +1,45 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM trap + +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TRAP_H + +#include + +TRACE_EVENT(trap_entry, + + TP_PROTO(struct pt_regs *regs, long trap), + + TP_ARGS(regs, trap), + + TP_STRUCT__entry( + __field( long, trap ) + __field( unsigned long, ip) + ), + TP_fast_assign( + __entry->trap = trap; + __entry->ip = regs ? instruction_pointer(regs) : 0UL; + ), + + TP_printk("number=%ld, ip = %lu", __entry->trap, __entry->ip) +); + +TRACE_EVENT(trap_exit, + + TP_PROTO(long trap), + + TP_ARGS(trap), + + TP_STRUCT__entry( + __field( long, trap ) + ), + TP_fast_assign( + __entry->trap = trap; + ), + + TP_printk("number=%ld", __entry->trap) +); + +#endif /* _TRACE_TRAP_H */ +/* This part must be outside protection */ +#include -- 1.7.10.4 From fdeslaur at gmail.com Wed Mar 20 16:00:13 2013 From: fdeslaur at gmail.com (Francis Deslauriers) Date: Wed, 20 Mar 2013 16:00:13 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: <1363809323-12154-1-git-send-email-fdeslaur@gmail.com> References: <1363809323-12154-1-git-send-email-fdeslaur@gmail.com> Message-ID: Here is reworked version on the trap tracepoints. If it looks good, i will go on by sending a lttng-modules patch adding the trap-probe. Comments are welcome. Francis On Wed, Mar 20, 2013 at 3:55 PM, Francis Deslauriers wrote: > This patch adds new trap tracepoint definitions. Both trap entry and trap > exit > tracepoints can be added. > > Signed-off-by: Francis Deslauriers > --- > include/trace/events/trap.h | 45 > +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > create mode 100644 include/trace/events/trap.h > > diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h > new file mode 100644 > index 0000000..e79e8c0 > --- /dev/null > +++ b/include/trace/events/trap.h > @@ -0,0 +1,45 @@ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM trap > + > +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_TRAP_H > + > +#include > + > +TRACE_EVENT(trap_entry, > + > + TP_PROTO(struct pt_regs *regs, long trap), > + > + TP_ARGS(regs, trap), > + > + TP_STRUCT__entry( > + __field( long, trap ) > + __field( unsigned long, ip) > + ), > + TP_fast_assign( > + __entry->trap = trap; > + __entry->ip = regs ? instruction_pointer(regs) : 0UL; > + ), > + > + TP_printk("number=%ld, ip = %lu", __entry->trap, __entry->ip) > +); > + > +TRACE_EVENT(trap_exit, > + > + TP_PROTO(long trap), > + > + TP_ARGS(trap), > + > + TP_STRUCT__entry( > + __field( long, trap ) > + ), > + TP_fast_assign( > + __entry->trap = trap; > + ), > + > + TP_printk("number=%ld", __entry->trap) > +); > + > +#endif /* _TRACE_TRAP_H */ > +/* This part must be outside protection */ > +#include > -- > 1.7.10.4 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mathieu.desnoyers at efficios.com Wed Mar 20 16:14:06 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 20 Mar 2013 16:14:06 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: <1363809323-12154-1-git-send-email-fdeslaur@gmail.com> References: <1363809323-12154-1-git-send-email-fdeslaur@gmail.com> Message-ID: <20130320201406.GA27044@Krystal> * Francis Deslauriers (fdeslaur at gmail.com) wrote: > This patch adds new trap tracepoint definitions. Both trap entry and trap exit > tracepoints can be added. > > Signed-off-by: Francis Deslauriers > --- > include/trace/events/trap.h | 45 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > create mode 100644 include/trace/events/trap.h > > diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h > new file mode 100644 > index 0000000..e79e8c0 > --- /dev/null > +++ b/include/trace/events/trap.h > @@ -0,0 +1,45 @@ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM trap > + > +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_TRAP_H > + > +#include > + > +TRACE_EVENT(trap_entry, > + > + TP_PROTO(struct pt_regs *regs, long trap), > + > + TP_ARGS(regs, trap), > + > + TP_STRUCT__entry( > + __field( long, trap ) > + __field( unsigned long, ip) many lines are using spaces instead of tabs. > + ), > + TP_fast_assign( > + __entry->trap = trap; > + __entry->ip = regs ? instruction_pointer(regs) : 0UL; > + ), > + > + TP_printk("number=%ld, ip = %lu", __entry->trap, __entry->ip) > +); > + > +TRACE_EVENT(trap_exit, > + > + TP_PROTO(long trap), > + > + TP_ARGS(trap), > + > + TP_STRUCT__entry( > + __field( long, trap ) here too. Thanks, Mathieu > + ), > + TP_fast_assign( > + __entry->trap = trap; > + ), > + > + TP_printk("number=%ld", __entry->trap) > +); > + > +#endif /* _TRACE_TRAP_H */ > +/* This part must be outside protection */ > +#include > -- > 1.7.10.4 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From fdeslaur at gmail.com Wed Mar 20 16:37:21 2013 From: fdeslaur at gmail.com (Francis Deslauriers) Date: Wed, 20 Mar 2013 16:37:21 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: References: Message-ID: <1363811841-23843-1-git-send-email-fdeslaur@gmail.com> This patch adds new trap tracepoint definitions. Both trap entry and trap exit tracepoints can be added. Signed-off-by: Francis Deslauriers --- include/trace/events/trap.h | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 include/trace/events/trap.h diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h new file mode 100644 index 0000000..e1847a3 --- /dev/null +++ b/include/trace/events/trap.h @@ -0,0 +1,45 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM trap + +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TRAP_H + +#include + +TRACE_EVENT(trap_entry, + + TP_PROTO(struct pt_regs *regs, long trap), + + TP_ARGS(regs, trap), + + TP_STRUCT__entry( + __field( long, trap) + __field( unsigned long, ip) + ), + TP_fast_assign( + __entry->trap = trap; + __entry->ip = regs ? instruction_pointer(regs) : 0UL; + ), + + TP_printk("number=%ld, ip = %lu", __entry->trap, __entry->ip) +); + +TRACE_EVENT(trap_exit, + + TP_PROTO(long trap), + + TP_ARGS(trap), + + TP_STRUCT__entry( + __field( long, trap) + ), + TP_fast_assign( + __entry->trap = trap; + ), + + TP_printk("number=%ld", __entry->trap) +); + +#endif /* _TRACE_TRAP_H */ +/* This part must be outside protection */ +#include -- 1.7.10.4 From mathieu.desnoyers at efficios.com Wed Mar 20 16:41:15 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 20 Mar 2013 16:41:15 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: <1363811841-23843-1-git-send-email-fdeslaur@gmail.com> References: <1363811841-23843-1-git-send-email-fdeslaur@gmail.com> Message-ID: <20130320204115.GA27807@Krystal> * Francis Deslauriers (fdeslaur at gmail.com) wrote: > This patch adds new trap tracepoint definitions. Both trap entry and trap exit > tracepoints can be added. "Both trap entry and trap exit tracepoints can be added." -> It enables each architecture to add trap instrumentation. > > Signed-off-by: Francis Deslauriers > --- > include/trace/events/trap.h | 45 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > create mode 100644 include/trace/events/trap.h > > diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h > new file mode 100644 > index 0000000..e1847a3 > --- /dev/null > +++ b/include/trace/events/trap.h > @@ -0,0 +1,45 @@ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM trap > + > +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_TRAP_H > + > +#include > + > +TRACE_EVENT(trap_entry, > + > + TP_PROTO(struct pt_regs *regs, long trap), > + > + TP_ARGS(regs, trap), > + > + TP_STRUCT__entry( > + __field( long, trap) Please make sure "trap" and "ip" are aligned in the source code. This is the style used by other instrumentation files. > + __field( unsigned long, ip) > + ), > + TP_fast_assign( > + __entry->trap = trap; > + __entry->ip = regs ? instruction_pointer(regs) : 0UL; > + ), > + > + TP_printk("number=%ld, ip = %lu", __entry->trap, __entry->ip) "number=" "ip = " -> space inconsistency. > +); > + > +TRACE_EVENT(trap_exit, > + > + TP_PROTO(long trap), > + > + TP_ARGS(trap), > + > + TP_STRUCT__entry( > + __field( long, trap) > + ), > + TP_fast_assign( > + __entry->trap = trap; > + ), > + > + TP_printk("number=%ld", __entry->trap) space or not around = ? Thanks, Mathieu > +); > + > +#endif /* _TRACE_TRAP_H */ > +/* This part must be outside protection */ > +#include > -- > 1.7.10.4 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From fdeslaur at gmail.com Wed Mar 20 21:36:33 2013 From: fdeslaur at gmail.com (Francis Deslauriers) Date: Wed, 20 Mar 2013 21:36:33 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: References: Message-ID: <1363829793-7579-1-git-send-email-fdeslaur@gmail.com> This patch adds new trap tracepoint definitions. It enables each architecture to add trap instrumentation. Signed-off-by: Francis Deslauriers --- include/trace/events/trap.h | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 include/trace/events/trap.h diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h new file mode 100644 index 0000000..171b9cf --- /dev/null +++ b/include/trace/events/trap.h @@ -0,0 +1,47 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM trap + +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TRAP_H + +#include + +TRACE_EVENT(trap_entry, + + TP_PROTO(struct pt_regs *regs, long trap), + + TP_ARGS(regs, trap), + + TP_STRUCT__entry( + __field( long, trap ) + __field( unsigned long, ip ) + ), + + TP_fast_assign( + __entry->trap = trap; + __entry->ip = regs ? instruction_pointer(regs) : 0UL; + ), + + TP_printk("number=%ld ip=%lu", __entry->trap, __entry->ip) +); + +TRACE_EVENT(trap_exit, + + TP_PROTO(long trap), + + TP_ARGS(trap), + + TP_STRUCT__entry( + __field( long, trap ) + ), + + TP_fast_assign( + __entry->trap = trap; + ), + + TP_printk("number=%ld", __entry->trap) +); + +#endif /* _TRACE_TRAP_H */ +/* This part must be outside protection */ +#include -- 1.7.10.4 From mathieu.desnoyers at efficios.com Wed Mar 20 22:51:44 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 20 Mar 2013 22:51:44 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: <1363829793-7579-1-git-send-email-fdeslaur@gmail.com> References: <1363829793-7579-1-git-send-email-fdeslaur@gmail.com> Message-ID: <20130321025144.GC3874@Krystal> Subject change: "Adding trap tracepoints definitions" -> "Add trap trace event definitions" * Francis Deslauriers (fdeslaur at gmail.com) wrote: > This patch adds new trap tracepoint definitions. It enables each > architecture to add trap instrumentation. "This patch" should be avoided (we know it's a patch). -> Add trace trace event definitions. It will allow each architecture to instrument their traps. I'm being even more strict than usual as you notice given that this patch is targeting lkml. Thanks, Mathieu > > Signed-off-by: Francis Deslauriers > --- > include/trace/events/trap.h | 47 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 47 insertions(+) > create mode 100644 include/trace/events/trap.h > > diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h > new file mode 100644 > index 0000000..171b9cf > --- /dev/null > +++ b/include/trace/events/trap.h > @@ -0,0 +1,47 @@ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM trap > + > +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_TRAP_H > + > +#include > + > +TRACE_EVENT(trap_entry, > + > + TP_PROTO(struct pt_regs *regs, long trap), > + > + TP_ARGS(regs, trap), > + > + TP_STRUCT__entry( > + __field( long, trap ) > + __field( unsigned long, ip ) > + ), > + > + TP_fast_assign( > + __entry->trap = trap; > + __entry->ip = regs ? instruction_pointer(regs) : 0UL; > + ), > + > + TP_printk("number=%ld ip=%lu", __entry->trap, __entry->ip) > +); > + > +TRACE_EVENT(trap_exit, > + > + TP_PROTO(long trap), > + > + TP_ARGS(trap), > + > + TP_STRUCT__entry( > + __field( long, trap ) > + ), > + > + TP_fast_assign( > + __entry->trap = trap; > + ), > + > + TP_printk("number=%ld", __entry->trap) > +); > + > +#endif /* _TRACE_TRAP_H */ > +/* This part must be outside protection */ > +#include > -- > 1.7.10.4 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From fdeslaur at gmail.com Thu Mar 21 00:32:36 2013 From: fdeslaur at gmail.com (Francis Deslauriers) Date: Thu, 21 Mar 2013 00:32:36 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: <20130321025144.GC3874@Krystal> References: <1363829793-7579-1-git-send-email-fdeslaur@gmail.com> <20130321025144.GC3874@Krystal> Message-ID: On Wed, Mar 20, 2013 at 10:51 PM, Mathieu Desnoyers wrote: > Subject change: > > "Adding trap tracepoints definitions" > > -> "Add trap trace event definitions" > > -> > > Add trace trace event definitions. It will allow each architecture to > instrument their traps. How about this? Add trap trace event definitions Add trap entry and trap exit trace event definitions. It will allow each architecture to instrument their traps. This way we dont repeat the subject and it is more specific. > > I'm being even more strict than usual as you notice given that this > patch is targeting lkml. > > Thanks, > > Mathieu > >> >> Signed-off-by: Francis Deslauriers >> --- >> include/trace/events/trap.h | 47 +++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 47 insertions(+) >> create mode 100644 include/trace/events/trap.h >> >> diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h >> new file mode 100644 >> index 0000000..171b9cf >> --- /dev/null >> +++ b/include/trace/events/trap.h >> @@ -0,0 +1,47 @@ >> +#undef TRACE_SYSTEM >> +#define TRACE_SYSTEM trap >> + >> +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) >> +#define _TRACE_TRAP_H >> + >> +#include >> + >> +TRACE_EVENT(trap_entry, >> + >> + TP_PROTO(struct pt_regs *regs, long trap), >> + >> + TP_ARGS(regs, trap), >> + >> + TP_STRUCT__entry( >> + __field( long, trap ) >> + __field( unsigned long, ip ) >> + ), >> + >> + TP_fast_assign( >> + __entry->trap = trap; >> + __entry->ip = regs ? instruction_pointer(regs) : 0UL; >> + ), >> + >> + TP_printk("number=%ld ip=%lu", __entry->trap, __entry->ip) >> +); >> + >> +TRACE_EVENT(trap_exit, >> + >> + TP_PROTO(long trap), >> + >> + TP_ARGS(trap), >> + >> + TP_STRUCT__entry( >> + __field( long, trap ) >> + ), >> + >> + TP_fast_assign( >> + __entry->trap = trap; >> + ), >> + >> + TP_printk("number=%ld", __entry->trap) >> +); >> + >> +#endif /* _TRACE_TRAP_H */ >> +/* This part must be outside protection */ >> +#include >> -- >> 1.7.10.4 >> >> >> _______________________________________________ >> lttng-dev mailing list >> lttng-dev at lists.lttng.org >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com From mathieu.desnoyers at efficios.com Thu Mar 21 09:28:38 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Thu, 21 Mar 2013 09:28:38 -0400 Subject: [lttng-dev] [RFC-PATCH] Adding trap tracepoints definitions In-Reply-To: References: <1363829793-7579-1-git-send-email-fdeslaur@gmail.com> <20130321025144.GC3874@Krystal> Message-ID: <20130321132837.GA20025@Krystal> * Francis Deslauriers (fdeslaur at gmail.com) wrote: > On Wed, Mar 20, 2013 at 10:51 PM, Mathieu Desnoyers > wrote: > > Subject change: > > > > "Adding trap tracepoints definitions" > > > > -> "Add trap trace event definitions" > > > > -> > > > > Add trace trace event definitions. It will allow each architecture to > > instrument their traps. > > How about this? > Add trap trace event definitions > > Add trap entry and trap exit trace event definitions. It will allow each > architecture to instrument their traps. > > > This way we dont repeat the subject and it is more specific. sounds good! With these changes, please put my: Reviewed-by: Mathieu Desnoyers Thanks, Mathieu > > > > > I'm being even more strict than usual as you notice given that this > > patch is targeting lkml. > > > > Thanks, > > > > Mathieu > > > >> > >> Signed-off-by: Francis Deslauriers > >> --- > >> include/trace/events/trap.h | 47 +++++++++++++++++++++++++++++++++++++++++++ > >> 1 file changed, 47 insertions(+) > >> create mode 100644 include/trace/events/trap.h > >> > >> diff --git a/include/trace/events/trap.h b/include/trace/events/trap.h > >> new file mode 100644 > >> index 0000000..171b9cf > >> --- /dev/null > >> +++ b/include/trace/events/trap.h > >> @@ -0,0 +1,47 @@ > >> +#undef TRACE_SYSTEM > >> +#define TRACE_SYSTEM trap > >> + > >> +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) > >> +#define _TRACE_TRAP_H > >> + > >> +#include > >> + > >> +TRACE_EVENT(trap_entry, > >> + > >> + TP_PROTO(struct pt_regs *regs, long trap), > >> + > >> + TP_ARGS(regs, trap), > >> + > >> + TP_STRUCT__entry( > >> + __field( long, trap ) > >> + __field( unsigned long, ip ) > >> + ), > >> + > >> + TP_fast_assign( > >> + __entry->trap = trap; > >> + __entry->ip = regs ? instruction_pointer(regs) : 0UL; > >> + ), > >> + > >> + TP_printk("number=%ld ip=%lu", __entry->trap, __entry->ip) > >> +); > >> + > >> +TRACE_EVENT(trap_exit, > >> + > >> + TP_PROTO(long trap), > >> + > >> + TP_ARGS(trap), > >> + > >> + TP_STRUCT__entry( > >> + __field( long, trap ) > >> + ), > >> + > >> + TP_fast_assign( > >> + __entry->trap = trap; > >> + ), > >> + > >> + TP_printk("number=%ld", __entry->trap) > >> +); > >> + > >> +#endif /* _TRACE_TRAP_H */ > >> +/* This part must be outside protection */ > >> +#include > >> -- > >> 1.7.10.4 > >> > >> > >> _______________________________________________ > >> lttng-dev mailing list > >> lttng-dev at lists.lttng.org > >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > > > -- > > Mathieu Desnoyers > > EfficiOS Inc. > > http://www.efficios.com -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From dgoulet at efficios.com Thu Mar 21 12:33:02 2013 From: dgoulet at efficios.com (David Goulet) Date: Thu, 21 Mar 2013 12:33:02 -0400 Subject: [lttng-dev] Per UID buffers in UST Message-ID: <514B363E.6080305@efficios.com> Hi everyone, Just a quick heads up that the support for per UID buffers for UST has been pushed into the master branch of tools and can be used like so: $ lttng create $ lttng enable-channel -u --buffers-uid chan1 $ lttng enable-event -a -u -c chan1 $ lttng start Of course, you'll need the master HEAD of lttng-ust as well. Please, I encourage anyone of you to test it! and of course report bugs or anything weird or not working :). commit 7972aab22f74b18faa168c0482216a3dd711a075 Cheers! David From dgoulet at efficios.com Thu Mar 21 13:32:47 2013 From: dgoulet at efficios.com (David Goulet) Date: Thu, 21 Mar 2013 13:32:47 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Fix: Memory leak on error paths of relay_add_stream In-Reply-To: <1362084510-10072-1-git-send-email-christian.babeux@efficios.com> References: <1362084510-10072-1-git-send-email-christian.babeux@efficios.com> Message-ID: <514B443F.4010709@efficios.com> Merged all 7! David Christian Babeux: > On error paths the memory allocated for stream is never freed. > > Also, fix undefined behavior on asprintf alloc failure. According to > asprintf(3), the content of the pointer passed to it is undefined if > an alloc failure occurs, so we could end up freeing a pointer in an > undefined state. Force its value to NULL. > > Signed-off-by: Christian Babeux > --- > src/bin/lttng-relayd/main.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c > index 4f9d742..00b7ea3 100644 > --- a/src/bin/lttng-relayd/main.c > +++ b/src/bin/lttng-relayd/main.c > @@ -941,6 +941,7 @@ int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr, > ret = asprintf(&path, "%s/%s", root_path, stream_info.channel_name); > if (ret < 0) { > PERROR("asprintf stream path"); > + path = NULL; > goto end; > } > > @@ -963,13 +964,17 @@ int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr, > end: > free(path); > free(root_path); > + > + reply.handle = htobe64(stream->stream_handle); > /* send the session id to the client or a negative return code on error */ > if (ret < 0) { > reply.ret_code = htobe32(LTTNG_ERR_UNK); > + /* stream was not properly added to the ht, so free it */ > + free(stream); > } else { > reply.ret_code = htobe32(LTTNG_OK); > } > - reply.handle = htobe64(stream->stream_handle); > + > send_ret = cmd->sock->ops->sendmsg(cmd->sock, &reply, > sizeof(struct lttcomm_relayd_status_stream), 0); > if (send_ret < 0) { From dgoulet at efficios.com Thu Mar 21 13:33:01 2013 From: dgoulet at efficios.com (David Goulet) Date: Thu, 21 Mar 2013 13:33:01 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Add with-sessiond-bin configure option In-Reply-To: <1362094937-6677-1-git-send-email-simon.marchi@polymtl.ca> References: <1362094937-6677-1-git-send-email-simon.marchi@polymtl.ca> Message-ID: <514B444D.9000505@efficios.com> Merged thanks! David Simon Marchi: > I also cleaned up the little check_sessiond function. The check using > access(2) was only done for the command line option, but I think it is a > good idea to do it wherever the path comes from. > > closes #441 > > Signed-off-by: Simon Marchi > --- > configure.ac | 17 +++++++++++++++++ > src/bin/lttng/lttng.c | 37 ++++++++++++++++++++----------------- > 2 files changed, 37 insertions(+), 17 deletions(-) > > diff --git a/configure.ac b/configure.ac > index 71fbb60..7349713 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -91,12 +91,20 @@ AC_ARG_WITH([consumerd64-libdir], > [CONSUMERD64_LIBDIR='']) > AC_SUBST([CONSUMERD64_LIBDIR]) > > +AC_ARG_WITH([sessiond-bin], > + AS_HELP_STRING([--with-sessiond-bin], > + [Location of the sessiond executable (including the filename)]), > + [SESSIOND_BIN="$withval"], > + [SESSIOND_BIN='']) > +AC_SUBST([SESSIOND_BIN]) > + > AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD32_BIN], "$CONSUMERD32_BIN", [Location of the 32-bit consumerd executable.]) > AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD64_BIN], "$CONSUMERD64_BIN", [Location of the 64-bit consumerd executable]) > AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD32_LIBDIR], "$CONSUMERD32_LIBDIR", [Search for consumerd 32-bit libraries in this location.]) > AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD64_LIBDIR], "$CONSUMERD64_LIBDIR", [Search for consumerd 64-bit libraries in this location.]) > AC_DEFINE_UNQUOTED([CONFIG_BABELTRACE_BIN], "$BABELTRACE_BIN", [Location of the babeltrace viewer executable.]) > AC_DEFINE_UNQUOTED([CONFIG_LTTV_GUI_BIN], "$LTTV_GUI_BIN", [Location of the lttv GUI viewer executable.]) > +AC_DEFINE_UNQUOTED([CONFIG_SESSIOND_BIN], "$SESSIOND_BIN", [Location of the sessiond executable.]) > > # Check for pthread > AC_CHECK_LIB([pthread], [pthread_create], [], > @@ -383,6 +391,15 @@ AS_ECHO("`eval eval echo $libdir`") > # If we build the sessiond, print the paths it will use > AS_IF([test "x$consumerd_only" = "xno"],[ > AS_ECHO() > + AS_ECHO_N("The lttng command will look for the lttng-sessiond executable at: ") > + AS_IF([test "$SESSIOND_BIN" = ""],[ > + AS_ECHO_N("`eval eval echo $bindir`") > + AS_ECHO("/lttng-sessiond") > + ],[ > + AS_ECHO("$SESSIOND_BIN") > + ]) > + > + AS_ECHO() > AS_ECHO("The sessiond daemon will look in the following directories: ") > AS_ECHO_N("32-bit consumerd executable at: ") > AS_IF([test "$CONSUMERD32_BIN" = ""],[ > diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c > index 8562144..4097956 100644 > --- a/src/bin/lttng/lttng.c > +++ b/src/bin/lttng/lttng.c > @@ -346,35 +346,38 @@ end: > static int check_sessiond(void) > { > int ret; > - char *pathname = NULL, *alloc_pathname = NULL; > + char *pathname = NULL; > > ret = lttng_session_daemon_alive(); > if (ret == 0) { /* not alive */ > /* Try command line option path */ > - if (opt_sessiond_path != NULL) { > - ret = access(opt_sessiond_path, F_OK | X_OK); > - if (ret < 0) { > - ERR("No such file or access denied: %s", opt_sessiond_path); > - goto end; > - } > - pathname = opt_sessiond_path; > - } else { > - /* Try LTTNG_SESSIOND_PATH env variable */ > + pathname = opt_sessiond_path; > + > + /* Try LTTNG_SESSIOND_PATH env variable */ > + if (pathname == NULL) { > pathname = getenv(DEFAULT_SESSIOND_PATH_ENV); > } > > - /* Let's rock and roll */ > + /* Try with configured path */ > if (pathname == NULL) { > - ret = asprintf(&alloc_pathname, INSTALL_BIN_PATH "/lttng-sessiond"); > - if (ret < 0) { > - perror("asprintf spawn sessiond"); > - goto end; > + if (CONFIG_SESSIOND_BIN[0] != '\0') { > + pathname = CONFIG_SESSIOND_BIN; > } > - pathname = alloc_pathname; > + } > + > + /* Let's rock and roll while trying the default path */ > + if (pathname == NULL) { > + pathname = INSTALL_BIN_PATH "/lttng-sessiond"; > + } > + > + /* Check existence and permissions */ > + ret = access(pathname, F_OK | X_OK); > + if (ret < 0) { > + ERR("No such file or access denied: %s", pathname); > + goto end; > } > > ret = spawn_sessiond(pathname); > - free(alloc_pathname); > if (ret < 0) { > ERR("Problem occurred when starting %s", pathname); > goto end; From dgoulet at efficios.com Thu Mar 21 13:35:41 2013 From: dgoulet at efficios.com (David Goulet) Date: Thu, 21 Mar 2013 13:35:41 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <16a0408728b4c746985844ecd893bd569b599641.1363477794.git.raphael.beamonte@gmail.com> References: <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com> <16a0408728b4c746985844ecd893bd569b599641.1363477794.git.raphael.beamonte@gmail.com> Message-ID: <514B44ED.3000702@efficios.com> This does not compile event after a clean and bootstrap. make[3]: Entering directory `/home/dgoulet/Documents/git/lttng-tools/src/bin/lttng' CC conf.o CC start.o In file included from commands/../command.h:26:0, from commands/start.c:27: commands/../utils.h:23:21: fatal error: version.h: No such file or directory compilation terminated. David Rapha?l Beamonte: > Signed-off-by: Rapha?l Beamonte > --- > .gitignore | 2 ++ > include/Makefile.am | 45 ++++++++++++++++++++++++++++++- > include/version.h.tmpl | 27 +++++++++++++++++++ > src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++ > src/bin/lttng-sessiond/main.c | 2 +- > src/bin/lttng/commands/version.c | 4 ++- > src/bin/lttng/lttng.c | 5 +++- > src/bin/lttng/utils.h | 13 +++++++++ > 8 files changed, 108 insertions(+), 4 deletions(-) > create mode 100644 include/version.h.tmpl > > diff --git a/.gitignore b/.gitignore > index ac72bf4..a36f0b9 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -31,6 +31,8 @@ config/ > !config/epoll.m4 > !config/config_feature.m4 > > +include/version.h > + > src/bin/lttng-sessiond/lttng-sessiond > src/bin/lttng/lttng > src/bin/lttng-consumerd/lttng-consumerd > diff --git a/include/Makefile.am b/include/Makefile.am > index 0bcb6f9..fce6276 100644 > --- a/include/Makefile.am > +++ b/include/Makefile.am > @@ -1 +1,44 @@ > -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h > +## The version.h file must be verified and generated or updated if the > +## git commit id (called git version here) changed since the last build > +## of lttng-tools. > +version.h: version.h.tmpl > + ## We first create variables for the current git version and > + ## the locations of the version.h and version.h.tmpl files > + (git_version="$$(git describe --long --all 2>/dev/null)"; \ > + version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \ > + version_h="$(top_builddir)/include/version.h"; \ > + ## If the version.h file doesn't exist or is not up to date, > + ## We replace it by the version.h.tmpl file > + if [ ! -e "$${version_h}" ] || \ > + [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \ > + cp "$${version_h_tmpl}" "$${version_h}"; \ > + fi; \ > + if [ -z "$${git_version}" ]; then \ > + ## If we don't have a git version, we verify that there is > + ## not any define of GIT_VERSION in the version.h file, or > + ## we remove it. > + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ > + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \ > + fi; \ > + else \ > + ## If we have a git version, we verify that it isn't the same > + ## as the one currently in the file (if there is one), as we > + ## don't want to update the file if it is already up to date > + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ > + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ > + ## If there is already a GIT_VERSION defined, > + ## we just replace it by the new version > + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ > + else \ > + ## Else, we add a GIT_VERSION define > + ## containing our new version. > + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ > + fi; \ > + fi; \ > + fi) > + > +## version.h is defined as a .PHONY file even if it's a real file as > +## we want our routine to be runned for each build. > +.PHONY: version.h > + > +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h version.h > diff --git a/include/version.h.tmpl b/include/version.h.tmpl > new file mode 100644 > index 0000000..c42789c > --- /dev/null > +++ b/include/version.h.tmpl > @@ -0,0 +1,27 @@ > +/* > + * version.h > + * > + * Linux Trace Toolkit version header file > + * > + * Copyright (C) 2013 - Rapha?l Beamonte > + * > + * This library is free software; you can redistribute it and/or modify it > + * under the terms of the GNU Lesser General Public License, version 2.1 only, > + * as published by the Free Software Foundation. > + * > + * This library is distributed in the hope that it will be useful, but WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License > + * for more details. > + * > + * You should have received a copy of the GNU Lesser General Public License > + * along with this library; if not, write to the Free Software Foundation, > + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#ifndef VERSION_H > +#define VERSION_H > + > +#define GIT_VERSION > + > +#endif /* VERSION_H */ > diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h > index 9258f38..e91918a 100644 > --- a/src/bin/lttng-sessiond/lttng-sessiond.h > +++ b/src/bin/lttng-sessiond/lttng-sessiond.h > @@ -1,5 +1,6 @@ > /* > * Copyright (C) 2011 - David Goulet > + * Copyright (C) 2013 - Rapha?l Beamonte > * > * This program is free software; you can redistribute it and/or modify > * it under the terms of the GNU General Public License, version 2 only, > @@ -28,6 +29,8 @@ > > #include "session.h" > #include "ust-app.h" > +#include "version.h" > + > > extern const char default_home_dir[], > default_tracing_group[], > @@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2]; > int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size); > int sessiond_check_thread_quit_pipe(int fd, uint32_t events); > > +/* > + * This static const char allows to return the version number depending > + * whether or not the GIT_VERSION value is available > + */ > +#ifdef GIT_VERSION > +static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")"; > +#else /* GIT_VERSION */ > +static const char lttng_sessiond_version[] = VERSION; > +#endif /* GIT_VERSION */ > + > + > #endif /* _LTT_SESSIOND_H */ > diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c > index f7bb53e..857a20d 100644 > --- a/src/bin/lttng-sessiond/main.c > +++ b/src/bin/lttng-sessiond/main.c > @@ -3547,7 +3547,7 @@ static int parse_args(int argc, char **argv) > usage(); > exit(EXIT_FAILURE); > case 'V': > - fprintf(stdout, "%s\n", VERSION); > + fprintf(stdout, "%s\n", lttng_sessiond_version); > exit(EXIT_SUCCESS); > case 'S': > opt_sig_parent = 1; > diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c > index 7f69de3..2170d00 100644 > --- a/src/bin/lttng/commands/version.c > +++ b/src/bin/lttng/commands/version.c > @@ -26,6 +26,7 @@ > #include > > #include "../command.h" > +#include "../utils.h" > > enum { > OPT_HELP = 1, > @@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv) > } > > MSG("lttng version " VERSION " - " VERSION_NAME); > - MSG("\n" VERSION_DESCRIPTION "\n"); > + MSG("%s", lttng_version); > + MSG(VERSION_DESCRIPTION "\n"); > MSG("Web site: http://lttng.org"); > MSG("\nlttng is free software and under the GPL license and part LGPL"); > > diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c > index 8562144..002bf4e 100644 > --- a/src/bin/lttng/lttng.c > +++ b/src/bin/lttng/lttng.c > @@ -31,6 +31,7 @@ > #include > > #include "command.h" > +#include "utils.h" > > /* Variables */ > static char *progname; > @@ -81,7 +82,9 @@ static struct cmd_struct commands[] = { > > static void usage(FILE *ofp) > { > - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); > + fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n"); > + fprintf(ofp, lttng_version); > + fprintf(ofp, "\n"); > fprintf(ofp, "usage: lttng [OPTIONS] []\n"); > fprintf(ofp, "\n"); > fprintf(ofp, "Options:\n"); > diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h > index 9f7bfcc..12ee7c0 100644 > --- a/src/bin/lttng/utils.h > +++ b/src/bin/lttng/utils.h > @@ -1,5 +1,6 @@ > /* > * Copyright (C) 2011 - David Goulet > + * Copyright (C) 2013 - Rapha?l Beamonte > * > * This program is free software; you can redistribute it and/or modify > * it under the terms of the GNU General Public License, version 2 only, > @@ -19,8 +20,20 @@ > #define _LTTNG_UTILS_H > > #include > +#include > > char *get_session_name(void); > void list_cmd_options(FILE *ofp, struct poptOption *options); > > +/* > + * This static const char allows to return the version number depending > + * whether or not the GIT_VERSION value is available > + */ > +#ifdef GIT_VERSION > +static const char lttng_version[] = "Git version: " GIT_VERSION "\n"; > +#else /* GIT_VERSION */ > +static const char lttng_version[] = ""; > +#endif /* GIT_VERSION */ > + > + > #endif /* _LTTNG_UTILS_H */ From christian.babeux at efficios.com Thu Mar 21 15:56:42 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Thu, 21 Mar 2013 15:56:42 -0400 Subject: [lttng-dev] [PATCH lttng-tools 1/6] Tests: Fix wrong number of tests in test plan of the thread stall test Message-ID: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> Signed-off-by: Christian Babeux --- tests/regression/tools/health/test_thread_stall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/regression/tools/health/test_thread_stall b/tests/regression/tools/health/test_thread_stall index 92cfb01..1651c02 100755 --- a/tests/regression/tools/health/test_thread_stall +++ b/tests/regression/tools/health/test_thread_stall @@ -24,7 +24,7 @@ SESSION_NAME="health_thread_stall" EVENT_NAME="bogus" HEALTH_CHECK_BIN="health_check" SESSIOND_PRELOAD=".libs/libhealthstall.so" -NUM_TESTS=12 +NUM_TESTS=11 source $TESTDIR/utils/utils.sh -- 1.8.1.3 From christian.babeux at efficios.com Thu Mar 21 15:56:43 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Thu, 21 Mar 2013 15:56:43 -0400 Subject: [lttng-dev] [PATCH lttng-tools 2/6] Tests: Fix missing TAP output in overlap test In-Reply-To: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> References: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> Message-ID: <1363895807-17892-2-git-send-email-christian.babeux@efficios.com> The start and stop tracing shell functions are currently redirected to /dev/null. This has the unfortunate side-effect of silencing the TAP output thus producing an incomplete test output. This commit remove the /dev/null redirection of those commands. Signed-off-by: Christian Babeux --- tests/regression/ust/overlap/test_overlap | 104 ++++++++++++++---------------- 1 file changed, 50 insertions(+), 54 deletions(-) diff --git a/tests/regression/ust/overlap/test_overlap b/tests/regression/ust/overlap/test_overlap index 4e0d90c..e823072 100755 --- a/tests/regression/ust/overlap/test_overlap +++ b/tests/regression/ust/overlap/test_overlap @@ -88,11 +88,11 @@ test_enable_simple_wildcard() enable_ust_lttng_event $SESSION_NAME "$event_wild1" enable_ust_lttng_event $SESSION_NAME "$event_wild2" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events @@ -110,11 +110,11 @@ test_enable_wildcard_filter() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -131,11 +131,11 @@ test_enable_wildcard_filter_2() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -152,11 +152,11 @@ test_enable_wildcard_filter_3() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -173,11 +173,11 @@ test_enable_wildcard_filter_4() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_no_demo_events return $? @@ -194,11 +194,11 @@ test_enable_wildcard_filter_5() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -215,11 +215,11 @@ test_enable_wildcard_filter_6() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH @@ -239,11 +239,11 @@ test_enable_wildcard_filter_7() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -260,11 +260,11 @@ test_enable_wildcard_filter_8() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_no_demo_events return $? @@ -281,11 +281,11 @@ test_enable_same_wildcard_filter() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -309,11 +309,11 @@ test_enable_same_wildcard_filter_2() fail "Enable event $event_name with filtering for session $sess_name twice failure NOT detected" fi - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -330,11 +330,11 @@ test_enable_same_wildcard_filter_3() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -351,11 +351,11 @@ test_enable_same_wildcard_filter_4() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==0&&1==0" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==0" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_no_demo_events return $? @@ -372,11 +372,11 @@ test_enable_same_event_filter() enable_ust_lttng_event_filter $SESSION_NAME "$event_wild1" "1==1&&1==1" enable_ust_lttng_event_filter $SESSION_NAME "$event_wild2" "1==1" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH @@ -398,11 +398,11 @@ test_disable_same_wildcard_filter() disable_ust_lttng_event $SESSION_NAME "ust*" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_no_demo_events return $? @@ -422,11 +422,11 @@ test_enable_bad_wildcard() enable_ust_lttng_event $SESSION_NAME "$event_wild2" enable_ust_lttng_event $SESSION_NAME "$event_wild3" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_no_demo_events return $? @@ -443,11 +443,11 @@ test_enable_simple_wildcard_2() enable_ust_lttng_event $SESSION_NAME "$event_wild1" enable_ust_lttng_event $SESSION_NAME "$event_wild2" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -464,11 +464,11 @@ test_enable_loglevel_overlap() enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING" enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -485,11 +485,11 @@ test_enable_loglevel_only_overlap() enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING" enable_ust_lttng_event_loglevel_only $SESSION_NAME "$event_wild2" "TRACE_CRIT" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -506,11 +506,11 @@ test_enable_loglevel_overlap_2() enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING" enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -527,11 +527,11 @@ test_enable_same_wildcard_loglevels() enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT" enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_match_all_demo_events return $? @@ -548,11 +548,11 @@ test_enable_same_event_loglevels() enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT" enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH @@ -575,11 +575,11 @@ test_disable_simple_wildcard() disable_ust_lttng_event $SESSION_NAME "$event_wild1" disable_ust_lttng_event $SESSION_NAME "$event_wild2" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME # No events are expected. trace_match_no_demo_events @@ -599,11 +599,11 @@ test_disable_wildcard_overlap() disable_ust_lttng_event $SESSION_NAME "$event_wild1" - start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + start_lttng_tracing $SESSION_NAME run_demo_app - stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + stop_lttng_tracing $SESSION_NAME # Expect only "ust_tests_demo" events. trace_matches "$DEMO_EVENT1" $NUM_DEMO1_EVENT $TRACE_PATH @@ -650,16 +650,12 @@ while [ "$i" -lt "$TEST_COUNT" ]; do TRACE_PATH=$(mktemp -d) - create_lttng_session $SESSION_NAME $TRACE_PATH >/dev/null 2>&1 + create_lttng_session $SESSION_NAME $TRACE_PATH # Execute test ${TESTS[$i]} - if [ $? -ne 0 ]; then - stop_lttng_sessiond - exit 1 - fi - destroy_lttng_session $SESSION_NAME >/dev/null 2>&1 + destroy_lttng_session $SESSION_NAME rm -rf $TRACE_PATH -- 1.8.1.3 From christian.babeux at efficios.com Thu Mar 21 15:56:44 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Thu, 21 Mar 2013 15:56:44 -0400 Subject: [lttng-dev] [PATCH lttng-tools 3/6] Tests: Fix tests first line of output to follow TAP guidelines In-Reply-To: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> References: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> Message-ID: <1363895807-17892-3-git-send-email-christian.babeux@efficios.com> >From the Test::Harness::TAP documentation [1]: The plan tells how many tests will be run, or how many tests have run. It's a check that the test file hasn't stopped prematurely. It must appear once, whether at the beginning or end of the output. The TAP plan *must* be the first line of output of any tests. Currently, most of the tests output their description and then the TAP plan. This can cause issues while parsing the test output for "strict" TAP parser such as the one used in the prove tool. This commit ensure that the first line outputted by any tests is the TAP plan. Signed-off-by: Christian Babeux --- tests/regression/kernel/test_all_events | 4 ++-- tests/regression/kernel/test_event_basic | 4 ++-- tests/regression/tools/filtering/test_invalid_filter | 4 ++-- tests/regression/tools/filtering/test_unsupported_op | 4 ++-- tests/regression/tools/filtering/test_valid_filter | 4 ++-- tests/regression/tools/health/test_thread_exit | 5 +++-- tests/regression/tools/health/test_thread_stall | 4 ++-- tests/regression/tools/health/test_tp_fail | 4 ++-- tests/regression/tools/streaming/test_high_throughput_limits | 4 ++-- tests/regression/tools/streaming/test_kernel | 4 ++-- tests/regression/tools/streaming/test_ust | 4 ++-- tests/regression/ust/before-after/test_before_after | 4 ++-- tests/regression/ust/buffers-uid/test_buffers_uid | 4 ++-- tests/regression/ust/high-throughput/test_high_throughput | 4 ++-- tests/regression/ust/low-throughput/test_low_throughput | 4 ++-- tests/regression/ust/multi-session/test_multi_session | 4 ++-- tests/regression/ust/nprocesses/test_nprocesses | 4 ++-- tests/regression/ust/overlap/test_overlap | 4 ++-- tests/regression/ust/test_event_basic | 4 ++-- tests/regression/ust/test_event_wildcard | 4 ++-- tests/unit/test_kernel_data.c | 4 ++-- tests/unit/test_session.c | 4 ++-- tests/unit/test_uri.c | 4 ++-- tests/unit/test_ust_data.c | 4 ++-- 24 files changed, 49 insertions(+), 48 deletions(-) diff --git a/tests/regression/kernel/test_all_events b/tests/regression/kernel/test_all_events index 4862748..afd42ab 100755 --- a/tests/regression/kernel/test_all_events +++ b/tests/regression/kernel/test_all_events @@ -23,8 +23,6 @@ NUM_TESTS=8 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function test_all_event() { TRACE_PATH=$(mktemp -d) @@ -47,6 +45,8 @@ function test_all_event() # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/kernel/test_event_basic b/tests/regression/kernel/test_event_basic index 4de94dc..5c19744 100755 --- a/tests/regression/kernel/test_event_basic +++ b/tests/regression/kernel/test_event_basic @@ -23,8 +23,6 @@ NUM_TESTS=12 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function test_event_basic() { TRACE_PATH=$(mktemp -d) @@ -51,6 +49,8 @@ function test_event_basic() # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/tools/filtering/test_invalid_filter b/tests/regression/tools/filtering/test_invalid_filter index 700fa23..9e8a3c6 100755 --- a/tests/regression/tools/filtering/test_invalid_filter +++ b/tests/regression/tools/filtering/test_invalid_filter @@ -28,8 +28,6 @@ NUM_TESTS=119 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function enable_ust_lttng_event_filter { sess_name="$1" @@ -85,6 +83,8 @@ function test_bytecode_limit plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + IFS=$'\n' INVALID_FILTERS=( # Unsupported ops diff --git a/tests/regression/tools/filtering/test_unsupported_op b/tests/regression/tools/filtering/test_unsupported_op index d0c6c86..b5b7f27 100755 --- a/tests/regression/tools/filtering/test_unsupported_op +++ b/tests/regression/tools/filtering/test_unsupported_op @@ -27,8 +27,6 @@ TRACE_PATH=$(mktemp -d) NUM_TESTS=46 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function enable_ust_lttng_event_filter_unsupported { sess_name=$1 @@ -86,6 +84,8 @@ function test_unsupported_op plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + # Unsupported operators OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT" "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT") diff --git a/tests/regression/tools/filtering/test_valid_filter b/tests/regression/tools/filtering/test_valid_filter index 09ac868..5587fde 100755 --- a/tests/regression/tools/filtering/test_valid_filter +++ b/tests/regression/tools/filtering/test_valid_filter @@ -29,8 +29,6 @@ NUM_TESTS=198 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -313,6 +311,8 @@ function validator_true_statement plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + IFS=$'\n' issue_356_filter="intfield > 0 && intfield > 1 && " diff --git a/tests/regression/tools/health/test_thread_exit b/tests/regression/tools/health/test_thread_exit index 885ad19..aa2bd57 100755 --- a/tests/regression/tools/health/test_thread_exit +++ b/tests/regression/tools/health/test_thread_exit @@ -28,8 +28,6 @@ NUM_TESTS=12 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then BAIL_OUT "libhealthexit.so not available for this test." fi @@ -78,8 +76,11 @@ function test_thread_exit return 1 fi } + plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" "LTTNG_THREAD_MANAGE_APPS" "LTTNG_THREAD_REG_APPS") diff --git a/tests/regression/tools/health/test_thread_stall b/tests/regression/tools/health/test_thread_stall index 1651c02..9295131 100755 --- a/tests/regression/tools/health/test_thread_stall +++ b/tests/regression/tools/health/test_thread_stall @@ -28,8 +28,6 @@ NUM_TESTS=11 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then BAIL_OUT "libhealthstall.so not available for this test." fi @@ -99,6 +97,8 @@ function test_thread_stall plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" "LTTNG_THREAD_MANAGE_APPS" # This thread is a little bit tricky to stall, diff --git a/tests/regression/tools/health/test_tp_fail b/tests/regression/tools/health/test_tp_fail index fdb8745..c7db624 100755 --- a/tests/regression/tools/health/test_tp_fail +++ b/tests/regression/tools/health/test_tp_fail @@ -28,8 +28,6 @@ NUM_TESTS=9 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -f "$CURDIR/$SESSIOND_PRELOAD" ]; then BAIL_OUT "libhealthtpfail.so not available for this test." fi @@ -73,6 +71,8 @@ function test_tp_fail plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + THREAD=("LTTNG_THREAD_MANAGE_CLIENTS" "LTTNG_THREAD_MANAGE_APPS") diff --git a/tests/regression/tools/streaming/test_high_throughput_limits b/tests/regression/tools/streaming/test_high_throughput_limits index 2412374..f3885a8 100755 --- a/tests/regression/tools/streaming/test_high_throughput_limits +++ b/tests/regression/tools/streaming/test_high_throughput_limits @@ -35,8 +35,6 @@ NUM_TESTS=112 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -162,6 +160,8 @@ function interrupt_cleanup() plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/tools/streaming/test_kernel b/tests/regression/tools/streaming/test_kernel index db529c5..9877bb8 100755 --- a/tests/regression/tools/streaming/test_kernel +++ b/tests/regression/tools/streaming/test_kernel @@ -28,8 +28,6 @@ NUM_TESTS=10 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - # LTTng kernel modules check out=`ls /lib/modules/$(uname -r)/extra | grep lttng` if [ -z "$out" ]; then @@ -79,6 +77,8 @@ function test_kernel_after_start () plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + if [ "$(id -u)" == "0" ]; then isroot=1 else diff --git a/tests/regression/tools/streaming/test_ust b/tests/regression/tools/streaming/test_ust index 2d49cde..333b2e9 100755 --- a/tests/regression/tools/streaming/test_ust +++ b/tests/regression/tools/streaming/test_ust @@ -29,8 +29,6 @@ NUM_TESTS=18 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -87,6 +85,8 @@ function test_ust_after_start () plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_relayd "-o $TRACE_PATH" start_lttng_sessiond diff --git a/tests/regression/ust/before-after/test_before_after b/tests/regression/ust/before-after/test_before_after index 6a5776e..c3e24f7 100755 --- a/tests/regression/ust/before-after/test_before_after +++ b/tests/regression/ust/before-after/test_before_after @@ -25,8 +25,6 @@ NUM_TESTS=16 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/gen-nevents" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -86,6 +84,8 @@ test_after_apps() { # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond diag "Start application BEFORE tracing was started" diff --git a/tests/regression/ust/buffers-uid/test_buffers_uid b/tests/regression/ust/buffers-uid/test_buffers_uid index a97a90a..1c590f2 100755 --- a/tests/regression/ust/buffers-uid/test_buffers_uid +++ b/tests/regression/ust/buffers-uid/test_buffers_uid @@ -26,8 +26,6 @@ NUM_TESTS=58 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/gen-nevents" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -214,6 +212,8 @@ test_multiple_channels() { # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + TESTS=( "test_before_app" "test_after_app" diff --git a/tests/regression/ust/high-throughput/test_high_throughput b/tests/regression/ust/high-throughput/test_high_throughput index a801400..ea45051 100755 --- a/tests/regression/ust/high-throughput/test_high_throughput +++ b/tests/regression/ust/high-throughput/test_high_throughput @@ -26,8 +26,6 @@ NUM_TESTS=9 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -38,6 +36,8 @@ TRACE_PATH=$(mktemp -d) plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond create_lttng_session $SESSION_NAME $TRACE_PATH diff --git a/tests/regression/ust/low-throughput/test_low_throughput b/tests/regression/ust/low-throughput/test_low_throughput index 197210a..1ca3c38 100755 --- a/tests/regression/ust/low-throughput/test_low_throughput +++ b/tests/regression/ust/low-throughput/test_low_throughput @@ -25,8 +25,6 @@ NUM_TESTS=8 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$BIN_NAME" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -37,6 +35,8 @@ TRACE_PATH=$(mktemp -d) plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond create_lttng_session $SESSION_NAME $TRACE_PATH diff --git a/tests/regression/ust/multi-session/test_multi_session b/tests/regression/ust/multi-session/test_multi_session index ffe8355..313a7d7 100755 --- a/tests/regression/ust/multi-session/test_multi_session +++ b/tests/regression/ust/multi-session/test_multi_session @@ -25,8 +25,6 @@ NUM_TESTS=28 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/gen-nevents" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -76,6 +74,8 @@ test_multi_session() { plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond TRACE_PATH=$(mktemp -d) diff --git a/tests/regression/ust/nprocesses/test_nprocesses b/tests/regression/ust/nprocesses/test_nprocesses index ac8e99a..418fda5 100755 --- a/tests/regression/ust/nprocesses/test_nprocesses +++ b/tests/regression/ust/nprocesses/test_nprocesses @@ -27,8 +27,6 @@ NUM_TESTS=9 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/$TEST_BIN_NAME" ]; then BAIL_OUT "No UST $TEST_BIN_NAME binary detected." fi @@ -37,6 +35,8 @@ fi plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond # Start test for 1000 seconds diff --git a/tests/regression/ust/overlap/test_overlap b/tests/regression/ust/overlap/test_overlap index e823072..add8ff1 100755 --- a/tests/regression/ust/overlap/test_overlap +++ b/tests/regression/ust/overlap/test_overlap @@ -34,8 +34,6 @@ NUM_TESTS=259 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - if [ ! -x "$CURDIR/demo/demo" ]; then BAIL_OUT "No UST nevents binary detected." fi @@ -615,6 +613,8 @@ test_disable_wildcard_overlap() plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + TESTS=( "test_enable_wildcard_filter" "test_enable_wildcard_filter_2" diff --git a/tests/regression/ust/test_event_basic b/tests/regression/ust/test_event_basic index 5a9cfe4..3ff91b3 100755 --- a/tests/regression/ust/test_event_basic +++ b/tests/regression/ust/test_event_basic @@ -27,8 +27,6 @@ NUM_TESTS=25 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function enable_ust_lttng_event_per_chan() { sess_name="$1" @@ -111,6 +109,8 @@ function test_event_basic() # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond test_event_basic diff --git a/tests/regression/ust/test_event_wildcard b/tests/regression/ust/test_event_wildcard index 88c02b0..33ba4c4 100755 --- a/tests/regression/ust/test_event_wildcard +++ b/tests/regression/ust/test_event_wildcard @@ -27,8 +27,6 @@ NUM_TESTS=9 source $TESTDIR/utils/utils.sh -print_test_banner "$TEST_DESC" - function test_event_wildcard() { TRACE_PATH=$(mktemp -d) @@ -59,6 +57,8 @@ function test_event_wildcard() # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS +print_test_banner "$TEST_DESC" + start_lttng_sessiond test_event_wildcard diff --git a/tests/unit/test_kernel_data.c b/tests/unit/test_kernel_data.c index c9dc194..f368745 100644 --- a/tests/unit/test_kernel_data.c +++ b/tests/unit/test_kernel_data.c @@ -177,10 +177,10 @@ static void test_create_kernel_stream(void) int main(int argc, char **argv) { - diag("Kernel data structure unit test"); - plan_tests(NUM_TESTS); + diag("Kernel data structure unit test"); + test_create_one_kernel_session(); test_create_kernel_metadata(); test_create_kernel_channel(); diff --git a/tests/unit/test_session.c b/tests/unit/test_session.c index 196124b..61db187 100644 --- a/tests/unit/test_session.c +++ b/tests/unit/test_session.c @@ -301,10 +301,10 @@ void test_large_session_number(void) int main(int argc, char **argv) { - diag("Sessions unit tests"); - plan_tests(NUM_TESTS); + diag("Sessions unit tests"); + test_session_list(); test_create_one_session(); diff --git a/tests/unit/test_uri.c b/tests/unit/test_uri.c index 91bd21c..ba0baf9 100644 --- a/tests/unit/test_uri.c +++ b/tests/unit/test_uri.c @@ -252,10 +252,10 @@ void test_uri_cmp() int main(int argc, char **argv) { - diag("URI unit tests"); - plan_tests(NUM_TESTS); + diag("URI unit tests"); + test_uri_parsing(); test_uri_cmp(); diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c index 50d43bb..294b5c5 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -182,10 +182,10 @@ static void test_create_ust_context(void) int main(int argc, char **argv) { - diag("UST data structures unit test"); - plan_tests(NUM_TESTS); + diag("UST data structures unit test"); + test_create_one_ust_session(); test_create_ust_metadata(); test_create_ust_channel(); -- 1.8.1.3 From christian.babeux at efficios.com Thu Mar 21 15:56:45 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Thu, 21 Mar 2013 15:56:45 -0400 Subject: [lttng-dev] [PATCH lttng-tools 4/6] Tests: Use Perl prove as the testsuite runner In-Reply-To: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> References: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> Message-ID: <1363895807-17892-4-git-send-email-christian.babeux@efficios.com> Currently the regression and unit testsuites are runned via a custom runner script. By using the Perl prove utility, we can run the testsuites and also gain additionnal features such as: parallel jobs, separate testlists, etc. This commit modify the make check target to run Perl prove as the testsuite runner. Testlist: tests/unit_tests : unit tests. tests/fast_regression : a fast regression testsuite. tests/long_regression : a long regression testsuite (includes slow tests such as test_low_throughput and others). tests/root_regression : a testsuite for tests that need root access (mostly tests using lttng-modules and bandwith limits). Running a testsuite: $ cd lttng-tools/tests $ ./run.sh One can also run tests manually using prove: $ prove --exec '' path/to/test OR $ prove --exec '' - < testlist Signed-off-by: Christian Babeux --- .gitignore | 1 - tests/Makefile.am | 4 +++- tests/fast_regression | 14 ++++++++++++++ tests/long_regression | 16 ++++++++++++++++ tests/root_regression | 4 ++++ tests/run.sh | 6 +++--- tests/unit_tests | 4 ++++ 7 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 tests/fast_regression create mode 100644 tests/long_regression create mode 100644 tests/root_regression create mode 100644 tests/unit_tests diff --git a/.gitignore b/.gitignore index ac72bf4..ee58252 100644 --- a/.gitignore +++ b/.gitignore @@ -62,7 +62,6 @@ gen-nevents gen-events-time gen-events gen-ust-events -unit_tests health_check tests/regression/ust/overlap/demo/demo diff --git a/tests/Makefile.am b/tests/Makefile.am index b75de49..c53b2d8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,6 @@ SUBDIRS = utils regression unit check-am: - ./run.sh + ./run.sh unit_tests + ./run.sh fast_regression + diff --git a/tests/fast_regression b/tests/fast_regression new file mode 100644 index 0000000..fb4ac60 --- /dev/null +++ b/tests/fast_regression @@ -0,0 +1,14 @@ +regression/tools/filtering/test_invalid_filter +regression/tools/filtering/test_unsupported_op +regression/tools/filtering/test_valid_filter +regression/tools/health/test_thread_exit +regression/tools/health/test_thread_stall +regression/tools/health/test_tp_fail +regression/tools/streaming/test_ust +regression/ust/before-after/test_before_after +regression/ust/buffers-uid/test_buffers_uid +regression/ust/multi-session/test_multi_session +regression/ust/nprocesses/test_nprocesses +regression/ust/overlap/test_overlap +regression/ust/test_event_basic +regression/ust/test_event_wildcard diff --git a/tests/long_regression b/tests/long_regression new file mode 100644 index 0000000..8bae843 --- /dev/null +++ b/tests/long_regression @@ -0,0 +1,16 @@ +regression/tools/filtering/test_invalid_filter +regression/tools/filtering/test_unsupported_op +regression/tools/filtering/test_valid_filter +regression/tools/health/test_thread_exit +regression/tools/health/test_thread_stall +regression/tools/health/test_tp_fail +regression/tools/streaming/test_ust +regression/ust/before-after/test_before_after +regression/ust/buffers-uid/test_buffers_uid +regression/ust/high-throughput/test_high_throughput +regression/ust/low-throughput/test_lo_throughput +regression/ust/multi-session/test_multi_session +regression/ust/nprocesses/test_nprocesses +regression/ust/overlap/test_overlap +regression/ust/test_event_basic +regression/ust/test_event_wildcard diff --git a/tests/root_regression b/tests/root_regression new file mode 100644 index 0000000..2ae884d --- /dev/null +++ b/tests/root_regression @@ -0,0 +1,4 @@ +regression/kernel/test_all_events +regression/kernel/test_event_basic +regression/tools/streaming/test_high_throughput_limits +regression/tools/streaming/test_kernel diff --git a/tests/run.sh b/tests/run.sh index d63c72b..c6c50fd 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -16,7 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -DIR=$(dirname $0) -$DIR/regression/run.sh $@ -$DIR/unit/run.sh $@ +[ -z "$1" ] && echo "Error: No testlist. Please specify a testlist to run." && exit 1 + +prove --merge --exec '' - < $1 diff --git a/tests/unit_tests b/tests/unit_tests new file mode 100644 index 0000000..d7c68b6 --- /dev/null +++ b/tests/unit_tests @@ -0,0 +1,4 @@ +unit/test_kernel_data +unit/test_session +unit/test_uri +unit/test_ust_data -- 1.8.1.3 From christian.babeux at efficios.com Thu Mar 21 15:56:46 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Thu, 21 Mar 2013 15:56:46 -0400 Subject: [lttng-dev] [PATCH lttng-tools 5/6] Tests: Cleanup tests runner that are no longer required In-Reply-To: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> References: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> Message-ID: <1363895807-17892-5-git-send-email-christian.babeux@efficios.com> Test runners have been superseeded by testlists and the prove utility. Signed-off-by: Christian Babeux --- tests/regression/Makefile.am | 2 +- tests/regression/kernel/Makefile.am | 2 +- tests/regression/kernel/run.sh | 32 ------------------------- tests/regression/run.sh | 23 ------------------ tests/regression/tools/Makefile.am | 2 -- tests/regression/tools/run.sh | 39 ------------------------------ tests/regression/ust/Makefile.am | 2 +- tests/unit/Makefile.am | 2 -- tests/unit/run.sh | 34 -------------------------- tests/utils/runner.sh | 48 ------------------------------------- 10 files changed, 3 insertions(+), 183 deletions(-) delete mode 100755 tests/regression/kernel/run.sh delete mode 100755 tests/regression/run.sh delete mode 100755 tests/regression/tools/run.sh delete mode 100755 tests/unit/run.sh delete mode 100644 tests/utils/runner.sh diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am index 3641cf1..ddb7372 100644 --- a/tests/regression/Makefile.am +++ b/tests/regression/Makefile.am @@ -1,6 +1,6 @@ SUBDIRS = tools kernel ust -EXTRA_DIST = run-report.py test_list.py run.sh +EXTRA_DIST = run-report.py test_list.py if HAVE_LIBLTTNG_UST_CTL SUBDIRS += ust diff --git a/tests/regression/kernel/Makefile.am b/tests/regression/kernel/Makefile.am index cff432d..6b2b891 100644 --- a/tests/regression/kernel/Makefile.am +++ b/tests/regression/kernel/Makefile.am @@ -1 +1 @@ -EXTRA_DIST = run.sh test_event_basic test_all_events +EXTRA_DIST = test_event_basic test_all_events diff --git a/tests/regression/kernel/run.sh b/tests/regression/kernel/run.sh deleted file mode 100755 index fe042e4..0000000 --- a/tests/regression/kernel/run.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2013 - Christian Babeux -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -DIR=$(dirname $0) -TESTDIR=$DIR/../.. -source $TESTDIR/utils/runner.sh - -#### ADD TESTS HERE #### - -tests=( $DIR/test_event_basic - $DIR/test_all_events ) - -#### END TESTS HERE #### - -opts=("$@") -run_tests tests[@] opts[@] diff --git a/tests/regression/run.sh b/tests/regression/run.sh deleted file mode 100755 index f0ea748..0000000 --- a/tests/regression/run.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2013 - Christian Babeux -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -DIR=$(dirname $0) - -$DIR/kernel/run.sh $@ -$DIR/ust/run.sh $@ -$DIR/tools/run.sh $@ diff --git a/tests/regression/tools/Makefile.am b/tests/regression/tools/Makefile.am index 9065a37..eef793a 100644 --- a/tests/regression/tools/Makefile.am +++ b/tests/regression/tools/Makefile.am @@ -1,3 +1 @@ SUBDIRS = streaming filtering health - -EXTRA_DIST = run.sh diff --git a/tests/regression/tools/run.sh b/tests/regression/tools/run.sh deleted file mode 100755 index 4f7d2c9..0000000 --- a/tests/regression/tools/run.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2013 - Christian Babeux -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -DIR=$(dirname $0) -TESTDIR=$DIR/../.. -source $TESTDIR/utils/runner.sh - -#### ADD TESTS HERE #### - -tests=( $DIR/filtering/test_invalid_filter - $DIR/filtering/test_unsupported_op - $DIR/filtering/test_valid_filter - $DIR/health/test_thread_exit - $DIR/health/test_thread_stall - $DIR/health/test_tp_fail - $DIR/streaming/test_kernel - $DIR/streaming/test_ust - $DIR/streaming/test_high_throughput_limits ) - -#### END TESTS HERE #### - -opts=("$@") -run_tests tests[@] opts[@] diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am index d8904bb..28256c6 100644 --- a/tests/regression/ust/Makefile.am +++ b/tests/regression/ust/Makefile.am @@ -2,6 +2,6 @@ if HAVE_LIBLTTNG_UST_CTL SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ overlap -EXTRA_DIST = runall.sh run-ust-global-tests.sh test_event_basic test_event_wildcard +EXTRA_DIST = test_event_basic test_event_wildcard endif diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 1e4cce3..a9d65ab 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -14,8 +14,6 @@ LIBCOMMON=$(top_builddir)/src/common/libcommon.la LIBSESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la LIBHASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la -EXTRA_DIST = run.sh - if HAVE_LIBLTTNG_UST_CTL noinst_PROGRAMS = test_uri test_session test_ust_data test_kernel_data else diff --git a/tests/unit/run.sh b/tests/unit/run.sh deleted file mode 100755 index a809e24..0000000 --- a/tests/unit/run.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2013 - Christian Babeux -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -DIR=$(dirname $0) -TESTDIR=$DIR/.. -source $TESTDIR/utils/runner.sh - -#### ADD TESTS HERE #### - -tests=( $DIR/test_uri - $DIR/test_session - $DIR/test_ust_data - $DIR/test_kernel_data ) - -#### END TESTS HERE #### - -opts=("$@") -run_tests tests[@] opts[@] diff --git a/tests/utils/runner.sh b/tests/utils/runner.sh deleted file mode 100644 index 8f4932a..0000000 --- a/tests/utils/runner.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2013 - Christian Babeux -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -function run_tests -{ - declare -a tests=("${!1}") - declare -a tests_opts=("${!2}") - - gentap=0 - - for test_opt in ${tests_opts[@]}; - do - case "$test_opt" in - --generate-tap-files) gentap=1 ;; - *) ;; - esac - done - - for bin in ${tests[@]}; - do - if [ ! -e $bin ]; then - echo -e "$bin not found, skipping." - continue - fi - - if [ "$gentap" -eq 1 ]; then - ./$bin > ${bin}.tap 2>&1 - else - ./$bin - fi - done -} -- 1.8.1.3 From christian.babeux at efficios.com Thu Mar 21 15:56:47 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Thu, 21 Mar 2013 15:56:47 -0400 Subject: [lttng-dev] [PATCH lttng-tools 6/6] Tests: Do not exit when a failure occurs in test_buffers_uid In-Reply-To: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> References: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> Message-ID: <1363895807-17892-6-git-send-email-christian.babeux@efficios.com> Signed-off-by: Christian Babeux --- tests/regression/ust/buffers-uid/test_buffers_uid | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/regression/ust/buffers-uid/test_buffers_uid b/tests/regression/ust/buffers-uid/test_buffers_uid index 1c590f2..215a060 100755 --- a/tests/regression/ust/buffers-uid/test_buffers_uid +++ b/tests/regression/ust/buffers-uid/test_buffers_uid @@ -230,11 +230,6 @@ start_lttng_sessiond while [ $i -lt $TEST_COUNT ]; do TRACE_PATH=$(mktemp -d) ${TESTS[$i]} - if [ $? -ne 0 ]; then - stop_lttng_sessiond - exit 1 - fi - rm -rf $TRACE_PATH let "i++" done -- 1.8.1.3 From yannick.brosseau at gmail.com Thu Mar 21 16:58:20 2013 From: yannick.brosseau at gmail.com (Yannick Brosseau) Date: Thu, 21 Mar 2013 16:58:20 -0400 Subject: [lttng-dev] [PATCH lttng-tools 4/6] Tests: Use Perl prove as the testsuite runner In-Reply-To: <1363895807-17892-4-git-send-email-christian.babeux@efficios.com> References: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> <1363895807-17892-4-git-send-email-christian.babeux@efficios.com> Message-ID: <514B746C.7010205@gmail.com> On 2013-03-21 15:56, Christian Babeux wrote: > Currently the regression and unit testsuites are runned via a custom > runner script. By using the Perl prove utility, we can run the testsuites > and also gain additionnal features such as: parallel jobs, separate testlists, > etc. > This new dependency should be documented in the README file. Yannick From christian.babeux at efficios.com Thu Mar 21 17:12:21 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Thu, 21 Mar 2013 17:12:21 -0400 Subject: [lttng-dev] [PATCH lttng-tools 4/6] Tests: Use Perl prove as the testsuite runner In-Reply-To: <514B746C.7010205@gmail.com> References: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> <1363895807-17892-4-git-send-email-christian.babeux@efficios.com> <514B746C.7010205@gmail.com> Message-ID: > This new dependency should be documented in the README file. Since lttng-tools depends on Automake (which is a Perl script), would that still be relevant to add? Thanks, Christian On Thu, Mar 21, 2013 at 4:58 PM, Yannick Brosseau wrote: > On 2013-03-21 15:56, Christian Babeux wrote: >> Currently the regression and unit testsuites are runned via a custom >> runner script. By using the Perl prove utility, we can run the testsuites >> and also gain additionnal features such as: parallel jobs, separate testlists, >> etc. >> > > This new dependency should be documented in the README file. > > Yannick > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From yannick.brosseau at gmail.com Thu Mar 21 17:21:19 2013 From: yannick.brosseau at gmail.com (Yannick Brosseau) Date: Thu, 21 Mar 2013 17:21:19 -0400 Subject: [lttng-dev] [PATCH lttng-tools 4/6] Tests: Use Perl prove as the testsuite runner In-Reply-To: References: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> <1363895807-17892-4-git-send-email-christian.babeux@efficios.com> <514B746C.7010205@gmail.com> Message-ID: <514B79CF.2040807@gmail.com> On 2013-03-21 17:12, Christian Babeux wrote: >> This new dependency should be documented in the README file. > Since lttng-tools depends on Automake (which is a Perl script), would > that still be relevant to add? > Automake is not needed if you use the tar.gz, so I think it should be there From christian.babeux at efficios.com Thu Mar 21 17:25:47 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Thu, 21 Mar 2013 17:25:47 -0400 Subject: [lttng-dev] [PATCH lttng-tools 4/6] Tests: Use Perl prove as the testsuite runner In-Reply-To: <514B79CF.2040807@gmail.com> References: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> <1363895807-17892-4-git-send-email-christian.babeux@efficios.com> <514B746C.7010205@gmail.com> <514B79CF.2040807@gmail.com> Message-ID: Okay I'll post a patch updating the README. On Thu, Mar 21, 2013 at 5:21 PM, Yannick Brosseau wrote: > On 2013-03-21 17:12, Christian Babeux wrote: >>> This new dependency should be documented in the README file. >> Since lttng-tools depends on Automake (which is a Perl script), would >> that still be relevant to add? >> > Automake is not needed if you use the tar.gz, so I think it should be there From jeremie.galarneau at efficios.com Thu Mar 21 17:26:27 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Thu, 21 Mar 2013 17:26:27 -0400 Subject: [lttng-dev] [PATCH lttng-ust] Add missing buffers-uid folder in ust regression test Makefile Message-ID: <1363901187-7955-1-git-send-email-jeremie.galarneau@efficios.com> Signed-off-by: J?r?mie Galarneau --- tests/regression/ust/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am index d8904bb..c5dee21 100644 --- a/tests/regression/ust/Makefile.am +++ b/tests/regression/ust/Makefile.am @@ -1,6 +1,6 @@ if HAVE_LIBLTTNG_UST_CTL SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ - overlap + overlap buffers-uid EXTRA_DIST = runall.sh run-ust-global-tests.sh test_event_basic test_event_wildcard -- 1.8.2 From jeremie.galarneau at efficios.com Thu Mar 21 17:28:00 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Thu, 21 Mar 2013 17:28:00 -0400 Subject: [lttng-dev] [PATCH lttng-ust] Add missing buffers-uid folder in ust regression test Makefile In-Reply-To: <1363901187-7955-1-git-send-email-jeremie.galarneau@efficios.com> References: <1363901187-7955-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: Oops...Wrong subject! Applies to lttng-tools, obviously. J?r?mie On Thu, Mar 21, 2013 at 5:26 PM, J?r?mie Galarneau wrote: > > Signed-off-by: J?r?mie Galarneau > --- > tests/regression/ust/Makefile.am | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am > index d8904bb..c5dee21 100644 > --- a/tests/regression/ust/Makefile.am > +++ b/tests/regression/ust/Makefile.am > @@ -1,6 +1,6 @@ > if HAVE_LIBLTTNG_UST_CTL > SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ > - overlap > + overlap buffers-uid > > EXTRA_DIST = runall.sh run-ust-global-tests.sh test_event_basic test_event_wildcard > > -- > 1.8.2 > -- J?r?mie Galarneau EfficiOS Inc. http://www.efficios.com From raphael.beamonte at gmail.com Thu Mar 21 18:13:20 2013 From: raphael.beamonte at gmail.com (=?UTF-8?q?Rapha=C3=ABl=20Beamonte?=) Date: Thu, 21 Mar 2013 18:13:20 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <514B44ED.3000702@efficios.com> References: <514B44ED.3000702@efficios.com> Message-ID: <2423f47f2d19009bcfe5af3cbe0c3350deb68fdf.1363903997.git.raphael.beamonte@gmail.com> Signed-off-by: Rapha?l Beamonte --- .gitignore | 2 ++ Makefile.am | 4 +-- include/Makefile.am | 45 ++++++++++++++++++++++++++++++- include/version.h.tmpl | 27 +++++++++++++++++++ src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++ src/bin/lttng-sessiond/main.c | 2 +- src/bin/lttng/commands/version.c | 4 ++- src/bin/lttng/lttng.c | 5 +++- src/bin/lttng/utils.h | 13 +++++++++ 9 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 include/version.h.tmpl diff --git a/.gitignore b/.gitignore index ac72bf4..a36f0b9 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,8 @@ config/ !config/epoll.m4 !config/config_feature.m4 +include/version.h + src/bin/lttng-sessiond/lttng-sessiond src/bin/lttng/lttng src/bin/lttng-consumerd/lttng-consumerd diff --git a/Makefile.am b/Makefile.am index b0537ce..03fdabc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,9 @@ ACLOCAL_AMFLAGS = -I config -SUBDIRS = src \ +SUBDIRS = include \ + src \ tests \ extras \ - include \ doc dist_doc_DATA = LICENSE \ diff --git a/include/Makefile.am b/include/Makefile.am index 0bcb6f9..fce6276 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1 +1,44 @@ -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h +## The version.h file must be verified and generated or updated if the +## git commit id (called git version here) changed since the last build +## of lttng-tools. +version.h: version.h.tmpl + ## We first create variables for the current git version and + ## the locations of the version.h and version.h.tmpl files + (git_version="$$(git describe --long --all 2>/dev/null)"; \ + version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \ + version_h="$(top_builddir)/include/version.h"; \ + ## If the version.h file doesn't exist or is not up to date, + ## We replace it by the version.h.tmpl file + if [ ! -e "$${version_h}" ] || \ + [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \ + cp "$${version_h_tmpl}" "$${version_h}"; \ + fi; \ + if [ -z "$${git_version}" ]; then \ + ## If we don't have a git version, we verify that there is + ## not any define of GIT_VERSION in the version.h file, or + ## we remove it. + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \ + fi; \ + else \ + ## If we have a git version, we verify that it isn't the same + ## as the one currently in the file (if there is one), as we + ## don't want to update the file if it is already up to date + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ + ## If there is already a GIT_VERSION defined, + ## we just replace it by the new version + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + else \ + ## Else, we add a GIT_VERSION define + ## containing our new version. + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + fi; \ + fi; \ + fi) + +## version.h is defined as a .PHONY file even if it's a real file as +## we want our routine to be runned for each build. +.PHONY: version.h + +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h version.h diff --git a/include/version.h.tmpl b/include/version.h.tmpl new file mode 100644 index 0000000..c42789c --- /dev/null +++ b/include/version.h.tmpl @@ -0,0 +1,27 @@ +/* + * version.h + * + * Linux Trace Toolkit version header file + * + * Copyright (C) 2013 - Rapha?l Beamonte + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef VERSION_H +#define VERSION_H + +#define GIT_VERSION + +#endif /* VERSION_H */ diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h index 9258f38..e91918a 100644 --- a/src/bin/lttng-sessiond/lttng-sessiond.h +++ b/src/bin/lttng-sessiond/lttng-sessiond.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - David Goulet + * Copyright (C) 2013 - Rapha?l Beamonte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only, @@ -28,6 +29,8 @@ #include "session.h" #include "ust-app.h" +#include "version.h" + extern const char default_home_dir[], default_tracing_group[], @@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2]; int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size); int sessiond_check_thread_quit_pipe(int fd, uint32_t events); +/* + * This static const char allows to return the version number depending + * whether or not the GIT_VERSION value is available + */ +#ifdef GIT_VERSION +static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")"; +#else /* GIT_VERSION */ +static const char lttng_sessiond_version[] = VERSION; +#endif /* GIT_VERSION */ + + #endif /* _LTT_SESSIOND_H */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index d88bafe..41701e9 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3555,7 +3555,7 @@ static int parse_args(int argc, char **argv) usage(); exit(EXIT_FAILURE); case 'V': - fprintf(stdout, "%s\n", VERSION); + fprintf(stdout, "%s\n", lttng_sessiond_version); exit(EXIT_SUCCESS); case 'S': opt_sig_parent = 1; diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c index 7f69de3..2170d00 100644 --- a/src/bin/lttng/commands/version.c +++ b/src/bin/lttng/commands/version.c @@ -26,6 +26,7 @@ #include #include "../command.h" +#include "../utils.h" enum { OPT_HELP = 1, @@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv) } MSG("lttng version " VERSION " - " VERSION_NAME); - MSG("\n" VERSION_DESCRIPTION "\n"); + MSG("%s", lttng_version); + MSG(VERSION_DESCRIPTION "\n"); MSG("Web site: http://lttng.org"); MSG("\nlttng is free software and under the GPL license and part LGPL"); diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index d3aaa84..4289901 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -31,6 +31,7 @@ #include #include "command.h" +#include "utils.h" /* Variables */ static char *progname; @@ -81,7 +82,9 @@ static struct cmd_struct commands[] = { static void usage(FILE *ofp) { - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); + fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n"); + fprintf(ofp, lttng_version); + fprintf(ofp, "\n"); fprintf(ofp, "usage: lttng [OPTIONS] []\n"); fprintf(ofp, "\n"); fprintf(ofp, "Options:\n"); diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h index 9f7bfcc..12ee7c0 100644 --- a/src/bin/lttng/utils.h +++ b/src/bin/lttng/utils.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - David Goulet + * Copyright (C) 2013 - Rapha?l Beamonte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only, @@ -19,8 +20,20 @@ #define _LTTNG_UTILS_H #include +#include char *get_session_name(void); void list_cmd_options(FILE *ofp, struct poptOption *options); +/* + * This static const char allows to return the version number depending + * whether or not the GIT_VERSION value is available + */ +#ifdef GIT_VERSION +static const char lttng_version[] = "Git version: " GIT_VERSION "\n"; +#else /* GIT_VERSION */ +static const char lttng_version[] = ""; +#endif /* GIT_VERSION */ + + #endif /* _LTTNG_UTILS_H */ -- 1.7.10.4 From mathieu.desnoyers at efficios.com Thu Mar 21 21:26:59 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Thu, 21 Mar 2013 21:26:59 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Add missing buffers-uid folder in ust regression test Makefile In-Reply-To: <1363901187-7955-1-git-send-email-jeremie.galarneau@efficios.com> References: <1363901187-7955-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <20130322012659.GA17191@Krystal> changing the subject, CCing to David. * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: > > Signed-off-by: J?r?mie Galarneau > --- > tests/regression/ust/Makefile.am | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am > index d8904bb..c5dee21 100644 > --- a/tests/regression/ust/Makefile.am > +++ b/tests/regression/ust/Makefile.am > @@ -1,6 +1,6 @@ > if HAVE_LIBLTTNG_UST_CTL > SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ > - overlap > + overlap buffers-uid > > EXTRA_DIST = runall.sh run-ust-global-tests.sh test_event_basic test_event_wildcard > > -- > 1.8.2 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From fdeslaur at gmail.com Thu Mar 21 22:06:16 2013 From: fdeslaur at gmail.com (Francis Deslauriers) Date: Thu, 21 Mar 2013 22:06:16 -0400 Subject: [lttng-dev] [trap-probe] Add lttng-probe-trap In-Reply-To: References: Message-ID: <1363917976-29492-1-git-send-email-fdeslaur@gmail.com> This probe monitors trap entry and trap exit trace event. Signed-off-by: Francis Deslauriers --- instrumentation/events/lttng-module/trap.h | 46 +++++++++++++++++++++++++++ instrumentation/events/mainline/trap.h | 47 ++++++++++++++++++++++++++++ probes/Makefile | 1 + probes/lttng-probe-trap.c | 43 +++++++++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 instrumentation/events/lttng-module/trap.h create mode 100644 instrumentation/events/mainline/trap.h create mode 100644 probes/lttng-probe-trap.c diff --git a/instrumentation/events/lttng-module/trap.h b/instrumentation/events/lttng-module/trap.h new file mode 100644 index 0000000..124bbba --- /dev/null +++ b/instrumentation/events/lttng-module/trap.h @@ -0,0 +1,46 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM trap + +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TRAP_H + +#include + +TRACE_EVENT(trap_entry, + + TP_PROTO(struct pt_regs *regs, long trap), + + TP_ARGS(regs, trap), + + TP_STRUCT__entry( + __field( long, trap ) + __field( unsigned long, ip ) + + ), + TP_fast_assign( + tp_assign(trap, trap) + tp_assign(ip, regs ? instruction_pointer(regs) : 0UL) + ), + + TP_printk("number=%ld ip=%lu", __entry->trap, __entry->ip) +) + +TRACE_EVENT(trap_exit, + + TP_PROTO(long trap), + + TP_ARGS(trap), + + TP_STRUCT__entry( + __field( long, trap ) + ), + TP_fast_assign( + tp_assign(trap, trap) + ), + + TP_printk("number=%ld", __entry->trap) +) + +#endif /* _TRACE_TRAP_H */ +/* This part must be outside protection */ +#include "../../../probes/define_trace.h" diff --git a/instrumentation/events/mainline/trap.h b/instrumentation/events/mainline/trap.h new file mode 100644 index 0000000..171b9cf --- /dev/null +++ b/instrumentation/events/mainline/trap.h @@ -0,0 +1,47 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM trap + +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TRAP_H + +#include + +TRACE_EVENT(trap_entry, + + TP_PROTO(struct pt_regs *regs, long trap), + + TP_ARGS(regs, trap), + + TP_STRUCT__entry( + __field( long, trap ) + __field( unsigned long, ip ) + ), + + TP_fast_assign( + __entry->trap = trap; + __entry->ip = regs ? instruction_pointer(regs) : 0UL; + ), + + TP_printk("number=%ld ip=%lu", __entry->trap, __entry->ip) +); + +TRACE_EVENT(trap_exit, + + TP_PROTO(long trap), + + TP_ARGS(trap), + + TP_STRUCT__entry( + __field( long, trap ) + ), + + TP_fast_assign( + __entry->trap = trap; + ), + + TP_printk("number=%ld", __entry->trap) +); + +#endif /* _TRACE_TRAP_H */ +/* This part must be outside protection */ +#include diff --git a/probes/Makefile b/probes/Makefile index 088cd5f..c8d0085 100644 --- a/probes/Makefile +++ b/probes/Makefile @@ -15,6 +15,7 @@ obj-m += lttng-probe-timer.o obj-m += lttng-probe-kmem.o obj-m += lttng-probe-module.o obj-m += lttng-probe-power.o +obj-m += lttng-probe-trap.o obj-m += lttng-probe-statedump.o diff --git a/probes/lttng-probe-trap.c b/probes/lttng-probe-trap.c new file mode 100644 index 0000000..17c1526 --- /dev/null +++ b/probes/lttng-probe-trap.c @@ -0,0 +1,43 @@ +/* + * probes/lttng-probe-trap.c + * + * LTTng trap probes. + * + * Copyright (C) 2010-2012 Mathieu Desnoyers + * Copyright (C) 2013 Francis Deslauriers . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; only + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +/* + * Create the tracepoint static inlines from the kernel to validate that our + * trace event macros match the kernel we run on. + */ +#include +#include "../wrapper/tracepoint.h" +/* + * Create LTTng tracepoint probes. + */ +#define LTTNG_PACKAGE_BUILD +#define CREATE_TRACE_POINTS +#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module + +#include "../instrumentation/events/lttng-module/trap.h" + +MODULE_LICENSE("GPL and additional rights"); +MODULE_AUTHOR("Francis Deslauriers "); +MODULE_DESCRIPTION("LTTng trap probes"); -- 1.7.10.4 From mathieu.desnoyers at efficios.com Thu Mar 21 22:17:27 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Thu, 21 Mar 2013 22:17:27 -0400 Subject: [lttng-dev] [trap-probe] Add lttng-probe-trap In-Reply-To: <1363917976-29492-1-git-send-email-fdeslaur@gmail.com> References: <1363917976-29492-1-git-send-email-fdeslaur@gmail.com> Message-ID: <20130322021727.GA18146@Krystal> * Francis Deslauriers (fdeslaur at gmail.com) wrote: > This probe monitors trap entry and trap exit trace event. It looks good to me! However, maybe it would be safer to first get a feedback on your Linux mainline patch before pulling this one in ? Otherwise, we could end up with incompatible definitions compared to mainline Linux. If this is OK with you, please re-post when the mainline Linux patch gets accepted. Thanks, Mathieu > > Signed-off-by: Francis Deslauriers > --- > instrumentation/events/lttng-module/trap.h | 46 +++++++++++++++++++++++++++ > instrumentation/events/mainline/trap.h | 47 ++++++++++++++++++++++++++++ > probes/Makefile | 1 + > probes/lttng-probe-trap.c | 43 +++++++++++++++++++++++++ > 4 files changed, 137 insertions(+) > create mode 100644 instrumentation/events/lttng-module/trap.h > create mode 100644 instrumentation/events/mainline/trap.h > create mode 100644 probes/lttng-probe-trap.c > > diff --git a/instrumentation/events/lttng-module/trap.h b/instrumentation/events/lttng-module/trap.h > new file mode 100644 > index 0000000..124bbba > --- /dev/null > +++ b/instrumentation/events/lttng-module/trap.h > @@ -0,0 +1,46 @@ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM trap > + > +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_TRAP_H > + > +#include > + > +TRACE_EVENT(trap_entry, > + > + TP_PROTO(struct pt_regs *regs, long trap), > + > + TP_ARGS(regs, trap), > + > + TP_STRUCT__entry( > + __field( long, trap ) > + __field( unsigned long, ip ) > + > + ), > + TP_fast_assign( > + tp_assign(trap, trap) > + tp_assign(ip, regs ? instruction_pointer(regs) : 0UL) > + ), > + > + TP_printk("number=%ld ip=%lu", __entry->trap, __entry->ip) > +) > + > +TRACE_EVENT(trap_exit, > + > + TP_PROTO(long trap), > + > + TP_ARGS(trap), > + > + TP_STRUCT__entry( > + __field( long, trap ) > + ), > + TP_fast_assign( > + tp_assign(trap, trap) > + ), > + > + TP_printk("number=%ld", __entry->trap) > +) > + > +#endif /* _TRACE_TRAP_H */ > +/* This part must be outside protection */ > +#include "../../../probes/define_trace.h" > diff --git a/instrumentation/events/mainline/trap.h b/instrumentation/events/mainline/trap.h > new file mode 100644 > index 0000000..171b9cf > --- /dev/null > +++ b/instrumentation/events/mainline/trap.h > @@ -0,0 +1,47 @@ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM trap > + > +#if !defined(_TRACE_TRAP_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_TRAP_H > + > +#include > + > +TRACE_EVENT(trap_entry, > + > + TP_PROTO(struct pt_regs *regs, long trap), > + > + TP_ARGS(regs, trap), > + > + TP_STRUCT__entry( > + __field( long, trap ) > + __field( unsigned long, ip ) > + ), > + > + TP_fast_assign( > + __entry->trap = trap; > + __entry->ip = regs ? instruction_pointer(regs) : 0UL; > + ), > + > + TP_printk("number=%ld ip=%lu", __entry->trap, __entry->ip) > +); > + > +TRACE_EVENT(trap_exit, > + > + TP_PROTO(long trap), > + > + TP_ARGS(trap), > + > + TP_STRUCT__entry( > + __field( long, trap ) > + ), > + > + TP_fast_assign( > + __entry->trap = trap; > + ), > + > + TP_printk("number=%ld", __entry->trap) > +); > + > +#endif /* _TRACE_TRAP_H */ > +/* This part must be outside protection */ > +#include > diff --git a/probes/Makefile b/probes/Makefile > index 088cd5f..c8d0085 100644 > --- a/probes/Makefile > +++ b/probes/Makefile > @@ -15,6 +15,7 @@ obj-m += lttng-probe-timer.o > obj-m += lttng-probe-kmem.o > obj-m += lttng-probe-module.o > obj-m += lttng-probe-power.o > +obj-m += lttng-probe-trap.o > > obj-m += lttng-probe-statedump.o > > diff --git a/probes/lttng-probe-trap.c b/probes/lttng-probe-trap.c > new file mode 100644 > index 0000000..17c1526 > --- /dev/null > +++ b/probes/lttng-probe-trap.c > @@ -0,0 +1,43 @@ > +/* > + * probes/lttng-probe-trap.c > + * > + * LTTng trap probes. > + * > + * Copyright (C) 2010-2012 Mathieu Desnoyers > + * Copyright (C) 2013 Francis Deslauriers . > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; only > + * version 2.1 of the License. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#include > + > +/* > + * Create the tracepoint static inlines from the kernel to validate that our > + * trace event macros match the kernel we run on. > + */ > +#include > +#include "../wrapper/tracepoint.h" > +/* > + * Create LTTng tracepoint probes. > + */ > +#define LTTNG_PACKAGE_BUILD > +#define CREATE_TRACE_POINTS > +#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module > + > +#include "../instrumentation/events/lttng-module/trap.h" > + > +MODULE_LICENSE("GPL and additional rights"); > +MODULE_AUTHOR("Francis Deslauriers "); > +MODULE_DESCRIPTION("LTTng trap probes"); > -- > 1.7.10.4 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From barthelemy at crans.org Fri Mar 22 06:02:44 2013 From: barthelemy at crans.org (=?ISO-8859-1?Q?S=E9bastien_Barth=E9l=E9my?=) Date: Fri, 22 Mar 2013 11:02:44 +0100 Subject: [lttng-dev] TMF: inconsistencies in the context vtid reporting Message-ID: Hello, I'm using simultaneous kernel and userspace tracing in order to understand how a multi threaded application (mis)behaves at shutdown. The idea is to use userspace tracepoints in the application, augmented with the vtid context, in order to know which thread is calling what and to relate that with the threads lifespan as reconstructed from the kernel scheduler traces. First, is the approach ok? Am I right to expect the vtid attached to ust event to match the tid shown in the reconstructed kernel scheduler state? Should I expect "time shifts" between the kernel and userspace traces (which would make the correlation harder). I was hoping to see the unix signals in the kernel trace too but could not find them so far. So now, the problem is that I get inconsistencies: some UST events report a vtid which is shown as waiting by the kernel trace (both in the Control Flow and the Resources views). How could a waiting thread trigger an UST event? I believe my kernel trace is complete, since the following command shows no output. $ babeltrace lttng-traces/auto-20130321-172308/kernel/ > /dev/null My userspace trace is not complete. But I believe it does not matter, because the missing events are seconds before the time window I'm interested in, and AFAIK, there is no state reconstruction involved (but may be there is?). I eventually came to a more blatant inconsistency: the displayed context vtid of an event is not always the same. See the two attached screenshots. The same UST event is highlighted, displayed once as part of a single UST trace and then in an experiment (same UST trace + kernel trace) the reported vtid is not the same: 15443 and 15411 respectively. babeltrace goes for 15443: $ babeltrace lttng-traces/auto-20130321-172308/ust/naoqi-bin-15411-20130321-172659/ | grep "17:27:13.883622748" [warning] Tracer discarded 165 events between [17:27:00.328855374] and [17:27:00.328857812]. You should consider recording a new trace with larger buffers or with fewer events enabled. [17:27:13.883622748] (+0.000087543) ald-0987-de:naoqi-bin:15411 qi_alcommon:module_metacall_stop: { cpu_id = 1 }, { vtid = 15443, vpid = 15411 }, { methodId = 34, moduleName = "ALMotion", methodName = "getAngles::(mb)" } I cannot tell it for sure but I think I also saw the same event in the experiment view with the wrong vtid. I'm using TMF 2.0.0.201303211612 (nightly build from yesterday). And by the way, thank your for the support I already got on IRC yesterday, you're a dream project to work with. -------------- next part -------------- A non-text attachment was scrubbed... Name: tmf_exp.png Type: image/png Size: 192266 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: tmf_trace.png Type: image/png Size: 182554 bytes Desc: not available URL: From Daniel.Thibault at drdc-rddc.gc.ca Fri Mar 22 09:25:52 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Fri, 22 Mar 2013 13:25:52 +0000 Subject: [lttng-dev] Updated easy-ust Makefile Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD028E81@VAL-E-01.valcartier.drdc-rddc.gc.ca> In my previous note on this mailing list, forget the bit about LD_PRELOAD being beholden to the remaining library search. I got fooled into thinking that for unrelated reasons. Turns out LD_PRELOAD loads the so regardless of the search's outcome: it's just added to the list of dependencies to load (traversal is breadth-first, it turns out), and its initializer called last. Here is a suggested updated lttng-ust/doc/examples/easy-ust/Makefile which fixes a minor problem (missing LDFLAGS preventing make from succeeding out-of-the-box) and adds additional targets demonstrating other ways tracepoints can be compiled into an application. Please review this for any factual errors. - - - BEGIN - - - # Copyright (C) 2011-2012 Matthew Khouzam # Copyright (C) 2012 Mathieu Desnoyers # # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED # OR IMPLIED. ANY USE IS AT YOUR OWN RISK. # # Permission is hereby granted to use or copy this program for any # purpose, provided the above notices are retained on all copies. # Permission to modify the code and to distribute modified code is # granted, provided the above notices are retained, and a notice that # the code was modified is included with the above copyright notice. # # This makefile is not using automake so that people can see how to make # simply. It builds a sample program in any one of four (really three) ways: # # ("static", default) with a statically embedded tracepoint provider probe, # through inclusion. # # ("staticlib") with a statically embedded tracepoint provider probe, through # a static library (libtp.a). The resulting samplestaticlib binary is identical # to the samplestatic binary. # # ("dynamic", "dynamicfull") with a dynamically loaded shared library # (libtp.so). The only difference between these two is that "dynamicfull" sets # the TRACEPOINT_PROBE_DYNAMIC_LINKAGE define in order to avoid needing to be # linked statically with the shared library. # # Currently, an instrumented application that would use a dynamically linked # (as opposed to dynamically loaded) tracepoint provider shared library would # still dynamically load it (using the dlopen() system call), so the difference # is pointless. # # The dynamic samples must use LD_PRELOAD to run because the trace provider # shared library (libtp.so) is not in the library search path; to obviate this # requirement, you can either install your trace provider shared library in # the library search path (e.g. /usr/local/lib) or add a DT_RUNPATH tag to your # sample so it looks in its own directory for missing libraries (look for the # commented-out "$(CC) ... -Wl,-rpath,\$ORIGIN,--enable-new-dtags" lines in # the "dynamic" and "dynamicfull" targets). The latter option does have the # disadvantage that the dynamic linker will look for all the required libraries # (libdl.so, libc.so, liblttng-ust.so, etc.) in sample's directory first. # # The "html" target helps for documentation (req. code2html). AR = ar CC = gcc LIBS = -ldl -llttng-ust # On Linux #LIBS = -lc -llttng-ust # On BSD CFLAGS = -I. LDFLAGS = -L/usr/local/lib SOFLAGS = -fPIC SOVERSION_MAJOR = 1 SOVERSION_MINOR = 0 # default make is "all" all: static static: sample.o tp.o $(CC) -o sample$@ $^ $(LDFLAGS) $(LIBS) @echo " Use './sample$@' to run sample$@" staticlib: sample.o libtp.a $(CC) -o sample$@ $^ $(LDFLAGS) $(LIBS) -L. @echo " Use './sample$@' to run sample$@" dynamic: sample.o libtp.so # $(CC) -o sample$@ $< $(LDFLAGS) $(LIBS) -L. -ltp \ # -Wl,-rpath,\$ORIGIN,--enable-new-dtags $(CC) -o sample$@ $< $(LDFLAGS) $(LIBS) -L. -ltp @echo " Use 'LD_PRELOAD=./libtp.so ./sample$@' to run sample$@" dynamicfull: sampledynamic.o libtp.so # $(CC) -o sample$@ $< $(LDFLAGS) $(LIBS) \ # -Wl,-rpath,\$ORIGIN,--enable-new-dtags $(CC) -o sample$@ $< $(LDFLAGS) $(LIBS) @echo " Use 'LD_PRELOAD=./libtp.so ./sample$@' to run sample$@" sample.o: sample.c sample_component_provider.h $(CC) $(CFLAGS) -c -o $@ $< sampledynamic.o: sample.c sample_component_provider.h $(CC) $(CFLAGS) -D TRACEPOINT_PROBE_DYNAMIC_LINKAGE -c -o $@ $< libtp.a: tp.o $(AR) -cq $@ $< libtp.so: libtp.o $(CC) -shared -Wl,-soname,$@.$(SOVERSION_MAJOR) -o \ $@.$(SOVERSION_MAJOR).$(SOVERSION_MINOR) $(LDFLAGS) $(LIBS) $< ln -sf $@.$(SOVERSION_MAJOR).$(SOVERSION_MINOR) $@.$(SOVERSION_MAJOR) ln -sf $@.$(SOVERSION_MAJOR) $@ libtp.o: tp.c sample_component_provider.h $(CC) $(CFLAGS) $(SOFLAGS) -c -o $@ $< tp.o: tp.c sample_component_provider.h $(CC) $(CFLAGS) -c -o $@ $< html: sample_component_provider.html sample.html tp.html %.html: %.c code2html -lc $< $@ %.html : %.h code2html -lc $< $@ .PHONY: clean clean: rm -f *.html rm -f *.o *.a *.so *.so.* rm -f samplestatic* sampledynamic* - - - END - - - Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC? G3J 1X5 CANADA Vox?: (418) 844-4000 x4245 Fax?: (418) 844-4538 NAC?: 918V QSDJ Gouvernement du Canada?/ Government of Canada From mathieu.desnoyers at efficios.com Fri Mar 22 10:00:45 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Fri, 22 Mar 2013 10:00:45 -0400 Subject: [lttng-dev] [PATCH] lttng-module: sched.h: Fix compilation on 3.9 kernel In-Reply-To: <1363957095-54785-1-git-send-email-maxin.john@enea.com> References: <1363957095-54785-1-git-send-email-maxin.john@enea.com> Message-ID: <20130322140045.GA2275@Krystal> * maxin.john at enea.com (maxin.john at enea.com) wrote: > From: "Maxin B. John" > > With commit 8bd75c77b7c6a3954140dd2e20346aef3efe4a35 > included in 3.9-rc1 kernel, rt specific bits in "linux/sched.h" > were moved into new header file "linux/sched/rt.h". merged into both master and stable-2.1 branches, thanks! Mathieu > > Fixes this compilation error: > CC [M] /home/majo/lttng/lttng-modules/probes/lttng-probe-sched.o > ... > /home/majo/lttng/lttng-modules/probes/../instrumentation/events/lttng-module > /../../../probes/../instrumentation/events/lttng-module/sched.h: > In function '__event_probe__sched_switch': > /home/majo/lttng/lttng-modules/probes/../instrumentation/events/lttng-module > /../../../probes/../instrumentation/events/lttng-module/sched.h:164:1: > error: 'MAX_RT_PRIO' undeclared (first use in this function) > ... > > Signed-off-by: Maxin B. John > --- > instrumentation/events/lttng-module/sched.h | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/instrumentation/events/lttng-module/sched.h b/instrumentation/events/lttng-module/sched.h > index e42acd2..25faad0 100644 > --- a/instrumentation/events/lttng-module/sched.h > +++ b/instrumentation/events/lttng-module/sched.h > @@ -8,6 +8,9 @@ > #include > #include > #include > +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) > +#include > +#endif > > #ifndef _TRACE_SCHED_DEF_ > #define _TRACE_SCHED_DEF_ > -- > 1.7.5.4 > -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From Daniel.Thibault at drdc-rddc.gc.ca Fri Mar 22 12:24:54 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Fri, 22 Mar 2013 16:24:54 +0000 Subject: [lttng-dev] liblttng-ust finalizer oddity Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD028EF8@VAL-E-01.valcartier.drdc-rddc.gc.ca> Below is an edited-for-brevity log that highlights an oddity of the liblttng-ust finalizer: it triggers a load and initialization of libgcc_s, but libgcc_s's finalizer doesn't run (I checked libgcc_s.so with readelf, and there is indeed a FINI entry in there). Is this a feature of libgcc_s? Of the Linux loader? Or of LTTng? Is it anything to worry about? $ LD_DEBUG=libs LD_PRELOAD=.libs/liblttng-ust-provider-ust-tests-demo.so:.libs/liblttng-ust-provider-ust-tests-demo3.so ./demo 805: find library=libdl.so.2 [0]; searching 805: search cache=/etc/ld.so.cache 805: trying file=/lib/x86_64-linux-gnu/libdl.so.2 805: 805: find library=libc.so.6 [0]; searching 805: search cache=/etc/ld.so.cache 805: trying file=/lib/x86_64-linux-gnu/libc.so.6 805: [...] 805: calling init: .libs/liblttng-ust-provider-ust-tests-demo.so 805: 805: 805: initialize program: ./demo 805: 805: 805: transferring control: ./demo 805: Demo program starting. Tracing... done. 805: 805: calling fini: ./demo [0] 805: 805: 805: calling fini: .libs/liblttng-ust-provider-ust-tests-demo.so [0] 805: 805: 805: calling fini: .libs/liblttng-ust-provider-ust-tests-demo3.so [0] 805: 805: 805: calling fini: /lib/x86_64-linux-gnu/libdl.so.2 [0] 805: 805: 805: calling fini: /home/daniel/Documents/lttng-ust-2.1.1+-08a3170/liblttng-ust/.libs/liblttng-ust.so.0 [0] 805: 805: find library=libgcc_s.so.1 [0]; searching 805: search path=/home/daniel/Documents/lttng-ust-2.1.1+-08a3170/liblttng-ust/.libs (RPATH from file .libs/liblttng-ust-provider-ust-tests-demo.so) 805: trying file=/home/daniel/Documents/lttng-ust-2.1.1+-08a3170/liblttng-ust/.libs/libgcc_s.so.1 805: search path=/home/daniel/Documents/lttng-ust-2.1.1+-08a3170/liblttng-ust/.libs (RPATH from file .libs/liblttng-ust-provider-ust-tests-demo.so) 805: trying file=/home/daniel/Documents/lttng-ust-2.1.1+-08a3170/liblttng-ust/.libs/libgcc_s.so.1 805: search cache=/etc/ld.so.cache 805: trying file=/lib/x86_64-linux-gnu/libgcc_s.so.1 805: 805: 805: calling init: /lib/x86_64-linux-gnu/libgcc_s.so.1 805: 805: 805: calling fini: /home/daniel/Documents/lttng-ust-2.1.1+-08a3170/liblttng-ust/.libs/liblttng-ust-tracepoint.so.0 [0] 805: 805: 805: calling fini: /lib/x86_64-linux-gnu/librt.so.1 [0] 805: 805: 805: calling fini: /usr/local/lib/liburcu-bp.so.2 [0] 805: 805: 805: calling fini: /usr/local/lib/liburcu-cds.so.2 [0] 805: 805: 805: calling fini: /lib/x86_64-linux-gnu/libpthread.so.0 [0] 805: Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC? G3J 1X5 CANADA Vox?: (418) 844-4000 x4245 Fax?: (418) 844-4538 NAC?: 918V QSDJ Gouvernement du Canada?/ Government of Canada From maxin.john at enea.com Fri Mar 22 08:58:15 2013 From: maxin.john at enea.com (maxin.john at enea.com) Date: Fri, 22 Mar 2013 13:58:15 +0100 Subject: [lttng-dev] [PATCH] lttng-module: sched.h: Fix compilation on 3.9 kernel Message-ID: <1363957095-54785-1-git-send-email-maxin.john@enea.com> From: "Maxin B. John" With commit 8bd75c77b7c6a3954140dd2e20346aef3efe4a35 included in 3.9-rc1 kernel, rt specific bits in "linux/sched.h" were moved into new header file "linux/sched/rt.h". Fixes this compilation error: CC [M] /home/majo/lttng/lttng-modules/probes/lttng-probe-sched.o ... /home/majo/lttng/lttng-modules/probes/../instrumentation/events/lttng-module /../../../probes/../instrumentation/events/lttng-module/sched.h: In function '__event_probe__sched_switch': /home/majo/lttng/lttng-modules/probes/../instrumentation/events/lttng-module /../../../probes/../instrumentation/events/lttng-module/sched.h:164:1: error: 'MAX_RT_PRIO' undeclared (first use in this function) ... Signed-off-by: Maxin B. John --- instrumentation/events/lttng-module/sched.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/instrumentation/events/lttng-module/sched.h b/instrumentation/events/lttng-module/sched.h index e42acd2..25faad0 100644 --- a/instrumentation/events/lttng-module/sched.h +++ b/instrumentation/events/lttng-module/sched.h @@ -8,6 +8,9 @@ #include #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) +#include +#endif #ifndef _TRACE_SCHED_DEF_ #define _TRACE_SCHED_DEF_ -- 1.7.5.4 From barthelemy at crans.org Fri Mar 22 13:58:51 2013 From: barthelemy at crans.org (=?ISO-8859-1?Q?S=E9bastien_Barth=E9l=E9my?=) Date: Fri, 22 Mar 2013 18:58:51 +0100 Subject: [lttng-dev] TMF: inconsistencies in the context vtid reporting In-Reply-To: References: Message-ID: On Fri, Mar 22, 2013 at 11:02 AM, S?bastien Barth?l?my wrote: > I was hoping to see the unix signals in the kernel trace too but could > not find them so far. I found them eventually. From maxin.john at enea.com Fri Mar 22 14:07:02 2013 From: maxin.john at enea.com (maxin.john at enea.com) Date: Fri, 22 Mar 2013 19:07:02 +0100 Subject: [lttng-dev] [PATCH] lttng-abi.c: fix the error check Message-ID: <1363975622-37401-1-git-send-email-maxin.john@enea.com> From: "Maxin B. John" lttng_syscalls_register() may return -ENOMEM or -EINVAL. So fix the error path to check for negative values in lttng_abi_create_event() and lttng_channel_ioctl(). Signed-off-by: Maxin B. John --- lttng-abi.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/lttng-abi.c b/lttng-abi.c index 25a350a..5613b75 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -648,7 +648,7 @@ int lttng_abi_create_event(struct file *channel_file, if (event_param->name[0] != '\0') return -EINVAL; ret = lttng_syscalls_register(channel, NULL); - if (ret) + if (ret < 0) goto fd_error; event_fd = 0; break; @@ -753,6 +753,8 @@ long lttng_channel_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } ret = lttng_abi_create_event(file, uevent_param); + if (ret < 0) + return -ENOMEM; old_event_error_free_old_param: kfree(old_uevent_param); -- 1.7.5.4 From christian.babeux at efficios.com Fri Mar 22 15:49:19 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Fri, 22 Mar 2013 15:49:19 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Add optional Perl dependency requirement to README Message-ID: <1363981759-4718-1-git-send-email-christian.babeux@efficios.com> Signed-off-by: Christian Babeux --- README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README b/README index 4ef88cb..cfbf1ac 100644 --- a/README +++ b/README @@ -28,6 +28,9 @@ REQUIREMENTS: * Debian/Ubuntu package: libpopt-dev + - Perl (optional) + Needed for make check and tests. + - SWIG >= 2.0 (optional) Needed for Python bindings (--enable-python-bindings). -- 1.8.2 From alexmonthy at voxpopuli.im Fri Mar 22 17:24:59 2013 From: alexmonthy at voxpopuli.im (Alexandre Montplaisir) Date: Fri, 22 Mar 2013 17:24:59 -0400 Subject: [lttng-dev] TMF: inconsistencies in the context vtid reporting In-Reply-To: References: Message-ID: <514CCC2B.1040802@voxpopuli.im> Hi S?bastien, On 13-03-22 06:02 AM, S?bastien Barth?l?my wrote: > Hello, > > I'm using simultaneous kernel and userspace tracing in order to > understand how a multi threaded application (mis)behaves at shutdown. > > The idea is to use userspace tracepoints in the application, augmented > with the vtid context, in order to know which thread is calling what > and to relate that with the threads lifespan as reconstructed from the > kernel scheduler traces. > > First, is the approach ok? Am I right to expect the vtid attached to > ust event to match the tid shown in the reconstructed kernel scheduler > state? It should work, yes. However note that the concept of "vtid" (virtual thread ID) is used to differentiate the tid assigned to a process when used within a container (LXC) vs. its tid on the host. You could use context.tid too, but if you don't use containers those two should be the same. > Should I expect "time shifts" between the kernel and userspace traces > (which would make the correlation harder). Ideally no, but depending on your kernel/libc versions, UST might not have access to the same time sources as the kernel tracer, so you could get small offsets. Maybe one of the tracer devs can give a better explanation. > > I was hoping to see the unix signals in the kernel trace too but could > not find them so far. > > So now, the problem is that I get inconsistencies: some UST events > report a vtid which is shown as waiting by the kernel trace (both in > the Control Flow and the Resources views). How could a waiting thread > trigger an UST event? > > I believe my kernel trace is complete, since the following command > shows no output. > > $ babeltrace lttng-traces/auto-20130321-172308/kernel/ > /dev/null > > My userspace trace is not complete. But I believe it does not matter, > because the missing events are seconds before the time window I'm > interested in, and AFAIK, there is no state reconstruction involved > (but may be there is?). It could happen ; maybe the tracer missed an important sched_switch event that set a process in a particular state. I wouldn't recommend running analyses on traces with missing events, some information could be all wrong. Unless you are on an embedded platform with very limited memory, it's usually safe to increase the buffer size to a couple MBs. See --enable-channel and --subbuf-size in the LTTng man page. I have to warn you about https://bugs.lttng.org/issues/228 in advance though... I still think the default value should be higher (and have the embedded guys use --subbuf-size to reduce it), but I don't call those shots ;) > I eventually came to a more blatant inconsistency: the displayed > context vtid of an event is not always the same. > > [...] > > I'm using TMF 2.0.0.201303211612 (nightly build from yesterday). Are your traces available somewhere (if they can be made public)? I would like to take a look at it, it seems the CTF parser gets confused between vtid and vpid for some weird reason... > And by the way, thank your for the support I already got on IRC > yesterday, you're a dream project to work with. Thanks! That's encouraging to hear ;) Cheers, Alex From mathieu.desnoyers at efficios.com Fri Mar 22 17:57:45 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Fri, 22 Mar 2013 17:57:45 -0400 Subject: [lttng-dev] [PATCH] lttng-abi.c: fix the error check In-Reply-To: <1363975622-37401-1-git-send-email-maxin.john@enea.com> References: <1363975622-37401-1-git-send-email-maxin.john@enea.com> Message-ID: <20130322215745.GB18746@Krystal> * maxin.john at enea.com (maxin.john at enea.com) wrote: > From: "Maxin B. John" > > lttng_syscalls_register() may return -ENOMEM or -EINVAL. So fix > the error path to check for negative values in lttng_abi_create_event() > and lttng_channel_ioctl(). I don't understand what this is supposed to fix. The expected return values from lttng_syscalls_register are: 0 -> success -EINVAL -> error -ENOMEM -> error so whether we check for error with if (ret) or if (ret < 0) should yield to the exact same result, since we don't expect positive return values. And for lttng_abi_create_event(), the original code flow is to execute 2 kfree(), and then "return ret", which will return either -EINVAL or -ENOMEM to the caller. So by adding this return -ENOMEM, you hide the real cause (-EINVAL or -ENOMEM), and you add 2 memory leaks. Or am I missing something ? Thanks, Mathieu > > Signed-off-by: Maxin B. John > --- > lttng-abi.c | 4 +++- > 1 files changed, 3 insertions(+), 1 deletions(-) > > diff --git a/lttng-abi.c b/lttng-abi.c > index 25a350a..5613b75 100644 > --- a/lttng-abi.c > +++ b/lttng-abi.c > @@ -648,7 +648,7 @@ int lttng_abi_create_event(struct file *channel_file, > if (event_param->name[0] != '\0') > return -EINVAL; > ret = lttng_syscalls_register(channel, NULL); > - if (ret) > + if (ret < 0) > goto fd_error; > event_fd = 0; > break; > @@ -753,6 +753,8 @@ long lttng_channel_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > break; > } > ret = lttng_abi_create_event(file, uevent_param); > + if (ret < 0) > + return -ENOMEM; > > old_event_error_free_old_param: > kfree(old_uevent_param); > -- > 1.7.5.4 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From yannick.brosseau at gmail.com Fri Mar 22 20:18:19 2013 From: yannick.brosseau at gmail.com (Brosseau, Yannick) Date: Fri, 22 Mar 2013 20:18:19 -0400 Subject: [lttng-dev] Fwd: [Bug 925071] New: babeltrace: Does not support aarch64 in f19 and rawhide In-Reply-To: References: Message-ID: I think that's a problem that might occur for other distribution soon ---------- Mensaje remitido ---------- De: Fecha: mar 22, 2013 8:06 p.m. Asunto: [Bug 925071] New: babeltrace: Does not support aarch64 in f19 and rawhide Para: Cc: Product: Fedora https://bugzilla.redhat.com/show_bug.cgi?id=925071 Bug ID: 925071 Summary: babeltrace: Does not support aarch64 in f19 and rawhide Product: Fedora Version: rawhide Component: babeltrace Severity: unspecified Priority: unspecified Assignee: yannick.brosseau at gmail.com Reporter: dennis at ausil.us QA Contact: extras-qa at fedoraproject.org CC: yannick.brosseau at gmail.com Blocks: 922257 (ARM64) Support for the ARM 64 bit CPU architecture (aarch64) was introduced in autoconf 2.69. babeltrace appears to use an earlier version of autoconf, preventing its being built. This can be fixed in of three ways (In order of preference): 1. Work with upstream to migrate the package to autoconf 2.69. 2. Rerun autoconf or autoreconf in %prep or %build prior to running configure. 3. Apply the patch at http://ausil.fedorapeople.org/aarch64/babeltrace/babeltrace-aarch64.patch which updates config.guess and config.sub to recognize aarch64. -- You are receiving this mail because: You are on the CC list for the bug. You are the assignee for the bug. -------------- next part -------------- An HTML attachment was scrubbed... URL: From maxin.john at enea.com Sat Mar 23 10:34:35 2013 From: maxin.john at enea.com (Maxin B. John) Date: Sat, 23 Mar 2013 15:34:35 +0100 Subject: [lttng-dev] [PATCH] lttng-abi.c: fix the error check In-Reply-To: <20130322215745.GB18746@Krystal> Message-ID: <20130323143435.GA55460@sestofb10.enea.se> I was trying to fix a random problem happened in hawkboard with 3.9.0-rc3 kernel. root at hawkboard:~# uname -a Linux hawkboard 3.9.0-rc3-00244-g9217cbb #35 PREEMPT Fri Mar 22 18:03:26 CET 2013 armv5tejl GNU/Linux root at hawkboard:~# lttng create mysession Session mysession created. Traces will be written in /home/root/lttng-traces/mysession-20130321-131130 root at hawkboard:~# lttng enable-event -a -k lttng-sessiond: page allocation failure: order:10, mode:0x10c0d0 [] (unwind_backtrace+0x0/0xfc) from [] (dump_stack+0x20/0x24) [] (dump_stack+0x20/0x24) from [] (warn_alloc_failed+0xd0/0x114) [] (warn_alloc_failed+0xd0/0x114) from [] (__alloc_pages_nodemask+0x620/0x8bc) [] (__alloc_pages_nodemask+0x620/0x8bc) from [] (__get_free_pages+0x20/0x5c) [] (__get_free_pages+0x20/0x5c) from [] (kmalloc_order_trace+0x34/0xf4) [] (kmalloc_order_trace+0x34/0xf4) from [] (lttng_syscalls_register+0x1a4/0x244 [lttng_tracer]) [] (lttng_syscalls_register+0x1a4/0x244 [lttng_tracer]) from [] (lttng_abi_create_event+0x7c/0x138 [lttng_tracer]) [] (lttng_abi_create_event+0x7c/0x138 [lttng_tracer]) from [] (lttng_channel_ioctl+0x198/0x53c [lttng_tracer]) [] (lttng_channel_ioctl+0x198/0x53c [lttng_tracer]) from [] (do_vfs_ioctl+0x8c/0x608) [] (do_vfs_ioctl+0x8c/0x608) from [] (sys_ioctl+0x80/0x88) [] (sys_ioctl+0x80/0x88) from [] (ret_fast_syscall+0x0/0x44) Mem-info: DMA per-cpu: CPU 0: hi: 18, btch: 3 usd: 0 active_anon:789 inactive_anon:12 isolated_anon:0 active_file:2056 inactive_file:2348 isolated_file:0 unevictable:0 dirty:0 writeback:0 unstable:0 free:2790 slab_reclaimable:852 slab_unreclaimable:944 mapped:589 shmem:21 pagetables:134 bounce:0 free_cma:0 DMA free:11160kB min:968kB low:1208kB high:1452kB active_anon:3156kB inactive_anon:48kB active_file:8224kB inactive_file:9392kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:65536kB managed:59016kB mlocked:0kB dirty:0kB writeback:0kB mapped:2356kB shmem:84kB slab_reclaimable:3408kB slab_unreclaimable:3776kB kernel_stack:448kB pagetables:536kB unstable:0kB bounce:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no lowmem_reserve[]: 0 0 0 DMA: 4*4kB (UEM) 9*8kB (UEM) 4*16kB (UEM) 8*32kB (EMR) 4*64kB (EMR) 4*128kB (EMR) 3*256kB (UER) 4*512kB (UEMR) 3*1024kB (UEM) 2*2048kB (UE) 0*4096kB = 11160kB 4432 total pagecache pages 16384 pages of RAM 2955 free pages 1571 reserved pages 1571 slab pages 264956 pages shared 0 pages swap cached PERROR: create event ioctl: Cannot allocate memory [in kernel_create_event() at kernel.c:206] All kernel events are enabled in channel channel0 > The expected return values from lttng_syscalls_register are: >?? > 0 -> success > -EINVAL -> error > -ENOMEM -> error >?? > so whether we check for error with >?? > if (ret) > or > if (ret < 0) >?? > should yield to the exact same result, since we don't expect positive > return values. Now, I can see that my idea wasn't right. > And for lttng_abi_create_event(), the original code flow is to execute 2 > kfree(), and then "return ret", which will return either -EINVAL or > -ENOMEM to the caller. >?? > So by adding this return -ENOMEM, you hide the real cause (-EINVAL or > -ENOMEM), and you add 2 memory leaks. Ahh.. Sorry! > Or am I missing something ? >?? > Thanks, > Mathieu Best Regards, Maxin From mathieu.desnoyers at efficios.com Sat Mar 23 11:46:58 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Sat, 23 Mar 2013 11:46:58 -0400 Subject: [lttng-dev] [PATCH] lttng-abi.c: fix the error check In-Reply-To: <20130323143435.GA55460@sestofb10.enea.se> References: <20130322215745.GB18746@Krystal> <20130323143435.GA55460@sestofb10.enea.se> Message-ID: <20130323154658.GA28816@Krystal> * Maxin B. John (maxin.john at enea.com) wrote: > I was trying to fix a random problem happened in hawkboard with > 3.9.0-rc3 kernel. > > root at hawkboard:~# uname -a > Linux hawkboard 3.9.0-rc3-00244-g9217cbb #35 PREEMPT Fri Mar 22 > 18:03:26 CET 2013 armv5tejl GNU/Linux > > root at hawkboard:~# lttng create mysession > Session mysession created. > Traces will be written in > /home/root/lttng-traces/mysession-20130321-131130 > root at hawkboard:~# lttng enable-event -a -k > lttng-sessiond: page allocation failure: order:10, mode:0x10c0d0 > [] (unwind_backtrace+0x0/0xfc) from [] > (dump_stack+0x20/0x24) > [] (dump_stack+0x20/0x24) from [] > (warn_alloc_failed+0xd0/0x114) > [] (warn_alloc_failed+0xd0/0x114) from [] > (__alloc_pages_nodemask+0x620/0x8bc) > [] (__alloc_pages_nodemask+0x620/0x8bc) from [] > (__get_free_pages+0x20/0x5c) > [] (__get_free_pages+0x20/0x5c) from [] > (kmalloc_order_trace+0x34/0xf4) > [] (kmalloc_order_trace+0x34/0xf4) from [] > (lttng_syscalls_register+0x1a4/0x244 [lttng_tracer]) > [] (lttng_syscalls_register+0x1a4/0x244 [lttng_tracer]) from Oh! got it. if we look at: int lttng_syscalls_register(struct lttng_channel *chan, void *filter) /* create syscall table mapping syscall to events */ chan->sc_table = kzalloc(sizeof(struct lttng_event *) * ARRAY_SIZE(sc_table), GFP_KERNEL); we notice that if sc_table is huge (e.g. because some system call numbers would be really, really high), then we could possibly run out of memory when doing this allocation. What is the range of system call numbers on your architecture ? Thanks, Mathieu > [] (lttng_abi_create_event+0x7c/0x138 [lttng_tracer]) > [] (lttng_abi_create_event+0x7c/0x138 [lttng_tracer]) from > [] (lttng_channel_ioctl+0x198/0x53c [lttng_tracer]) > [] (lttng_channel_ioctl+0x198/0x53c [lttng_tracer]) from > [] (do_vfs_ioctl+0x8c/0x608) > [] (do_vfs_ioctl+0x8c/0x608) from [] > (sys_ioctl+0x80/0x88) > [] (sys_ioctl+0x80/0x88) from [] > (ret_fast_syscall+0x0/0x44) > Mem-info: > DMA per-cpu: > CPU 0: hi: 18, btch: 3 usd: 0 > active_anon:789 inactive_anon:12 isolated_anon:0 > active_file:2056 inactive_file:2348 isolated_file:0 > unevictable:0 dirty:0 writeback:0 unstable:0 > free:2790 slab_reclaimable:852 slab_unreclaimable:944 > mapped:589 shmem:21 pagetables:134 bounce:0 > free_cma:0 > DMA free:11160kB min:968kB low:1208kB high:1452kB active_anon:3156kB > inactive_anon:48kB active_file:8224kB inactive_file:9392kB > unevictable:0kB isolated(anon):0kB isolated(file):0kB present:65536kB > managed:59016kB mlocked:0kB dirty:0kB writeback:0kB mapped:2356kB > shmem:84kB slab_reclaimable:3408kB slab_unreclaimable:3776kB > kernel_stack:448kB pagetables:536kB unstable:0kB bounce:0kB > free_cma:0kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no > lowmem_reserve[]: 0 0 0 > DMA: 4*4kB (UEM) 9*8kB (UEM) 4*16kB (UEM) 8*32kB (EMR) 4*64kB (EMR) > 4*128kB (EMR) 3*256kB (UER) 4*512kB (UEMR) 3*1024kB (UEM) 2*2048kB > (UE) 0*4096kB = 11160kB > 4432 total pagecache pages > 16384 pages of RAM > 2955 free pages > 1571 reserved pages > 1571 slab pages > 264956 pages shared > 0 pages swap cached > PERROR: create event ioctl: Cannot allocate memory [in > kernel_create_event() at kernel.c:206] > All kernel events are enabled in channel channel0 > > > The expected return values from lttng_syscalls_register are: > >? > > 0 -> success > > -EINVAL -> error > > -ENOMEM -> error > >? > > so whether we check for error with > >? > > if (ret) > > or > > if (ret < 0) > >? > > should yield to the exact same result, since we don't expect positive > > return values. > > Now, I can see that my idea wasn't right. > > > And for lttng_abi_create_event(), the original code flow is to execute 2 > > kfree(), and then "return ret", which will return either -EINVAL or > > -ENOMEM to the caller. > >? > > So by adding this return -ENOMEM, you hide the real cause (-EINVAL or > > -ENOMEM), and you add 2 memory leaks. > > Ahh.. Sorry! > > > Or am I missing something ? > >? > > Thanks, > > Mathieu > > Best Regards, > Maxin -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From mathieu.desnoyers at efficios.com Sat Mar 23 12:03:34 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Sat, 23 Mar 2013 12:03:34 -0400 Subject: [lttng-dev] [PATCH] lttng-abi.c: fix the error check In-Reply-To: <20130323154658.GA28816@Krystal> References: <20130322215745.GB18746@Krystal> <20130323143435.GA55460@sestofb10.enea.se> <20130323154658.GA28816@Krystal> Message-ID: <20130323160334.GB28816@Krystal> * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote: > * Maxin B. John (maxin.john at enea.com) wrote: > > I was trying to fix a random problem happened in hawkboard with > > 3.9.0-rc3 kernel. > > > > root at hawkboard:~# uname -a > > Linux hawkboard 3.9.0-rc3-00244-g9217cbb #35 PREEMPT Fri Mar 22 > > 18:03:26 CET 2013 armv5tejl GNU/Linux > > > > root at hawkboard:~# lttng create mysession > > Session mysession created. > > Traces will be written in > > /home/root/lttng-traces/mysession-20130321-131130 > > root at hawkboard:~# lttng enable-event -a -k > > lttng-sessiond: page allocation failure: order:10, mode:0x10c0d0 > > [] (unwind_backtrace+0x0/0xfc) from [] > > (dump_stack+0x20/0x24) > > [] (dump_stack+0x20/0x24) from [] > > (warn_alloc_failed+0xd0/0x114) > > [] (warn_alloc_failed+0xd0/0x114) from [] > > (__alloc_pages_nodemask+0x620/0x8bc) > > [] (__alloc_pages_nodemask+0x620/0x8bc) from [] > > (__get_free_pages+0x20/0x5c) > > [] (__get_free_pages+0x20/0x5c) from [] > > (kmalloc_order_trace+0x34/0xf4) > > [] (kmalloc_order_trace+0x34/0xf4) from [] > > (lttng_syscalls_register+0x1a4/0x244 [lttng_tracer]) > > [] (lttng_syscalls_register+0x1a4/0x244 [lttng_tracer]) from > > Oh! got it. > > if we look at: > > int lttng_syscalls_register(struct lttng_channel *chan, void *filter) > > /* create syscall table mapping syscall to events */ > chan->sc_table = kzalloc(sizeof(struct lttng_event *) > * ARRAY_SIZE(sc_table), GFP_KERNEL); > > we notice that if sc_table is huge (e.g. because some system call > numbers would be really, really high), then we could possibly run out of > memory when doing this allocation. > > What is the range of system call numbers on your architecture ? a look at: arch/arm/include/uapi/asm/unistd.h shows: #define __NR_OABI_SYSCALL_BASE 0x900000 #if defined(__thumb__) || defined(__ARM_EABI__) #define __NR_SYSCALL_BASE 0 #else #define __NR_SYSCALL_BASE __NR_OABI_SYSCALL_BASE #endif So this offset "base" might be causing the large allocation. Can you try the following patch and see if it helps ? --- diff --git a/lttng-syscalls.c b/lttng-syscalls.c index 62ed24a..10449b9 100644 --- a/lttng-syscalls.c +++ b/lttng-syscalls.c @@ -35,6 +35,10 @@ # endif #endif +#ifndef __NR_SYSCALL_BASE +#define __NR_SYSCALL_BASE 0 +#endif + static void syscall_entry_probe(void *__data, struct pt_regs *regs, long id); @@ -133,7 +137,7 @@ struct trace_syscall_entry { #undef TRACE_SYSCALL_TABLE #define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \ - [ _nr ] = { \ + [ (_nr) - __NR_SYSCALL_BASE ] = { \ .func = __event_probe__##_template, \ .nrargs = (_nrargs), \ .fields = __event_fields___##_template, \ @@ -147,7 +151,7 @@ static const struct trace_syscall_entry sc_table[] = { #undef TRACE_SYSCALL_TABLE #define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \ - [ _nr ] = { \ + [ (_nr) - __NR_SYSCALL_BASE] = { \ .func = __event_probe__##compat_##_template, \ .nrargs = (_nrargs), \ .fields = __event_fields___##compat_##_template,\ @@ -180,7 +184,9 @@ void syscall_entry_probe(void *__data, struct pt_regs *regs, long id) struct lttng_event *event, *unknown_event; const struct trace_syscall_entry *table, *entry; size_t table_len; + long syscall_offset; + syscall_offset = id - __NR_SYSCALL_BASE; if (unlikely(is_compat_task())) { table = compat_sc_table; table_len = ARRAY_SIZE(compat_sc_table); @@ -190,19 +196,19 @@ void syscall_entry_probe(void *__data, struct pt_regs *regs, long id) table_len = ARRAY_SIZE(sc_table); unknown_event = chan->sc_unknown; } - if (unlikely(id >= table_len)) { - syscall_entry_unknown(unknown_event, regs, id); + if (unlikely(syscall_offset >= table_len)) { + syscall_entry_unknown(unknown_event, regs, syscall_offset); return; } if (unlikely(is_compat_task())) - event = chan->compat_sc_table[id]; + event = chan->compat_sc_table[syscall_offset]; else - event = chan->sc_table[id]; + event = chan->sc_table[syscall_offset]; if (unlikely(!event)) { - syscall_entry_unknown(unknown_event, regs, id); + syscall_entry_unknown(unknown_event, regs, syscall_offset); return; } - entry = &table[id]; + entry = &table[syscall_offset]; WARN_ON_ONCE(!entry); switch (entry->nrargs) { -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From maxin.john at enea.com Sat Mar 23 12:56:21 2013 From: maxin.john at enea.com (Maxin B. John) Date: Sat, 23 Mar 2013 17:56:21 +0100 Subject: [lttng-dev] [PATCH] lttng-abi.c: fix the error check In-Reply-To: <20130323160334.GB28816@Krystal> Message-ID: <20130323165621.GA62630@sestofb10.enea.se> On Sat, Mar 23, 2013 at 12:03:34PM -0400, Mathieu Desnoyers wrote: > * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote: > > * Maxin B. John (maxin.john at enea.com) wrote: > > > I was trying to fix a random problem happened in hawkboard with?? > > > 3.9.0-rc3 kernel. > > > > > > root at hawkboard:~# uname -a > > > Linux hawkboard 3.9.0-rc3-00244-g9217cbb #35 PREEMPT Fri Mar 22 > > > 18:03:26 CET 2013 armv5tejl GNU/Linux > a look at: > > arch/arm/include/uapi/asm/unistd.h > > shows: > > #define __NR_OABI_SYSCALL_BASE 0x900000 > > #if defined(__thumb__) || defined(__ARM_EABI__) > #define __NR_SYSCALL_BASE 0 > #else > #define __NR_SYSCALL_BASE __NR_OABI_SYSCALL_BASE > #endif > > So this offset "base" might be causing the large allocation. Can you try > the following patch and see if it helps ? > --- I have applied the patch and tested it on the device. However, I can still see the random page allocation failure (It works fine at first time and then randomly fails). Could be a hardware problem.. I will verify it in another similar board. I forgot to mention that even before, with this page allocation failure, lttng works as expected and I can see the output using babeltrace. oot at hawkboard:~# lttng enable-event -a -k lttng-sessiond: page allocation failure: order:10, mode:0x10c0d0 [] (unwind_backtrace+0x0/0xfc) from [] (dump_stack+0x20/0x24) [] (dump_stack+0x20/0x24) from [] (warn_alloc_failed+0xd0/0x114) [] (warn_alloc_failed+0xd0/0x114) from [] (__alloc_pages_nodemask+0x620/0x8bc) [] (__alloc_pages_nodemask+0x620/0x8bc) from [] (__get_free_pages+0x20/0x5c) [] (__get_free_pages+0x20/0x5c) from [] (kmalloc_order_trace+0x34/0xf4) [] (kmalloc_order_trace+0x34/0xf4) from [] (lttng_syscalls_register+0x1a4/0x240 [lttng_tracer]) [] (lttng_syscalls_register+0x1a4/0x240 [lttng_tracer]) from [] (lttng_abi_create_event+0x7c/0x138 [lttng_tracer]) [] (lttng_abi_create_event+0x7c/0x .... Thanks & Regards, Maxin From mathieu.desnoyers at efficios.com Sat Mar 23 13:37:17 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Sat, 23 Mar 2013 13:37:17 -0400 Subject: [lttng-dev] Fwd: [Bug 925071] New: babeltrace: Does not support aarch64 in f19 and rawhide In-Reply-To: References: Message-ID: <20130323173717.GC28816@Krystal> Will fix within babeltrace 1.1.0. I just updated my trees for the next lttng-ust releases too (just removed my config/config.* and re-ran ./bootstrap). David, you might want to do the same for lttng-tools. Thanks, Mathieu * Brosseau, Yannick (yannick.brosseau at gmail.com) wrote: > I think that's a problem that might occur for other distribution soon > ---------- Mensaje remitido ---------- > De: > Fecha: mar 22, 2013 8:06 p.m. > Asunto: [Bug 925071] New: babeltrace: Does not support aarch64 in f19 and > rawhide > Para: > Cc: > > Product: Fedora > https://bugzilla.redhat.com/show_bug.cgi?id=925071 > > Bug ID: 925071 > Summary: babeltrace: Does not support aarch64 in f19 and > rawhide > Product: Fedora > Version: rawhide > Component: babeltrace > Severity: unspecified > Priority: unspecified > Assignee: yannick.brosseau at gmail.com > Reporter: dennis at ausil.us > QA Contact: extras-qa at fedoraproject.org > CC: yannick.brosseau at gmail.com > Blocks: 922257 (ARM64) > > Support for the ARM 64 bit CPU architecture (aarch64) was introduced in > autoconf 2.69. babeltrace appears to use an earlier version of > autoconf, preventing its being built. This can be fixed in of three ways > (In > order of preference): > > 1. Work with upstream to migrate the package to autoconf 2.69. > > 2. Rerun autoconf or autoreconf in %prep or %build prior to running > configure. > > 3. Apply the patch at > http://ausil.fedorapeople.org/aarch64/babeltrace/babeltrace-aarch64.patch > which updates config.guess and config.sub to recognize aarch64. > > -- > You are receiving this mail because: > You are on the CC list for the bug. > You are the assignee for the bug. > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From mathieu.desnoyers at efficios.com Sat Mar 23 13:45:01 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Sat, 23 Mar 2013 13:45:01 -0400 Subject: [lttng-dev] [RELEASE] Babeltrace 1.1.0 Message-ID: <20130323174501.GA30102@Krystal> The Babeltrace project provides trace read and write libraries, as well as a trace converter. Plugins can be created for any trace format to allow its conversion to/from another trace format. The main format expected to be converted to/from is the Common Trace Format (CTF). The default input format of the "babeltrace" command is CTF, and its default output format is a human-readable text log. The "babeltrace-log" command converts from a text log to a CTF trace. Noteworthy changes: We had to make important namespacing changes to the user-visible API between babeltrace 1.0.x and 1.1.0 in order to ensure libbabeltrace does not with external project symbols and types. Changelog: 2013-03-23 Babeltrace 1.1.0 * Reinsert "at end of stream" message for discarded events * Improvement: Message from babeltrace concerning discarded events needs improvement * Cleanup: typo fix * Cleanup: add end of line at end of verbose message * Fix: misleading message from babeltrace --verbose * Fix: babeltrace --fields all overrides --no-delta * Add verbosity to stream id error message * Fix: Ensure the specified input format is CTF * Fix: Undefined behavior of double free on strlist in get_names_args * Fix: ctf-text: don't close stdout * Fix: warning message for unexpected trace byte order * Namespace the struct declaration * Namespace the struct definition * Namespace the struct format * Namespace the struct mmap_stream * Namespace the struct trace_descriptor * Namespace struct stream_pos * Namespace compliance for dependencies function * Cleanup error messages * Fix: babeltrace: make '-w' actually work * Convert the unit tests to the TAP format * Spelling cleanups within comments * Move the bitfield test to tests/lib/ * Fix: Added a null pointer check to bt_ctf_field_name * Add babeltrace.pc to gitignore * namespacing: place flex/bison symbols under bt_yy namespace * namespace the lookup_integer function * namespace the definition functions * namespace the variant functions * namespace the declaration functions * namespace the collection functions * namespace the heap functions * namespace the struct functions * namespace the string functions * namespace the sequence functions * namespace the int functions * namespace the enum functions * namespace definition_ref and definition_unref * namespace declaration_ref and declaration_unref * namespace the array functions * namespace the scope_path functions * Hide internal functions of libbabeltrace-ctf * Hide internal functions of ctf-text * BT_HIDDEN macro * Namespace the lookup_enum function Project website: http://www.efficios.com/babeltrace Download link: http://www.efficios.com/files/babeltrace/ CTF specification: http://www.efficios.com/ctf -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From christian.babeux at efficios.com Sat Mar 23 14:47:55 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Sat, 23 Mar 2013 14:47:55 -0400 Subject: [lttng-dev] [PATCH babeltrace] Replace AM_PROG_MKDIR obsolete macro with AC_PROG_MKDIR_P Message-ID: <1364064475-24015-1-git-send-email-christian.babeux@efficios.com> The bootstrap script is complaining with a deprecation warning [1] for the AM_PROG_MKDIR_P Automake macro. Relevant bootstrap output: configure.ac:13: warning: The 'AM_PROG_MKDIR_P' macro is deprecated, and will soon be removed. configure.ac:13: You should use the Autoconf-provided 'AC_PROG_MKDIR_P' macro instead, configure.ac:13: and use '$(MKDIR_P)' instead of '$(mkdir_p)'in your Makefile.am files. Fix this by updating configure.ac with the proposed AC_PROG_MKDIR_P macro. [1] - https://www.gnu.org/software/automake/manual/html_node/Obsolete-Macros.html Signed-off-by: Christian Babeux --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b96e09f..cc23f5a 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_CONFIG_MACRO_DIR([m4]) -AM_PROG_MKDIR_P +AC_PROG_MKDIR_P AC_CONFIG_HEADERS([config.h]) -- 1.8.2 From mathieu.desnoyers at efficios.com Sat Mar 23 19:03:27 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Sat, 23 Mar 2013 19:03:27 -0400 Subject: [lttng-dev] [PATCH babeltrace] Replace AM_PROG_MKDIR obsolete macro with AC_PROG_MKDIR_P In-Reply-To: <1364064475-24015-1-git-send-email-christian.babeux@efficios.com> References: <1364064475-24015-1-git-send-email-christian.babeux@efficios.com> Message-ID: <20130323230327.GA2745@Krystal> * Christian Babeux (christian.babeux at efficios.com) wrote: > The bootstrap script is complaining with a deprecation warning [1] for > the AM_PROG_MKDIR_P Automake macro. Merged, thanks! Mathieu > > Relevant bootstrap output: > > configure.ac:13: warning: The 'AM_PROG_MKDIR_P' macro is deprecated, > and will soon be removed. > configure.ac:13: You should use the Autoconf-provided 'AC_PROG_MKDIR_P' > macro instead, > configure.ac:13: and use '$(MKDIR_P)' instead of '$(mkdir_p)'in your > Makefile.am files. > > Fix this by updating configure.ac with the proposed AC_PROG_MKDIR_P macro. > > [1] - https://www.gnu.org/software/automake/manual/html_node/Obsolete-Macros.html > > Signed-off-by: Christian Babeux > --- > configure.ac | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/configure.ac b/configure.ac > index b96e09f..cc23f5a 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -10,7 +10,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) > > AC_CONFIG_MACRO_DIR([m4]) > > -AM_PROG_MKDIR_P > +AC_PROG_MKDIR_P > > AC_CONFIG_HEADERS([config.h]) > > -- > 1.8.2 > -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From maxin.john at enea.com Mon Mar 25 08:30:57 2013 From: maxin.john at enea.com (maxin.john at enea.com) Date: Mon, 25 Mar 2013 13:30:57 +0100 Subject: [lttng-dev] [PATCH] lttng-module: block.h : Fix build for 3.9 kernel Message-ID: <1364214657-35068-1-git-send-email-maxin.john@enea.com> From: "Maxin B. John" commit :3a366e614d0837d9fc23f78cdb1a1186ebc3387f block: add missing block_bio_complete() tracepoint added block_bio_complete to 3.9 kernel commit : 8c1cf6bb02fda79b0a4b9bd121f6be6d4ce7a15a block: add @req to bio_{front|back}_merge tracepoints added block_bio_backmerge and block_bio_frontmerge to 3.9 kernel Update block.h based on these commits in mainline kernel Fixes this build failure: .... include/trace/events/block.h:353:1: note: previous definition of 'trace_block_bio_frontmerge' was here make[3]: *** [/home/majo/kernel/lttng/lttng-modules/probes/ lttng-probe-block.o] Error 1 make[2]: *** [/home/majo/kernel/lttng/lttng-modules/probes] Error 2 make[1]: *** [_module_/home/majo/kernel/lttng/lttng-modules] Error 2 make: *** [default] Error 2 Signed-off-by: Maxin B. John --- instrumentation/events/lttng-module/block.h | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/instrumentation/events/lttng-module/block.h b/instrumentation/events/lttng-module/block.h index d42ebd4..59bd2c0 100644 --- a/instrumentation/events/lttng-module/block.h +++ b/instrumentation/events/lttng-module/block.h @@ -311,6 +311,13 @@ TRACE_EVENT(block_bio_bounce, * This tracepoint indicates there is no further work to do on this * block IO operation @bio. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) +/** + * commit :3a366e614d0837d9fc23f78cdb1a1186ebc3387f + * block: add missing block_bio_complete() tracepoint + * added block_bio_complete to 3.9.0 kernel + */ +#else TRACE_EVENT(block_bio_complete, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) @@ -349,6 +356,7 @@ TRACE_EVENT(block_bio_complete, (unsigned long long)__entry->sector, __entry->nr_sector, __entry->error) ) +#endif DECLARE_EVENT_CLASS(block_bio, @@ -387,6 +395,13 @@ DECLARE_EVENT_CLASS(block_bio, * Merging block request @bio to the end of an existing block request * in queue @q. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) +/** + * commit : 8c1cf6bb02fda79b0a4b9bd121f6be6d4ce7a15a + * block: add @req to bio_{front|back}_merge tracepoints + * added block_bio_backmerge and block_bio_frontmerge to 3.9.0 kernel + */ +#else DEFINE_EVENT(block_bio, block_bio_backmerge, TP_PROTO(struct request_queue *q, struct bio *bio), @@ -408,6 +423,7 @@ DEFINE_EVENT(block_bio, block_bio_frontmerge, TP_ARGS(q, bio) ) +#endif /** * block_bio_queue - putting new block IO operation in queue -- 1.7.5.4 From mathieu.desnoyers at efficios.com Mon Mar 25 09:33:34 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Mon, 25 Mar 2013 09:33:34 -0400 Subject: [lttng-dev] [PATCH] lttng-module: block.h : Fix build for 3.9 kernel In-Reply-To: <1364214657-35068-1-git-send-email-maxin.john@enea.com> References: <1364214657-35068-1-git-send-email-maxin.john@enea.com> Message-ID: <20130325133334.GA32008@Krystal> * maxin.john at enea.com (maxin.john at enea.com) wrote: > From: "Maxin B. John" > > commit :3a366e614d0837d9fc23f78cdb1a1186ebc3387f > block: add missing block_bio_complete() tracepoint > added block_bio_complete to 3.9 kernel > > commit : 8c1cf6bb02fda79b0a4b9bd121f6be6d4ce7a15a > block: add @req to bio_{front|back}_merge tracepoints > added block_bio_backmerge and block_bio_frontmerge to 3.9 kernel > > Update block.h based on these commits in mainline kernel Disabling the event prior to 3.9.0 does not seem to be the proper solution. We should rather #ifdef the old/new TRACE_EVENT definitions to accept the proper number of arguments for each kernel. Thanks, Mathieu > > Fixes this build failure: > .... > include/trace/events/block.h:353:1: note: previous definition of > 'trace_block_bio_frontmerge' was here > make[3]: *** [/home/majo/kernel/lttng/lttng-modules/probes/ > lttng-probe-block.o] Error 1 > make[2]: *** [/home/majo/kernel/lttng/lttng-modules/probes] Error 2 > make[1]: *** [_module_/home/majo/kernel/lttng/lttng-modules] Error 2 > make: *** [default] Error 2 > > Signed-off-by: Maxin B. John > --- > instrumentation/events/lttng-module/block.h | 16 ++++++++++++++++ > 1 files changed, 16 insertions(+), 0 deletions(-) > > diff --git a/instrumentation/events/lttng-module/block.h b/instrumentation/events/lttng-module/block.h > index d42ebd4..59bd2c0 100644 > --- a/instrumentation/events/lttng-module/block.h > +++ b/instrumentation/events/lttng-module/block.h > @@ -311,6 +311,13 @@ TRACE_EVENT(block_bio_bounce, > * This tracepoint indicates there is no further work to do on this > * block IO operation @bio. > */ > +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) > +/** > + * commit :3a366e614d0837d9fc23f78cdb1a1186ebc3387f > + * block: add missing block_bio_complete() tracepoint > + * added block_bio_complete to 3.9.0 kernel > + */ > +#else > TRACE_EVENT(block_bio_complete, > > #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) > @@ -349,6 +356,7 @@ TRACE_EVENT(block_bio_complete, > (unsigned long long)__entry->sector, > __entry->nr_sector, __entry->error) > ) > +#endif > > DECLARE_EVENT_CLASS(block_bio, > > @@ -387,6 +395,13 @@ DECLARE_EVENT_CLASS(block_bio, > * Merging block request @bio to the end of an existing block request > * in queue @q. > */ > +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) > +/** > + * commit : 8c1cf6bb02fda79b0a4b9bd121f6be6d4ce7a15a > + * block: add @req to bio_{front|back}_merge tracepoints > + * added block_bio_backmerge and block_bio_frontmerge to 3.9.0 kernel > + */ > +#else > DEFINE_EVENT(block_bio, block_bio_backmerge, > > TP_PROTO(struct request_queue *q, struct bio *bio), > @@ -408,6 +423,7 @@ DEFINE_EVENT(block_bio, block_bio_frontmerge, > > TP_ARGS(q, bio) > ) > +#endif > > /** > * block_bio_queue - putting new block IO operation in queue > -- > 1.7.5.4 > -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From Daniel.Thibault at drdc-rddc.gc.ca Mon Mar 25 09:53:26 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Mon, 25 Mar 2013 13:53:26 +0000 Subject: [lttng-dev] [LTTNG-TOOLS PATCH] On-disk multiple tracefiles circular buffer - revisited Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD02944A@VAL-E-01.valcartier.drdc-rddc.gc.ca> Here are proposed semantics for the tracefile-size/tracefile-count enable-channel options (are they still planned for later inclusion in lttng-tools?): -C, --tracefile-size SIZE This is a recent proposal (2013-Mar-08) that has yet to be added to the command. Maximum size of each stored trace file (local or remote). Default is zero, which means no limitation. When set, each trace file is chopped into sequentially numbered segments of at most SIZE bytes each (e.g. "channel0_0" becomes "channel0_0_0", "channel0_0_1", etc.). SIZE must be at least as large as the sub-buffer size. The option is most useful if -W, --tracefile-count is also set. -W, --tracefile-count NUM This is a recent proposal (2013-Mar-08) that has yet to be added to the command. Maximum number of stored trace file chunks (local or remote). Default is zero, which means no limitation. When set, once the number of trace file segments reaches NUM the first segments are re-used (overwritten), creating an on-disc circular buffer of sorts. The option has no effect unless the -C, --tracefile-size option is also set. Note that when -C is set but -W is not (or if -W is set to 1), this means the single trace file gets overwritten after each SIZE bytes. Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC? G3J 1X5 CANADA Vox?: (418) 844-4000 x4245 Fax?: (418) 844-4538 NAC?: 918V QSDJ Gouvernement du Canada?/ Government of Canada From dgoulet at efficios.com Mon Mar 25 10:16:50 2013 From: dgoulet at efficios.com (David Goulet) Date: Mon, 25 Mar 2013 10:16:50 -0400 Subject: [lttng-dev] [PATCH lttng-tools 1/6] Tests: Fix wrong number of tests in test plan of the thread stall test In-Reply-To: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> References: <1363895807-17892-1-git-send-email-christian.babeux@efficios.com> Message-ID: <51505C52.4050300@efficios.com> Merged! Thanks David Christian Babeux: > Signed-off-by: Christian Babeux > --- > tests/regression/tools/health/test_thread_stall | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tests/regression/tools/health/test_thread_stall b/tests/regression/tools/health/test_thread_stall > index 92cfb01..1651c02 100755 > --- a/tests/regression/tools/health/test_thread_stall > +++ b/tests/regression/tools/health/test_thread_stall > @@ -24,7 +24,7 @@ SESSION_NAME="health_thread_stall" > EVENT_NAME="bogus" > HEALTH_CHECK_BIN="health_check" > SESSIOND_PRELOAD=".libs/libhealthstall.so" > -NUM_TESTS=12 > +NUM_TESTS=11 > > source $TESTDIR/utils/utils.sh > From dgoulet at efficios.com Mon Mar 25 10:16:59 2013 From: dgoulet at efficios.com (David Goulet) Date: Mon, 25 Mar 2013 10:16:59 -0400 Subject: [lttng-dev] [PATCH lttng-ust] Add missing buffers-uid folder in ust regression test Makefile In-Reply-To: <1363901187-7955-1-git-send-email-jeremie.galarneau@efficios.com> References: <1363901187-7955-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <51505C5B.6050303@efficios.com> Merged! J?r?mie Galarneau: > > Signed-off-by: J?r?mie Galarneau > --- > tests/regression/ust/Makefile.am | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am > index d8904bb..c5dee21 100644 > --- a/tests/regression/ust/Makefile.am > +++ b/tests/regression/ust/Makefile.am > @@ -1,6 +1,6 @@ > if HAVE_LIBLTTNG_UST_CTL > SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ > - overlap > + overlap buffers-uid > > EXTRA_DIST = runall.sh run-ust-global-tests.sh test_event_basic test_event_wildcard > From maxin.john at enea.com Mon Mar 25 10:22:32 2013 From: maxin.john at enea.com (Maxin B. John) Date: Mon, 25 Mar 2013 15:22:32 +0100 Subject: [lttng-dev] [PATCH] lttng-module: block.h : Fix build for 3.9 kernel In-Reply-To: <20130325133334.GA32008@Krystal> Message-ID: <20130325142232.GA17611@sestofb10.enea.se> On Mon, Mar 25, 2013 at 09:33:34AM -0400, Mathieu Desnoyers wrote: > * maxin.john at enea.com (maxin.john at enea.com) wrote: > > From: "Maxin B. John" > > commit :3a366e614d0837d9fc23f78cdb1a1186ebc3387f > > block: add missing block_bio_complete() tracepoint > > added block_bio_complete to 3.9 kernel > > commit : 8c1cf6bb02fda79b0a4b9bd121f6be6d4ce7a15a > > block: add @req to bio_{front|back}_merge tracepoints > > added block_bio_backmerge and block_bio_frontmerge to 3.9 kernel > > Update block.h based on these commits in mainline kernel > Disabling the event prior to 3.9.0 does not seem to be the proper > solution. We should rather #ifdef the old/new TRACE_EVENT definitions to > accept the proper number of arguments for each kernel. Thank you very much for the review comments.I will update it accordingly. > Thanks, > Mathieu Best Regards, Maxin From dgoulet at efficios.com Mon Mar 25 10:30:18 2013 From: dgoulet at efficios.com (David Goulet) Date: Mon, 25 Mar 2013 10:30:18 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <2423f47f2d19009bcfe5af3cbe0c3350deb68fdf.1363903997.git.raphael.beamonte@gmail.com> References: <514B44ED.3000702@efficios.com> <2423f47f2d19009bcfe5af3cbe0c3350deb68fdf.1363903997.git.raphael.beamonte@gmail.com> Message-ID: <51505F7A.7060108@efficios.com> Hi, Two things. First, the version.h.tmpl has to be added to EXTRA_DIST in include/Makefile.am Second thing, on line 86 of lttng.c, *never* *never* *never* pass a variable to printf without a format. fprintf(ofp, lttng_version); This is a huge vector attack to format strings. Furthermore, outside of the git tree, there is a warning: lttng.c:86:2: warning: zero-length gnu_printf format string [-Wformat-zero-length] Thanks! David Rapha?l Beamonte: > Signed-off-by: Rapha?l Beamonte > --- > .gitignore | 2 ++ > Makefile.am | 4 +-- > include/Makefile.am | 45 ++++++++++++++++++++++++++++++- > include/version.h.tmpl | 27 +++++++++++++++++++ > src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++ > src/bin/lttng-sessiond/main.c | 2 +- > src/bin/lttng/commands/version.c | 4 ++- > src/bin/lttng/lttng.c | 5 +++- > src/bin/lttng/utils.h | 13 +++++++++ > 9 files changed, 110 insertions(+), 6 deletions(-) > create mode 100644 include/version.h.tmpl > > diff --git a/.gitignore b/.gitignore > index ac72bf4..a36f0b9 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -31,6 +31,8 @@ config/ > !config/epoll.m4 > !config/config_feature.m4 > > +include/version.h > + > src/bin/lttng-sessiond/lttng-sessiond > src/bin/lttng/lttng > src/bin/lttng-consumerd/lttng-consumerd > diff --git a/Makefile.am b/Makefile.am > index b0537ce..03fdabc 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -1,9 +1,9 @@ > ACLOCAL_AMFLAGS = -I config > > -SUBDIRS = src \ > +SUBDIRS = include \ > + src \ > tests \ > extras \ > - include \ > doc > > dist_doc_DATA = LICENSE \ > diff --git a/include/Makefile.am b/include/Makefile.am > index 0bcb6f9..fce6276 100644 > --- a/include/Makefile.am > +++ b/include/Makefile.am > @@ -1 +1,44 @@ > -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h > +## The version.h file must be verified and generated or updated if the > +## git commit id (called git version here) changed since the last build > +## of lttng-tools. > +version.h: version.h.tmpl > + ## We first create variables for the current git version and > + ## the locations of the version.h and version.h.tmpl files > + (git_version="$$(git describe --long --all 2>/dev/null)"; \ > + version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \ > + version_h="$(top_builddir)/include/version.h"; \ > + ## If the version.h file doesn't exist or is not up to date, > + ## We replace it by the version.h.tmpl file > + if [ ! -e "$${version_h}" ] || \ > + [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \ > + cp "$${version_h_tmpl}" "$${version_h}"; \ > + fi; \ > + if [ -z "$${git_version}" ]; then \ > + ## If we don't have a git version, we verify that there is > + ## not any define of GIT_VERSION in the version.h file, or > + ## we remove it. > + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ > + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \ > + fi; \ > + else \ > + ## If we have a git version, we verify that it isn't the same > + ## as the one currently in the file (if there is one), as we > + ## don't want to update the file if it is already up to date > + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ > + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ > + ## If there is already a GIT_VERSION defined, > + ## we just replace it by the new version > + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ > + else \ > + ## Else, we add a GIT_VERSION define > + ## containing our new version. > + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ > + fi; \ > + fi; \ > + fi) > + > +## version.h is defined as a .PHONY file even if it's a real file as > +## we want our routine to be runned for each build. > +.PHONY: version.h > + > +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h version.h > diff --git a/include/version.h.tmpl b/include/version.h.tmpl > new file mode 100644 > index 0000000..c42789c > --- /dev/null > +++ b/include/version.h.tmpl > @@ -0,0 +1,27 @@ > +/* > + * version.h > + * > + * Linux Trace Toolkit version header file > + * > + * Copyright (C) 2013 - Rapha?l Beamonte > + * > + * This library is free software; you can redistribute it and/or modify it > + * under the terms of the GNU Lesser General Public License, version 2.1 only, > + * as published by the Free Software Foundation. > + * > + * This library is distributed in the hope that it will be useful, but WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License > + * for more details. > + * > + * You should have received a copy of the GNU Lesser General Public License > + * along with this library; if not, write to the Free Software Foundation, > + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#ifndef VERSION_H > +#define VERSION_H > + > +#define GIT_VERSION > + > +#endif /* VERSION_H */ > diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h > index 9258f38..e91918a 100644 > --- a/src/bin/lttng-sessiond/lttng-sessiond.h > +++ b/src/bin/lttng-sessiond/lttng-sessiond.h > @@ -1,5 +1,6 @@ > /* > * Copyright (C) 2011 - David Goulet > + * Copyright (C) 2013 - Rapha?l Beamonte > * > * This program is free software; you can redistribute it and/or modify > * it under the terms of the GNU General Public License, version 2 only, > @@ -28,6 +29,8 @@ > > #include "session.h" > #include "ust-app.h" > +#include "version.h" > + > > extern const char default_home_dir[], > default_tracing_group[], > @@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2]; > int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size); > int sessiond_check_thread_quit_pipe(int fd, uint32_t events); > > +/* > + * This static const char allows to return the version number depending > + * whether or not the GIT_VERSION value is available > + */ > +#ifdef GIT_VERSION > +static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")"; > +#else /* GIT_VERSION */ > +static const char lttng_sessiond_version[] = VERSION; > +#endif /* GIT_VERSION */ > + > + > #endif /* _LTT_SESSIOND_H */ > diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c > index d88bafe..41701e9 100644 > --- a/src/bin/lttng-sessiond/main.c > +++ b/src/bin/lttng-sessiond/main.c > @@ -3555,7 +3555,7 @@ static int parse_args(int argc, char **argv) > usage(); > exit(EXIT_FAILURE); > case 'V': > - fprintf(stdout, "%s\n", VERSION); > + fprintf(stdout, "%s\n", lttng_sessiond_version); > exit(EXIT_SUCCESS); > case 'S': > opt_sig_parent = 1; > diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c > index 7f69de3..2170d00 100644 > --- a/src/bin/lttng/commands/version.c > +++ b/src/bin/lttng/commands/version.c > @@ -26,6 +26,7 @@ > #include > > #include "../command.h" > +#include "../utils.h" > > enum { > OPT_HELP = 1, > @@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv) > } > > MSG("lttng version " VERSION " - " VERSION_NAME); > - MSG("\n" VERSION_DESCRIPTION "\n"); > + MSG("%s", lttng_version); > + MSG(VERSION_DESCRIPTION "\n"); > MSG("Web site: http://lttng.org"); > MSG("\nlttng is free software and under the GPL license and part LGPL"); > > diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c > index d3aaa84..4289901 100644 > --- a/src/bin/lttng/lttng.c > +++ b/src/bin/lttng/lttng.c > @@ -31,6 +31,7 @@ > #include > > #include "command.h" > +#include "utils.h" > > /* Variables */ > static char *progname; > @@ -81,7 +82,9 @@ static struct cmd_struct commands[] = { > > static void usage(FILE *ofp) > { > - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); > + fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n"); > + fprintf(ofp, lttng_version); > + fprintf(ofp, "\n"); > fprintf(ofp, "usage: lttng [OPTIONS] []\n"); > fprintf(ofp, "\n"); > fprintf(ofp, "Options:\n"); > diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h > index 9f7bfcc..12ee7c0 100644 > --- a/src/bin/lttng/utils.h > +++ b/src/bin/lttng/utils.h > @@ -1,5 +1,6 @@ > /* > * Copyright (C) 2011 - David Goulet > + * Copyright (C) 2013 - Rapha?l Beamonte > * > * This program is free software; you can redistribute it and/or modify > * it under the terms of the GNU General Public License, version 2 only, > @@ -19,8 +20,20 @@ > #define _LTTNG_UTILS_H > > #include > +#include > > char *get_session_name(void); > void list_cmd_options(FILE *ofp, struct poptOption *options); > > +/* > + * This static const char allows to return the version number depending > + * whether or not the GIT_VERSION value is available > + */ > +#ifdef GIT_VERSION > +static const char lttng_version[] = "Git version: " GIT_VERSION "\n"; > +#else /* GIT_VERSION */ > +static const char lttng_version[] = ""; > +#endif /* GIT_VERSION */ > + > + > #endif /* _LTTNG_UTILS_H */ From dgoulet at efficios.com Mon Mar 25 10:32:18 2013 From: dgoulet at efficios.com (David Goulet) Date: Mon, 25 Mar 2013 10:32:18 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Add optional Perl dependency requirement to README In-Reply-To: <1363981759-4718-1-git-send-email-christian.babeux@efficios.com> References: <1363981759-4718-1-git-send-email-christian.babeux@efficios.com> Message-ID: <51505FF2.7030008@efficios.com> Merged! Thanks Christian Babeux: > Signed-off-by: Christian Babeux > --- > README | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/README b/README > index 4ef88cb..cfbf1ac 100644 > --- a/README > +++ b/README > @@ -28,6 +28,9 @@ REQUIREMENTS: > > * Debian/Ubuntu package: libpopt-dev > > + - Perl (optional) > + Needed for make check and tests. > + > - SWIG >= 2.0 (optional) > Needed for Python bindings (--enable-python-bindings). > From raphael.beamonte at gmail.com Mon Mar 25 11:50:21 2013 From: raphael.beamonte at gmail.com (=?UTF-8?q?Rapha=C3=ABl=20Beamonte?=) Date: Mon, 25 Mar 2013 11:50:21 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <51505F7A.7060108@efficios.com> References: <51505F7A.7060108@efficios.com> Message-ID: <0ab8866c5deb744279d9150823d24203a51851b1.1364226619.git.raphael.beamonte@gmail.com> Signed-off-by: Rapha?l Beamonte --- .gitignore | 2 ++ Makefile.am | 4 +-- include/Makefile.am | 46 +++++++++++++++++++++++++++++++ include/version.h.tmpl | 27 ++++++++++++++++++ src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++ src/bin/lttng-sessiond/main.c | 2 +- src/bin/lttng/commands/version.c | 4 ++- src/bin/lttng/lttng.c | 5 +++- src/bin/lttng/utils.h | 13 +++++++++ 9 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 include/version.h.tmpl diff --git a/.gitignore b/.gitignore index ee58252..0385627 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,8 @@ config/ !config/epoll.m4 !config/config_feature.m4 +include/version.h + src/bin/lttng-sessiond/lttng-sessiond src/bin/lttng/lttng src/bin/lttng-consumerd/lttng-consumerd diff --git a/Makefile.am b/Makefile.am index b0537ce..03fdabc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,9 @@ ACLOCAL_AMFLAGS = -I config -SUBDIRS = src \ +SUBDIRS = include \ + src \ tests \ extras \ - include \ doc dist_doc_DATA = LICENSE \ diff --git a/include/Makefile.am b/include/Makefile.am index 0bcb6f9..850950f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1 +1,47 @@ +## The version.h file must be verified and generated or updated if the +## git commit id (called git version here) changed since the last build +## of lttng-tools. +version.h: version.h.tmpl + ## We first create variables for the current git version and + ## the locations of the version.h and version.h.tmpl files + (git_version="$$(git describe --long --all 2>/dev/null)"; \ + version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \ + version_h="$(top_builddir)/include/version.h"; \ + ## If the version.h file doesn't exist or is not up to date, + ## We replace it by the version.h.tmpl file + if [ ! -e "$${version_h}" ] || \ + [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \ + cp "$${version_h_tmpl}" "$${version_h}"; \ + fi; \ + if [ -z "$${git_version}" ]; then \ + ## If we don't have a git version, we verify that there is + ## not any define of GIT_VERSION in the version.h file, or + ## we remove it. + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \ + fi; \ + else \ + ## If we have a git version, we verify that it isn't the same + ## as the one currently in the file (if there is one), as we + ## don't want to update the file if it is already up to date + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \ + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \ + ## If there is already a GIT_VERSION defined, + ## we just replace it by the new version + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + else \ + ## Else, we add a GIT_VERSION define + ## containing our new version. + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \ + fi; \ + fi; \ + fi) + +## version.h is defined as a .PHONY file even if it's a real file as +## we want our routine to be runned for each build. +.PHONY: version.h + lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h +nodist_lttnginclude_HEADERS = version.h + +EXTRA_DIST = version.h.tmpl diff --git a/include/version.h.tmpl b/include/version.h.tmpl new file mode 100644 index 0000000..c42789c --- /dev/null +++ b/include/version.h.tmpl @@ -0,0 +1,27 @@ +/* + * version.h + * + * Linux Trace Toolkit version header file + * + * Copyright (C) 2013 - Rapha?l Beamonte + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef VERSION_H +#define VERSION_H + +#define GIT_VERSION + +#endif /* VERSION_H */ diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h index 9258f38..e91918a 100644 --- a/src/bin/lttng-sessiond/lttng-sessiond.h +++ b/src/bin/lttng-sessiond/lttng-sessiond.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - David Goulet + * Copyright (C) 2013 - Rapha?l Beamonte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only, @@ -28,6 +29,8 @@ #include "session.h" #include "ust-app.h" +#include "version.h" + extern const char default_home_dir[], default_tracing_group[], @@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2]; int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size); int sessiond_check_thread_quit_pipe(int fd, uint32_t events); +/* + * This static const char allows to return the version number depending + * whether or not the GIT_VERSION value is available + */ +#ifdef GIT_VERSION +static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")"; +#else /* GIT_VERSION */ +static const char lttng_sessiond_version[] = VERSION; +#endif /* GIT_VERSION */ + + #endif /* _LTT_SESSIOND_H */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index d88bafe..41701e9 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3555,7 +3555,7 @@ static int parse_args(int argc, char **argv) usage(); exit(EXIT_FAILURE); case 'V': - fprintf(stdout, "%s\n", VERSION); + fprintf(stdout, "%s\n", lttng_sessiond_version); exit(EXIT_SUCCESS); case 'S': opt_sig_parent = 1; diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c index 7f69de3..2170d00 100644 --- a/src/bin/lttng/commands/version.c +++ b/src/bin/lttng/commands/version.c @@ -26,6 +26,7 @@ #include #include "../command.h" +#include "../utils.h" enum { OPT_HELP = 1, @@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv) } MSG("lttng version " VERSION " - " VERSION_NAME); - MSG("\n" VERSION_DESCRIPTION "\n"); + MSG("%s", lttng_version); + MSG(VERSION_DESCRIPTION "\n"); MSG("Web site: http://lttng.org"); MSG("\nlttng is free software and under the GPL license and part LGPL"); diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index d3aaa84..c8a9c71 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -31,6 +31,7 @@ #include #include "command.h" +#include "utils.h" /* Variables */ static char *progname; @@ -81,7 +82,9 @@ static struct cmd_struct commands[] = { static void usage(FILE *ofp) { - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n"); + fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n"); + fprintf(ofp, "%s", lttng_version); + fprintf(ofp, "\n"); fprintf(ofp, "usage: lttng [OPTIONS] []\n"); fprintf(ofp, "\n"); fprintf(ofp, "Options:\n"); diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h index 9f7bfcc..12ee7c0 100644 --- a/src/bin/lttng/utils.h +++ b/src/bin/lttng/utils.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - David Goulet + * Copyright (C) 2013 - Rapha?l Beamonte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only, @@ -19,8 +20,20 @@ #define _LTTNG_UTILS_H #include +#include char *get_session_name(void); void list_cmd_options(FILE *ofp, struct poptOption *options); +/* + * This static const char allows to return the version number depending + * whether or not the GIT_VERSION value is available + */ +#ifdef GIT_VERSION +static const char lttng_version[] = "Git version: " GIT_VERSION "\n"; +#else /* GIT_VERSION */ +static const char lttng_version[] = ""; +#endif /* GIT_VERSION */ + + #endif /* _LTTNG_UTILS_H */ -- 1.7.10.4 From raphael.beamonte at gmail.com Mon Mar 25 11:55:42 2013 From: raphael.beamonte at gmail.com (=?UTF-8?B?UmFwaGHDq2wgQmVhbW9udGU=?=) Date: Mon, 25 Mar 2013 11:55:42 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources In-Reply-To: <0ab8866c5deb744279d9150823d24203a51851b1.1364226619.git.raphael.beamonte@gmail.com> References: <51505F7A.7060108@efficios.com> <0ab8866c5deb744279d9150823d24203a51851b1.1364226619.git.raphael.beamonte@gmail.com> Message-ID: <5150737E.6000300@gmail.com> On 2013-03-25 10:30, David Goulet wrote:> Hi, > > Two things. First, the version.h.tmpl has to be added to EXTRA_DIST in > include/Makefile.am Done. And changed the "version.h" to "nodist_*_headers". > Second thing, on line 86 of lttng.c, *never* *never* *never* pass a > variable to printf without a format. > > fprintf(ofp, lttng_version); > > This is a huge vector attack to format strings. Furthermore, outside of > the git tree, there is a warning: > > lttng.c:86:2: warning: zero-length gnu_printf format string > [-Wformat-zero-length] My mistake, forgot to correct that... It's ok in the new patch. Rapha?l -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: From mathieu.desnoyers at efficios.com Mon Mar 25 14:40:45 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Mon, 25 Mar 2013 14:40:45 -0400 Subject: [lttng-dev] [RELEASE] LTTng-UST 2.1.2 Message-ID: <20130325184045.GA26037@Krystal> LTTng-UST, the Linux Trace Toolkit Next Generation Userspace Tracer, is port of the low-overhead tracing capabilities of the LTTng kernel tracer to user-space. The library "liblttng-ust" enables tracing of applications and libraries. Changelog: 2013-03-25 lttng-ust 2.1.2 * Fix uninitialized has_loglevel variable * tracepoint: Don't add NULL probes * Remove mention of locking issues associated with dlopen usage * Fix: refcount issue in lttng-ust-abi.c * Fix: don't flush-final for offset 0 if reader is on sub-buffer * Use tp rcu link test in provider * Remove direct dependency of probes on urcu-bp * Fix package: don't distribute generated headers * Fix: don't cancel already exited threads * Scalability fix: tracepoint.c hash table size increase * Scalability fix for many events: event hash table size * Speed up probe registration for large amount of events * Add missing demo-trace shell script to dist tarball * Fix: missing test for lttng_ust_comm_should_quit in * lttng-ust-comm.c * Documentation: clarify debian package name for uuid in README * Document dependency on libuuid * Fix: comment in ust-ctl.h * Fix I/O-related error values in ustctl Project website: http://lttng.org Download link: http://lttng.org/download (please refer to the README file for installation instructions) -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From jeremie.galarneau at efficios.com Mon Mar 25 20:26:07 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Mon, 25 Mar 2013 20:26:07 -0400 Subject: [lttng-dev] Pull request: lttng-ust tests clean-up Message-ID: Hi all, I'd like to propose a set of patches to clean-up the lttng-ust tests. Since the clean-up now weighs in at a fairly hefty 21 patches, I think a link to my personal repository might be more appropriate than posting the patch-set on this list. The relevant commits are 8ae5122...0060eb2 I will also be posting a set of patches that fixes and moves some of the lttng-ust tests to lttng-tools since they depend on it. Git access: git://github.com/jgalar/lttng-ust-tests-cleanup.git -b test-cleanup Web interface: https://github.com/jgalar/lttng-ust-tests-cleanup Comments are welcome, as always! Regards, J?r?mie -- J?r?mie Galarneau EfficiOS Inc. http://www.efficios.com From jeremie.galarneau at efficios.com Mon Mar 25 20:28:30 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Mon, 25 Mar 2013 20:28:30 -0400 Subject: [lttng-dev] [PATCH lttng-tools 1/7] Tests: Add Python test_utils module Message-ID: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> Basic Python test framework based on the lttng-tools Python bindings that facilitates the creation of a tracing session saving its trace in a temporary location, the activation of events in the UST domain and clean teardown of the test session. Also provides basic TAP output facilities. Signed-off-by: J?r?mie Galarneau --- tests/utils/test_utils.py | 111 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 tests/utils/test_utils.py diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py new file mode 100644 index 0000000..5e00de4 --- /dev/null +++ b/tests/utils/test_utils.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python3 +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import uuid +import os +import subprocess +import shutil +import sys +import tempfile + +# Import lttng bindings generated in the current tree +lttng_bindings_path = os.path.dirname(os.path.abspath(__file__)) + "/" +for i in range(3): + lttng_bindings_path = os.path.dirname(lttng_bindings_path) +lttng_bindings_path = lttng_bindings_path + "/extras/bindings/swig/python" +lttng_bindings_libs_path = lttng_bindings_path + "/.libs" +sys.path.append(lttng_bindings_path) +sys.path.append(lttng_bindings_libs_path) +from lttng import * + + +class SessionInfo: + def __init__(self, handle, session_name, tmp_directory, channel_name): + self.handle = handle + self.name = session_name + self.tmp_directory = tmp_directory + self.trace_path = tmp_directory + "/" + session_name + self.channel_name = channel_name + +def bail(diag, session_info = None): + print("Bail out!") + print("#", diag) + + if session_info is not None: + stop_session(session_info, True) + + if os.path.exists(session_info.trace_path): + shutil.rmtree(session_info.trace_path) + exit(-1) + +def print_test_result(result, number, description): + result_string = None + if result is True: + result_string = "ok" + else: + result_string = "not ok" + + result_string += " {0} - {1}".format(number, description) + print(result_string) + +def enable_ust_tracepoint_event(session_info, event_name): + event = Event() + event.name = event_name + event.type = EVENT_TRACEPOINT + event.loglevel = EVENT_LOGLEVEL_ALL + res = enable_event(session_info.handle, event, session_info.channel_name) + if res < 0: + bail("Failed to enable userspace event " + event_name, session_info) + +def create_session(): + dom = Domain() + dom.type = DOMAIN_UST + + session_name = str(uuid.uuid1()) + tmp_directory = tempfile.mkdtemp() + trace_path = tmp_directory + "/" + session_name + + res = create(session_name, trace_path) + if res < 0: + bail("Failed to create tracing session.") + + channel = Channel() + channel.name = "channel0" + channel_set_default_attr(dom, channel.attr) + + han = Handle(session_name, dom) + res = enable_channel(han, channel) + + session_info = SessionInfo(han, session_name, tmp_directory, channel.name) + if res < 0: + bail("Failed to enable channel " + channel.name, session_info) + return session_info + +def start_session(session_info): + start(session_info.name) + +def stop_session(session_info, bailing = False): + # Workaround lttng-ctl outputing directly to stdout by spawning a subprocess. + lttng_binary_path = os.path.dirname(os.path.abspath(__file__)) + "/" + for i in range(3): + lttng_binary_path = os.path.dirname(lttng_binary_path) + lttng_binary_path = lttng_binary_path + "/src/bin/lttng/lttng" + + retcode = subprocess.call([lttng_binary_path, "stop", session_info.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if retcode != 0 and not bailing: + bail("Unable to stop session " + session_info.name, session_info) + destroy(session_info.name) -- 1.8.2 From jeremie.galarneau at efficios.com Mon Mar 25 20:28:31 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Mon, 25 Mar 2013 20:28:31 -0400 Subject: [lttng-dev] [PATCH lttng-tools 2/7] Tests: Add "linking" ust regression test In-Reply-To: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <1364257716-5739-2-git-send-email-jeremie.galarneau@efficios.com> Based on the "demo" test formerly part of lttng-ust. Tests userspace tracing with directly, statically and dynamically linked providers. Also meant as an exemple of building and tracing an application with all types of provider linking. Signed-off-by: J?r?mie Galarneau --- .gitignore | 3 + configure.ac | 1 + tests/fast_regression | 1 + tests/long_regression | 1 + tests/regression/ust/Makefile.am | 2 +- tests/regression/ust/linking/Makefile.am | 85 +++++++++++ tests/regression/ust/linking/README | 29 ++++ tests/regression/ust/linking/demo.c | 69 +++++++++ tests/regression/ust/linking/demo_preload | 4 + tests/regression/ust/linking/test_linking | 35 +++++ tests/regression/ust/linking/test_linking.py | 199 +++++++++++++++++++++++++ tests/regression/ust/linking/tp.c | 26 ++++ tests/regression/ust/linking/tp2.c | 26 ++++ tests/regression/ust/linking/tp3.c | 26 ++++ tests/regression/ust/linking/ust_tests_demo.h | 61 ++++++++ tests/regression/ust/linking/ust_tests_demo2.h | 68 +++++++++ tests/regression/ust/linking/ust_tests_demo3.h | 53 +++++++ 17 files changed, 688 insertions(+), 1 deletion(-) create mode 100644 tests/regression/ust/linking/Makefile.am create mode 100644 tests/regression/ust/linking/README create mode 100644 tests/regression/ust/linking/demo.c create mode 100755 tests/regression/ust/linking/demo_preload create mode 100755 tests/regression/ust/linking/test_linking create mode 100644 tests/regression/ust/linking/test_linking.py create mode 100644 tests/regression/ust/linking/tp.c create mode 100644 tests/regression/ust/linking/tp2.c create mode 100644 tests/regression/ust/linking/tp3.c create mode 100644 tests/regression/ust/linking/ust_tests_demo.h create mode 100644 tests/regression/ust/linking/ust_tests_demo2.h create mode 100644 tests/regression/ust/linking/ust_tests_demo3.h diff --git a/.gitignore b/.gitignore index ee58252..b9c3ec8 100644 --- a/.gitignore +++ b/.gitignore @@ -64,5 +64,8 @@ gen-events gen-ust-events health_check tests/regression/ust/overlap/demo/demo +tests/regression/ust/linking/demo_builtin +tests/regression/ust/linking/demo_static +tests/regression/ust/linking/demo benchmark/ diff --git a/configure.ac b/configure.ac index 9f120f2..5494cd8 100644 --- a/configure.ac +++ b/configure.ac @@ -332,6 +332,7 @@ AC_CONFIG_FILES([ tests/regression/ust/multi-session/Makefile tests/regression/ust/overlap/Makefile tests/regression/ust/overlap/demo/Makefile + tests/regression/ust/linking/Makefile tests/unit/Makefile tests/utils/Makefile tests/utils/tap/Makefile diff --git a/tests/fast_regression b/tests/fast_regression index fb4ac60..b700fa5 100644 --- a/tests/fast_regression +++ b/tests/fast_regression @@ -12,3 +12,4 @@ regression/ust/nprocesses/test_nprocesses regression/ust/overlap/test_overlap regression/ust/test_event_basic regression/ust/test_event_wildcard +regression/ust/linking/test_linking diff --git a/tests/long_regression b/tests/long_regression index c198178..1fb68c3 100644 --- a/tests/long_regression +++ b/tests/long_regression @@ -14,3 +14,4 @@ regression/ust/nprocesses/test_nprocesses regression/ust/overlap/test_overlap regression/ust/test_event_basic regression/ust/test_event_wildcard +regression/ust/linking/test_linking diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am index 78a5aab..74db00b 100644 --- a/tests/regression/ust/Makefile.am +++ b/tests/regression/ust/Makefile.am @@ -1,6 +1,6 @@ if HAVE_LIBLTTNG_UST_CTL SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ - overlap buffers-uid + overlap buffers-uid linking EXTRA_DIST = test_event_basic test_event_wildcard diff --git a/tests/regression/ust/linking/Makefile.am b/tests/regression/ust/linking/Makefile.am new file mode 100644 index 0000000..d2c4eca --- /dev/null +++ b/tests/regression/ust/linking/Makefile.am @@ -0,0 +1,85 @@ +# -Wsystem-headers is needed to print warnings in the tracepoint +# description file. +AM_CPPFLAGS = -I$(srcdir) -I$(top_builddir)/include -Wsystem-headers + +# Set LIBS to nothing so the application does not link on useless +# libraries. +LIBS = + +# Build a version of the test app with built-in tracepoints +demo_builtin_SOURCES = demo.c tp.c tp2.c tp3.c ust_tests_demo.h \ + ust_tests_demo2.h ust_tests_demo3.h +demo_builtin_LDADD = -llttng-ust +demo_builtin_CFLAGS = -Werror=old-style-definition + +# Build a version statically linked to the providers +# contains ust_tests_demo.h and ust_tests_demo2.h provider probes +noinst_LTLIBRARIES = liblttng-ust-provider-ust-tests-demo-static.la \ + liblttng-ust-provider-ust-tests-demo3-static.la + +liblttng_ust_provider_ust_tests_demo_static_la_SOURCES = \ + tp.c ust_tests_demo.h \ + tp2.c ust_tests_demo2.h +liblttng_ust_provider_ust_tests_demo_static_la_LIBADD = \ + -llttng-ust + +# contains ust_tests_demo3.h provider probes +liblttng_ust_provider_ust_tests_demo3_static_la_SOURCES = \ + tp3.c ust_tests_demo3.h +liblttng_ust_provider_ust_tests_demo3_static_la_LIBADD = \ + -llttng-ust + +demo_static_SOURCES = demo.c +demo_static_LDADD = liblttng-ust-provider-ust-tests-demo-static.la \ + liblttng-ust-provider-ust-tests-demo3-static.la + +if LTTNG_TOOLS_BUILD_WITH_LIBDL +demo_builtin_LDADD += -ldl +demo_static_LDADD += -ldl +endif +if LTTNG_TOOLS_BUILD_WITH_LIBC_DL +demo_builtin_LDADD += -lc +demo_static_LDADD += -lc +endif + +noinst_PROGRAMS = demo_builtin demo_static + +if !NO_SHARED +# Force the shared flag on the noinst libraries since they are +# only built static by default +FORCE_SHARED_LIB_OPTIONS = -module -shared -avoid-version \ + -rpath $(abs_builddir) + +noinst_LTLIBRARIES += liblttng-ust-provider-ust-tests-demo.la \ + liblttng-ust-provider-ust-tests-demo3.la + +#contains ust_tests_demo.h and ust_tests_demo2.h provider probes +liblttng_ust_provider_ust_tests_demo_la_SOURCES = \ + tp.c ust_tests_demo.h \ + tp2.c ust_tests_demo2.h +liblttng_ust_provider_ust_tests_demo_la_LIBADD = -llttng-ust +liblttng_ust_provider_ust_tests_demo_la_LDFLAGS = \ + $(FORCE_SHARED_LIB_OPTIONS) + +#contains ust_tests_demo3.h provider probes +liblttng_ust_provider_ust_tests_demo3_la_SOURCES = \ + tp3.c ust_tests_demo3.h +liblttng_ust_provider_ust_tests_demo3_la_LIBADD = -llttng-ust +liblttng_ust_provider_ust_tests_demo3_la_LDFLAGS = \ + $(FORCE_SHARED_LIB_OPTIONS) + +noinst_PROGRAMS += demo +demo_SOURCES = demo.c ust_tests_demo.h +demo_CFLAGS = -DTEST_DYNAMIC_LINKAGE + +if LTTNG_TOOLS_BUILD_WITH_LIBDL +demo_LDADD = -ldl +endif +if LTTNG_TOOLS_BUILD_WITH_LIBC_DL +demo_LDADD = -lc +endif + +endif + +noinst_SCRIPTS = test_linking test_linking.py demo_preload +EXTRA_DIST = test_linking test_linking.py demo_preload diff --git a/tests/regression/ust/linking/README b/tests/regression/ust/linking/README new file mode 100644 index 0000000..bbf3a4d --- /dev/null +++ b/tests/regression/ust/linking/README @@ -0,0 +1,29 @@ +UST linking test +---------------- + +Tests userspace tracing with directly, statically and dynamically linked +providers. + +DESCRIPTION +----------- + +This test checks that tracepoints can be enabled by using LD_PRELOAD inside a +launcher script. The test application is also compiled with tracepoint +providers linked directly and statically. The same test suite is executed +for every version of the binary. + +The resulting trace is verified to make sure it is valid and contains the +expected valuess. This test also verifies that the execution of the demo test +without LD_PRELOAD has not produced any logged events. + +Also serves as an example of building and tracing an application with all types +of provider linking. + +DEPENDENCIES +------------ + +To run this test, you will need: + + - lttng-tools + - babeltrace + - python 3.0 or better diff --git a/tests/regression/ust/linking/demo.c b/tests/regression/ust/linking/demo.c new file mode 100644 index 0000000..a02ee80 --- /dev/null +++ b/tests/regression/ust/linking/demo.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Pierre-Marc Fournier + * Copyright (C) 2011 Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 of + * the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TRACEPOINT_DEFINE + +#if TEST_DYNAMIC_LINKAGE +#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE +#endif + +#include "ust_tests_demo.h" +#include "ust_tests_demo2.h" +#include "ust_tests_demo3.h" + +int main(int argc, char **argv) +{ + int i, netint; + long values[] = { 1, 2, 3 }; + char text[10] = "test"; + double dbl = 2.0; + float flt = 2222.0; + int delay = 0; + + if (argc == 2) + delay = atoi(argv[1]); + + fprintf(stderr, "Demo program starting.\n"); + + sleep(delay); + + fprintf(stderr, "Tracing... "); + tracepoint(ust_tests_demo, starting, 123); + for (i = 0; i < 5; i++) { + netint = htonl(i); + tracepoint(ust_tests_demo2, loop, i, netint, values, + text, strlen(text), dbl, flt); + } + tracepoint(ust_tests_demo, done, 456); + tracepoint(ust_tests_demo3, done, 42); + fprintf(stderr, " done.\n"); + return 0; +} diff --git a/tests/regression/ust/linking/demo_preload b/tests/regression/ust/linking/demo_preload new file mode 100755 index 0000000..1f68a68 --- /dev/null +++ b/tests/regression/ust/linking/demo_preload @@ -0,0 +1,4 @@ +#!/bin/sh + +CURDIR=$(dirname $0) +LD_PRELOAD=${CURDIR}/.libs/liblttng-ust-provider-ust-tests-demo.so:${CURDIR}/.libs/liblttng-ust-provider-ust-tests-demo3.so ${CURDIR}/./demo ${*} diff --git a/tests/regression/ust/linking/test_linking b/tests/regression/ust/linking/test_linking new file mode 100755 index 0000000..77e0b82 --- /dev/null +++ b/tests/regression/ust/linking/test_linking @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Check for a running sessiond +`pidof lt-lttng-sessiond` +STOP_SESSIOND=$? + +CURDIR=$(dirname $0) +TESTDIR=${CURDIR}/../../.. + +# Try to launch a sessiond before invoking the python test script +if [ $STOP_SESSIOND -ne 0 ]; then + DIR=$(readlink -f ${TESTDIR}) + ${DIR}/../src/bin/lttng-sessiond/lttng-sessiond --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" +fi + +python3 ${CURDIR}/test_linking.py + +if [ $STOP_SESSIOND -ne 0 ]; then + kill `pidof lt-lttng-sessiond` +fi diff --git a/tests/regression/ust/linking/test_linking.py b/tests/regression/ust/linking/test_linking.py new file mode 100644 index 0000000..9591312 --- /dev/null +++ b/tests/regression/ust/linking/test_linking.py @@ -0,0 +1,199 @@ +#!/usr/bin/env python3 +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import os +import subprocess +import re +import shutil +import sys + +test_path = os.path.dirname(os.path.abspath(__file__)) + "/" +test_utils_path = test_path +for i in range(4): + test_utils_path = os.path.dirname(test_utils_path) +test_utils_path = test_utils_path + "/utils" +sys.path.append(test_utils_path) +from test_utils import * + + +def check_ust_test_demo2_event(event_line, expected_int_field_value): + match = re.search(r".*ust_tests_demo2:loop.*", event_line) + if match is None: + return False + match = re.search(r".*intfield = (\d+)", event_line) + if match is None or int(match.group(1)) != expected_int_field_value: + return False + match = re.search(r".*longfield = (\d+)", event_line) + if match is None or int(match.group(1)) != expected_int_field_value: + return False + match = re.search(r".*netintfield = (\d+)", event_line) + if match is None or int(match.group(1)) != expected_int_field_value: + return False + match = re.search(r".*intfield2 = 0x(\d+)", event_line) + if match is None or int(match.group(1)) != expected_int_field_value: + return False + match = re.search(r".*netintfieldhex = 0x(\d+)", event_line) + if match is None or int(match.group(1)) != expected_int_field_value: + return False + match = re.search(r".*floatfield = (\d+)", event_line) + if match is None or int(match.group(1)) != 2222: + return False + match = re.search(r".*doublefield = (\d+)", event_line) + if match is None or int(match.group(1)) != 2: + return False + match = re.search(r".*_seqfield1_length = (\d+)", event_line) + if match is None or int(match.group(1)) != 4: + return False + match = re.search(r".*seqfield1 = \[ \[0\] = (\d+), \[1\] = (\d+), \[2\] = (\d+), \[3\] = (\d+) \]", event_line) + if match is None or int(match.group(1)) != 116 or int(match.group(2)) != 101 or int(match.group(3)) != 115 or int(match.group(4)) != 116: + return False + match = re.search(r".*arrfield1 = \[ \[0\] = (\d), \[1\] = (\d), \[2\] = (\d) \]", event_line) + if match is None or int(match.group(1)) != 1 or int(match.group(2)) != 2 or int(match.group(3)) != 3: + return False + match = re.search(r".*arrfield2 = \"([a-z]*)\"", event_line) + if match is None or match.group(1) != "test": + return False + match = re.search(r".*_seqfield2_length = (\d+)", event_line) + if match is None or int(match.group(1)) != 4: + return False + match = re.search(r".*seqfield2 = \"([a-z]*)\"", event_line) + if match is None or match.group(1) != "test": + return False + match = re.search(r".*stringfield = \"([a-z]*)\"", event_line) + if match is None or match.group(1) != "test": + return False + + return True + +NR_TESTS = 0 +DYNAMIC_TEST_ENABLED = False + +test_executables = [test_path + "demo_static", test_path + "demo_builtin"] +if os.path.exists(test_path + "demo"): + test_executables.append(test_path + "demo_preload") + NR_TESTS = 2 + DYNAMIC_TEST_ENABLED = True + +# Only enable tests that were compiled successfully +test_executables = [executable for executable in test_executables if os.path.exists(executable)] + +NR_TESTS += len(test_executables) * 10 + +current_test = 1 +print("1..{0}".format(NR_TESTS)) + +if NR_TESTS == 0: + print("# No test binary found") + exit(-1) + +# Check if a sessiond is running... bail out if none found. +if session_daemon_alive() == 0: + bail("No sessiond running. Please make sure you are running this test with the \"run\" shell script and verify that the lttng tools are properly installed.") + +if DYNAMIC_TEST_ENABLED: + session_info = create_session() + enable_ust_tracepoint_event(session_info, "ust_tests_demo*") + start_session(session_info) + + # Dry run, no events should be logged + demo_process = subprocess.Popen(test_path + "demo", stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if sys.version_info >= (3 ,3): + try: + demo_process.wait(5) + except TimeoutExpired: + demo_process.kill() + bail("Failed to run demo test application without preloading") + else: + demo_process.wait() + stop_session(session_info) + + print_test_result(demo_process.returncode == 0, current_test,\ + "Running application dynamically linked to providers, no preload") + current_test += 1 + print_test_result(not os.path.exists(session_info.trace_path), current_test,\ + "No events logged when running demo application without preloading providers") + current_test += 1 + + shutil.rmtree(session_info.tmp_directory) + +for executable in test_executables: + executable_name = os.path.basename(executable) + session_info = create_session() + enable_ust_tracepoint_event(session_info, "ust_tests_demo*") + start_session(session_info) + + demo_process = subprocess.Popen(executable, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if sys.version_info >= (3, 3): + try: + demo_process.wait(5) + except TimeoutExpired: + demo_process.kill() + bail("Failed to run {0} test application".format(executable_name)) + else: + demo_process.wait() + stop_session(session_info) + + trace_found = os.path.exists(session_info.trace_path) + print_test_result(trace_found, current_test,\ + "{0}, resulting trace found".format(executable_name)) + current_test += 1 + + if not trace_found: + print("# Skipping " + executable_name + " trace verification tests") + continue + + try: + babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except FileNotFoundError: + bail("Could not open babeltrace. Please make sure it is installed.") + + # We should find 8 events in the resulting trace + event_entries = [] + for event_line in babeltrace_process.stdout: + event_line = event_line.decode('utf-8').replace("\n", "") + event_entries.append(event_line) + + if len(event_entries) != 8: + bail("{0}, wrong number of events found in resulting trace.".format(executable_name)) + + shutil.rmtree(session_info.tmp_directory) + + print_test_result(len(event_entries) == 8, current_test,\ + "{0}, total number of events logged is correct".format(executable_name)) + current_test += 1 + + # Check each loop event + match = re.search(r".*ust_tests_demo:starting.*value = (\d+) ", event_entries[0]) + print_test_result(match is not None and (int(match.group(1)) == 123), current_test,\ + "{0}, ust_tests_demo:starting event found in trace with a correct integer argument".format(executable_name)) + current_test += 1 + + for i in range(5): + print_test_result(check_ust_test_demo2_event(event_entries[i+1], i), current_test,\ + "{0}, ust_tests_demo2:loop event found in trace and arguments are correct, iteration ".format(executable_name)\ + + str(i + 1)) + current_test += 1 + + match = re.search(r".*ust_tests_demo:done.*value = (\d+)", event_entries[6]) + print_test_result(match is not None and (int(match.group(1)) == 456), current_test,\ + "{0}, ust_tests_demo:done event found in resulting trace with a correct integer argument".format(executable_name)) + current_test += 1 + + match = re.search(r".*ust_tests_demo3:done.*value = (\d+)", event_entries[7]) + print_test_result(match is not None and (int(match.group(1)) == 42), current_test,\ + "{0}, ust_tests_demo3:done event found in resulting trace with a correct integer argument".format(executable_name)) + current_test += 1 diff --git a/tests/regression/ust/linking/tp.c b/tests/regression/ust/linking/tp.c new file mode 100644 index 0000000..8e44db4 --- /dev/null +++ b/tests/regression/ust/linking/tp.c @@ -0,0 +1,26 @@ +/* + * tp.c + * + * Copyright (c) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_demo.h" diff --git a/tests/regression/ust/linking/tp2.c b/tests/regression/ust/linking/tp2.c new file mode 100644 index 0000000..ba45c23 --- /dev/null +++ b/tests/regression/ust/linking/tp2.c @@ -0,0 +1,26 @@ +/* + * tp2.c + * + * Copyright (c) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_demo2.h" diff --git a/tests/regression/ust/linking/tp3.c b/tests/regression/ust/linking/tp3.c new file mode 100644 index 0000000..5f97651 --- /dev/null +++ b/tests/regression/ust/linking/tp3.c @@ -0,0 +1,26 @@ +/* + * tp3.c + * + * Copyright (c) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_demo3.h" diff --git a/tests/regression/ust/linking/ust_tests_demo.h b/tests/regression/ust/linking/ust_tests_demo.h new file mode 100644 index 0000000..d2492b8 --- /dev/null +++ b/tests/regression/ust/linking/ust_tests_demo.h @@ -0,0 +1,61 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +TRACEPOINT_EVENT(ust_tests_demo, starting, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo, starting, TRACE_CRIT) + +TRACEPOINT_EVENT(ust_tests_demo, done, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo, done, TRACE_CRIT) + +#endif /* _TRACEPOINT_UST_TESTS_DEMO_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_demo.h" + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/tests/regression/ust/linking/ust_tests_demo2.h b/tests/regression/ust/linking/ust_tests_demo2.h new file mode 100644 index 0000000..25d42ad --- /dev/null +++ b/tests/regression/ust/linking/ust_tests_demo2.h @@ -0,0 +1,68 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo2 + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO2_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +TRACEPOINT_EVENT(ust_tests_demo2, loop, + TP_ARGS(int, anint, int, netint, long *, values, + char *, text, size_t, textlen, + double, doublearg, float, floatarg), + TP_FIELDS( + ctf_integer(int, intfield, anint) + ctf_integer_hex(int, intfield2, anint) + ctf_integer(long, longfield, anint) + ctf_integer_network(int, netintfield, netint) + ctf_integer_network_hex(int, netintfieldhex, netint) + ctf_array(long, arrfield1, values, 3) + ctf_array_text(char, arrfield2, text, 10) + ctf_sequence(char, seqfield1, text, + size_t, textlen) + ctf_sequence_text(char, seqfield2, text, + size_t, textlen) + ctf_string(stringfield, text) + ctf_float(float, floatfield, floatarg) + ctf_float(double, doublefield, doublearg) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo2, loop, TRACE_WARNING) + +#endif /* _TRACEPOINT_UST_TESTS_DEMO2_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_demo2.h" + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/tests/regression/ust/linking/ust_tests_demo3.h b/tests/regression/ust/linking/ust_tests_demo3.h new file mode 100644 index 0000000..c7b63dd --- /dev/null +++ b/tests/regression/ust/linking/ust_tests_demo3.h @@ -0,0 +1,53 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo3 + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO3_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO3_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +TRACEPOINT_EVENT(ust_tests_demo3, done, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo3, done, TRACE_WARNING) + +#endif /* _TRACEPOINT_UST_TESTS_DEMO3_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_demo3.h" + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif -- 1.8.2 From jeremie.galarneau at efficios.com Mon Mar 25 20:28:32 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Mon, 25 Mar 2013 20:28:32 -0400 Subject: [lttng-dev] [PATCH lttng-tools 3/7] Tests: Add "daemon" ust regression test In-Reply-To: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <1364257716-5739-3-git-send-email-jeremie.galarneau@efficios.com> Based on the "daemon" test formerly part of lttng-ust. Signed-off-by: J?r?mie Galarneau --- .gitignore | 1 + configure.ac | 1 + tests/fast_regression | 1 + tests/long_regression | 1 + tests/regression/ust/Makefile.am | 2 +- tests/regression/ust/daemon/Makefile.am | 15 ++++ tests/regression/ust/daemon/README | 27 ++++++ tests/regression/ust/daemon/daemon.c | 54 +++++++++++ tests/regression/ust/daemon/test_daemon | 35 ++++++++ tests/regression/ust/daemon/test_daemon.py | 120 +++++++++++++++++++++++++ tests/regression/ust/daemon/ust_tests_daemon.h | 57 ++++++++++++ 11 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 tests/regression/ust/daemon/Makefile.am create mode 100644 tests/regression/ust/daemon/README create mode 100644 tests/regression/ust/daemon/daemon.c create mode 100755 tests/regression/ust/daemon/test_daemon create mode 100644 tests/regression/ust/daemon/test_daemon.py create mode 100644 tests/regression/ust/daemon/ust_tests_daemon.h diff --git a/.gitignore b/.gitignore index b9c3ec8..5ea488e 100644 --- a/.gitignore +++ b/.gitignore @@ -67,5 +67,6 @@ tests/regression/ust/overlap/demo/demo tests/regression/ust/linking/demo_builtin tests/regression/ust/linking/demo_static tests/regression/ust/linking/demo +tests/regression/ust/daemon/daemon benchmark/ diff --git a/configure.ac b/configure.ac index 5494cd8..109e4fc 100644 --- a/configure.ac +++ b/configure.ac @@ -333,6 +333,7 @@ AC_CONFIG_FILES([ tests/regression/ust/overlap/Makefile tests/regression/ust/overlap/demo/Makefile tests/regression/ust/linking/Makefile + tests/regression/ust/daemon/Makefile tests/unit/Makefile tests/utils/Makefile tests/utils/tap/Makefile diff --git a/tests/fast_regression b/tests/fast_regression index b700fa5..394dbfd 100644 --- a/tests/fast_regression +++ b/tests/fast_regression @@ -13,3 +13,4 @@ regression/ust/overlap/test_overlap regression/ust/test_event_basic regression/ust/test_event_wildcard regression/ust/linking/test_linking +regression/ust/daemon/test_daemon diff --git a/tests/long_regression b/tests/long_regression index 1fb68c3..1187270 100644 --- a/tests/long_regression +++ b/tests/long_regression @@ -15,3 +15,4 @@ regression/ust/overlap/test_overlap regression/ust/test_event_basic regression/ust/test_event_wildcard regression/ust/linking/test_linking +regression/ust/daemon/test_daemon diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am index 74db00b..2dd6fe9 100644 --- a/tests/regression/ust/Makefile.am +++ b/tests/regression/ust/Makefile.am @@ -1,6 +1,6 @@ if HAVE_LIBLTTNG_UST_CTL SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ - overlap buffers-uid linking + overlap buffers-uid linking daemon EXTRA_DIST = test_event_basic test_event_wildcard diff --git a/tests/regression/ust/daemon/Makefile.am b/tests/regression/ust/daemon/Makefile.am new file mode 100644 index 0000000..d457c06 --- /dev/null +++ b/tests/regression/ust/daemon/Makefile.am @@ -0,0 +1,15 @@ +AM_CPPFLAGS = -I$(srcdir) + +noinst_PROGRAMS = daemon +daemon_SOURCES = daemon.c ust_tests_daemon.h +daemon_LDADD = -llttng-ust -llttng-ust-fork + +if LTTNG_TOOLS_BUILD_WITH_LIBDL +daemon_LDADD += -ldl +endif +if LTTNG_TOOLS_BUILD_WITH_LIBC_DL +daemon_LDADD += -lc +endif + +noinst_SCRIPTS = test_daemon test_daemon.py +EXTRA_DIST = test_daemon test_daemon.py diff --git a/tests/regression/ust/daemon/README b/tests/regression/ust/daemon/README new file mode 100644 index 0000000..64659c6 --- /dev/null +++ b/tests/regression/ust/daemon/README @@ -0,0 +1,27 @@ +Daemon tracing test +------------------- + +This test checks if tracing works correctly in a child process created by a +call to daemon(). + +DESCRIPTION +----------- + +A session daemon is launched if none are found to be running. The test_daemon +script then creates a session, enables all events from the userspace domain, +starts the session and launches the daemon binary. + +The daemon binary, in turn, triggers tracepoints both from the original and +resulting daemon process. + +The test_daemon script then parses the resulting trace and ensures that the +events were correctly recorded and were logged with the right PIDs. + +DEPENDENCIES +------------ + +To run this test, you will need: + + - lttng-tools (with python bindings) + - babeltrace + - python 3.0 or better diff --git a/tests/regression/ust/daemon/daemon.c b/tests/regression/ust/daemon/daemon.c new file mode 100644 index 0000000..477e1a6 --- /dev/null +++ b/tests/regression/ust/daemon/daemon.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2009 Pierre-Marc Fournier + * Copyright (C) 2011-2012 Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 of + * the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include + +#define TRACEPOINT_DEFINE +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_daemon.h" + +int main(int argc, char **argv, char *env[]) +{ + int result; + + if (argc < 1) { + fprintf(stderr, "usage: daemon\n"); + exit(1); + } + + pid_t parent_pid = getpid(); + printf("parent_pid %d\n", parent_pid); + tracepoint(ust_tests_daemon, before_daemon, parent_pid); + + result = daemon(0, 1); + if (result == 0) { + printf("child_pid %d\n", getpid()); + + tracepoint(ust_tests_daemon, after_daemon_child, getpid()); + } else { + tracepoint(ust_tests_daemon, after_daemon_parent); + perror("daemon"); + exit(1); + } + + return 0; +} diff --git a/tests/regression/ust/daemon/test_daemon b/tests/regression/ust/daemon/test_daemon new file mode 100755 index 0000000..54afd0c --- /dev/null +++ b/tests/regression/ust/daemon/test_daemon @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Check for a running sessiond +`pidof lt-lttng-sessiond` +STOP_SESSIOND=$? + +CURDIR=$(dirname $0) +TESTDIR=${CURDIR}/../../.. + +# Try to launch a sessiond before invoking the python test script +if [ $STOP_SESSIOND -ne 0 ]; then + DIR=$(readlink -f ${TESTDIR}) + ${DIR}/../src/bin/lttng-sessiond/lttng-sessiond --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" +fi + +python3 ${CURDIR}/test_daemon.py + +if [ $STOP_SESSIOND -ne 0 ]; then + kill `pidof lt-lttng-sessiond` +fi diff --git a/tests/regression/ust/daemon/test_daemon.py b/tests/regression/ust/daemon/test_daemon.py new file mode 100644 index 0000000..c9a9bff --- /dev/null +++ b/tests/regression/ust/daemon/test_daemon.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import uuid +import os +import subprocess +import re +import shutil +import sys + +test_path = os.path.dirname(os.path.abspath(__file__)) + "/" +test_utils_path = test_path +for i in range(4): + test_utils_path = os.path.dirname(test_utils_path) +test_utils_path = test_utils_path + "/utils" +sys.path.append(test_utils_path) +from test_utils import * + + +NR_TESTS = 6 +current_test = 1 +print("1..{0}".format(NR_TESTS)) + +# Check if a sessiond is running... bail out if none found. +if session_daemon_alive() == 0: + bail("No sessiond running. Please make sure you are running this test with the \"run\" shell script and verify that the lttng tools are properly installed.") + +session_info = create_session() +enable_ust_tracepoint_event(session_info, "*") +start_session(session_info) + +daemon_process = subprocess.Popen(test_path + "daemon", stdout=subprocess.PIPE) +if sys.version_info >= (3, 3): + try: + daemon_process_return_code = daemon_process.wait(5) + except TimeoutExpired: + daemon_process.kill() + daemon_process_return_code = -1 +else: + daemon_process_return_code = daemon_process.wait() + +daemon_process_output = daemon_process.communicate()[0] +daemon_process_output = daemon_process_output.decode('utf-8').splitlines() + +print_test_result(daemon_process_return_code == 0, current_test, "Successful call to daemon() and normal exit") +current_test += 1 + +if daemon_process_return_code != 0: + bail("Could not trigger tracepoints successfully. Abondoning test.") + +stop_session(session_info) + +if len(daemon_process_output) != 2: + bail("Unexpected output received from daemon test executable." + str(daemon_process_output)) + +parent_pid = re.search(r"\d+", daemon_process_output[0]).group(0) +daemon_pid = re.search(r"\d+", daemon_process_output[1]).group(0) + +try: + babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE) +except FileNotFoundError: + bail("Could not open babeltrace. Please make sure it is installed.") + +before_daemon_event_found = False +before_daemon_event_pid = -1 +after_daemon_event_found = False +after_daemon_event_pid = -1 + +for event_line in babeltrace_process.stdout: + event_line = event_line.decode('utf-8').replace("\n", "") + + if re.search(r"before_daemon", event_line) is not None: + if before_daemon_event_found: + bail("Multiple instances of the before_daemon event found. Please make sure only one instance of this test is runnning.") + before_daemon_event_found = True + match = re.search(r"(?<=pid = )\d+", event_line) + + if match is not None: + before_daemon_event_pid = match.group(0) + + if re.search(r"after_daemon", event_line) is not None: + if after_daemon_event_found: + bail("Multiple instances of the after_daemon event found. Please make sure only one instance of this test is runnning.") + after_daemon_event_found = True + match = re.search(r"(?<=pid = )\d+", event_line) + + if match is not None: + after_daemon_event_pid = match.group(0) +babeltrace_process.wait() + +print_test_result(babeltrace_process.returncode == 0, current_test, "Resulting trace is readable") +current_test += 1 + +if babeltrace_process.returncode != 0: + bail("Unreadable trace; can't proceed with analysis.") + +print_test_result(before_daemon_event_found, current_test, "before_daemon event found in resulting trace") +current_test += 1 +print_test_result(before_daemon_event_pid == parent_pid, current_test, "Parent pid reported in trace is correct") +current_test += 1 +print_test_result(before_daemon_event_found, current_test, "after_daemon event found in resulting trace") +current_test += 1 +print_test_result(after_daemon_event_pid == daemon_pid, current_test, "Daemon pid reported in trace is correct") +current_test += 1 + +shutil.rmtree(session_info.tmp_directory) diff --git a/tests/regression/ust/daemon/ust_tests_daemon.h b/tests/regression/ust/daemon/ust_tests_daemon.h new file mode 100644 index 0000000..0025a54 --- /dev/null +++ b/tests/regression/ust/daemon/ust_tests_daemon.h @@ -0,0 +1,57 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_daemon + +#if !defined(_TRACEPOINT_UST_TESTS_DAEMON_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DAEMON_H + +/* + * Copyright (C) 2012 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include + +TRACEPOINT_EVENT(ust_tests_daemon, before_daemon, + TP_ARGS(pid_t, pid), + TP_FIELDS( + ctf_integer(pid_t, pid, pid) + ) +) + +TRACEPOINT_EVENT(ust_tests_daemon, after_daemon_child, + TP_ARGS(pid_t, pid), + TP_FIELDS( + ctf_integer(pid_t, pid, pid) + ) +) + +TRACEPOINT_EVENT(ust_tests_daemon, after_daemon_parent, + TP_ARGS(), + TP_FIELDS() +) + +#endif /* _TRACEPOINT_UST_TESTS_DAEMON_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_daemon.h" + +/* This part must be outside ifdef protection */ +#include -- 1.8.2 From jeremie.galarneau at efficios.com Mon Mar 25 20:28:33 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Mon, 25 Mar 2013 20:28:33 -0400 Subject: [lttng-dev] [PATCH lttng-tools 4/7] Tests: Add "exit-fast" ust regression test In-Reply-To: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <1364257716-5739-4-git-send-email-jeremie.galarneau@efficios.com> Based on the "exit-fast" test formerly part of lttng-ust. Signed-off-by: J?r?mie Galarneau --- .gitignore | 1 + configure.ac | 1 + tests/fast_regression | 1 + tests/long_regression | 1 + tests/regression/ust/Makefile.am | 2 +- tests/regression/ust/exit-fast/Makefile.am | 15 +++ tests/regression/ust/exit-fast/README | 23 +++++ tests/regression/ust/exit-fast/exit-fast.c | 47 +++++++++ tests/regression/ust/exit-fast/test_exit-fast | 35 +++++++ tests/regression/ust/exit-fast/test_exit-fast.py | 111 +++++++++++++++++++++ .../regression/ust/exit-fast/ust_tests_exitfast.h | 52 ++++++++++ 11 files changed, 288 insertions(+), 1 deletion(-) create mode 100644 tests/regression/ust/exit-fast/Makefile.am create mode 100644 tests/regression/ust/exit-fast/README create mode 100644 tests/regression/ust/exit-fast/exit-fast.c create mode 100755 tests/regression/ust/exit-fast/test_exit-fast create mode 100644 tests/regression/ust/exit-fast/test_exit-fast.py create mode 100644 tests/regression/ust/exit-fast/ust_tests_exitfast.h diff --git a/.gitignore b/.gitignore index 5ea488e..4c186d2 100644 --- a/.gitignore +++ b/.gitignore @@ -68,5 +68,6 @@ tests/regression/ust/linking/demo_builtin tests/regression/ust/linking/demo_static tests/regression/ust/linking/demo tests/regression/ust/daemon/daemon +tests/regression/ust/exit-fast/exit-fast benchmark/ diff --git a/configure.ac b/configure.ac index 109e4fc..88d8a33 100644 --- a/configure.ac +++ b/configure.ac @@ -334,6 +334,7 @@ AC_CONFIG_FILES([ tests/regression/ust/overlap/demo/Makefile tests/regression/ust/linking/Makefile tests/regression/ust/daemon/Makefile + tests/regression/ust/exit-fast/Makefile tests/unit/Makefile tests/utils/Makefile tests/utils/tap/Makefile diff --git a/tests/fast_regression b/tests/fast_regression index 394dbfd..e588661 100644 --- a/tests/fast_regression +++ b/tests/fast_regression @@ -14,3 +14,4 @@ regression/ust/test_event_basic regression/ust/test_event_wildcard regression/ust/linking/test_linking regression/ust/daemon/test_daemon +regression/ust/exit-fast/test_exit-fast diff --git a/tests/long_regression b/tests/long_regression index 1187270..a81d094 100644 --- a/tests/long_regression +++ b/tests/long_regression @@ -16,3 +16,4 @@ regression/ust/test_event_basic regression/ust/test_event_wildcard regression/ust/linking/test_linking regression/ust/daemon/test_daemon +regression/ust/exit-fast/test_exit-fast diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am index 2dd6fe9..1631ba6 100644 --- a/tests/regression/ust/Makefile.am +++ b/tests/regression/ust/Makefile.am @@ -1,6 +1,6 @@ if HAVE_LIBLTTNG_UST_CTL SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ - overlap buffers-uid linking daemon + overlap buffers-uid linking daemon exit-fast EXTRA_DIST = test_event_basic test_event_wildcard diff --git a/tests/regression/ust/exit-fast/Makefile.am b/tests/regression/ust/exit-fast/Makefile.am new file mode 100644 index 0000000..ff47cd9 --- /dev/null +++ b/tests/regression/ust/exit-fast/Makefile.am @@ -0,0 +1,15 @@ +AM_CPPFLAGS = -I$(srcdir) + +noinst_PROGRAMS = exit-fast +exit_fast_SOURCES = exit-fast.c ust_tests_exitfast.h +exit_fast_LDADD = -llttng-ust + +if LTTNG_TOOLS_BUILD_WITH_LIBDL +exit_fast_LDADD += -ldl +endif +if LTTNG_TOOLS_BUILD_WITH_LIBC_DL +exit_fast_LDADD += -lc +endif + +noinst_SCRIPTS = test_exit-fast test_exit-fast.py +EXTRA_DIST = test_exit-fast test_exit-fast.py diff --git a/tests/regression/ust/exit-fast/README b/tests/regression/ust/exit-fast/README new file mode 100644 index 0000000..87340dd --- /dev/null +++ b/tests/regression/ust/exit-fast/README @@ -0,0 +1,23 @@ +exit-fast tracing test +------------------- + +This test verifies that tracing works correctly when the traced process exits +right after an event is logged. + +DESCRIPTION +----------- + +This test launches a process that logs an event and returns directly after. +It then launches it again in a mode that will trigger a SIGKILL right after +the tracepoint is executed. The resulting trace is then checked for errors. + +The events must be present in the trace and contain the appropriate test string. + +DEPENDENCIES +------------ + +To run this test, you will need: + + - lttng-tools (with python bindings) + - babeltrace + - python 3.0 or better diff --git a/tests/regression/ust/exit-fast/exit-fast.c b/tests/regression/ust/exit-fast/exit-fast.c new file mode 100644 index 0000000..8642656 --- /dev/null +++ b/tests/regression/ust/exit-fast/exit-fast.c @@ -0,0 +1,47 @@ +/* Copyright (C) 2011 Nils Carlson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* This test generates a single event and exits. + */ + +#include +#include +#include +#include + +#define TRACEPOINT_DEFINE +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_exitfast.h" + +int main(int argc, char *argv[]) +{ + int suicide = 0; + char normal_exit_text[] = "exit-fast tracepoint normal exit"; + char suicide_exit_text[] = "exit-fast tracepoint suicide"; + + if (argc > 1 && !strcmp(argv[1], "suicide")) { + suicide = 1; + } + + if (suicide) { + tracepoint(ust_tests_exitfast, message, suicide_exit_text); + kill(getpid(), SIGKILL); + } + + tracepoint(ust_tests_exitfast, message, normal_exit_text); + return 0; +} diff --git a/tests/regression/ust/exit-fast/test_exit-fast b/tests/regression/ust/exit-fast/test_exit-fast new file mode 100755 index 0000000..e8a0bd6 --- /dev/null +++ b/tests/regression/ust/exit-fast/test_exit-fast @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Check for a running sessiond +`pidof lt-lttng-sessiond` +STOP_SESSIOND=$? + +CURDIR=$(dirname $0) +TESTDIR=${CURDIR}/../../.. + +# Try to launch a sessiond before invoking the python test script +if [ $STOP_SESSIOND -ne 0 ]; then + DIR=$(readlink -f ${TESTDIR}) + ${DIR}/../src/bin/lttng-sessiond/lttng-sessiond --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" +fi + +python3 ${CURDIR}/test_exit-fast.py + +if [ $STOP_SESSIOND -ne 0 ]; then + kill `pidof lt-lttng-sessiond` +fi diff --git a/tests/regression/ust/exit-fast/test_exit-fast.py b/tests/regression/ust/exit-fast/test_exit-fast.py new file mode 100644 index 0000000..71ae7d3 --- /dev/null +++ b/tests/regression/ust/exit-fast/test_exit-fast.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python3 +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import os +import subprocess +import re +import shutil +import sys + +test_path = os.path.dirname(os.path.abspath(__file__)) + "/" +test_utils_path = test_path +for i in range(4): + test_utils_path = os.path.dirname(test_utils_path) +test_utils_path = test_utils_path + "/utils" +sys.path.append(test_utils_path) +from test_utils import * + + +normal_exit_message = "exit-fast tracepoint normal exit" +suicide_exit_message = "exit-fast tracepoint suicide" +NR_TESTS = 5 +current_test = 1 +print("1..{0}".format(NR_TESTS)) + +# Check if a sessiond is running... bail out if none found. +if session_daemon_alive() == 0: + bail("No sessiond running. Please make sure you are running this test with the \"run\" shell script and verify that the lttng tools are properly installed.") + +session_info = create_session() +enable_ust_tracepoint_event(session_info, "ust_tests_exitfast*") +start_session(session_info) + +test_env = os.environ.copy() +test_env["LTTNG_UST_REGISTER_TIMEOUT"] = "-1" + +exit_fast_process = subprocess.Popen(test_path + "exit-fast", stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=test_env) + +if sys.version_info >= (3, 3): + try: + exit_fast_process.wait(5) + except TimeoutExpired: + exit_fast_process.kill() + bail("Failed to run exit-fast test application.") +else: + exit_fast_process.wait() + +print_test_result(exit_fast_process.returncode == 0, current_test, "Test application exited normally") +current_test += 1 + +exit_fast_process = subprocess.Popen([test_path + "exit-fast", "suicide"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=test_env) + +if sys.version_info >= (3, 3): + try: + exit_fast_process.wait(5) + except TimeoutExpired: + exit_fast_process.kill() + bail("Failed to run exit-fast test application in suicide mode.") +else: + exit_fast_process.wait() + +stop_session(session_info) + +# Check both events (normal exit and suicide messages) are present in the resulting trace +try: + babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +except FileNotFoundError: + bail("Could not open babeltrace. Please make sure it is installed.") + +event_lines = [] +for event_line in babeltrace_process.stdout: + event_line = event_line.decode('utf-8').replace("\n", "") + event_lines.append(event_line) +babeltrace_process.wait() + +print_test_result(babeltrace_process.returncode == 0, current_test, "Resulting trace is readable") +current_test += 1 + +if babeltrace_process.returncode != 0: + bail("Unreadable trace; can't proceed with analysis.") + +print_test_result(len(event_lines) == 2, current_test, "Correct number of events found in resulting trace") +current_test += 1 + +if len(event_lines) != 2: + bail("Unexpected number of events found in resulting trace (" + session_info.trace_path + ")." ) + +match = re.search(r".*message = \"(.*)\"", event_lines[0]) +print_test_result(match is not None and match.group(1) == normal_exit_message, current_test,\ + "Tracepoint message generated during normal exit run is present in trace and has the expected value") +current_test += 1 + +match = re.search(r".*message = \"(.*)\"", event_lines[1]) +print_test_result(match is not None and match.group(1) == suicide_exit_message, current_test,\ + "Tracepoint message generated during suicide run is present in trace and has the expected value") +current_test += 1 + +shutil.rmtree(session_info.tmp_directory) diff --git a/tests/regression/ust/exit-fast/ust_tests_exitfast.h b/tests/regression/ust/exit-fast/ust_tests_exitfast.h new file mode 100644 index 0000000..71d81f7 --- /dev/null +++ b/tests/regression/ust/exit-fast/ust_tests_exitfast.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011-2012 Mathieu Desnoyers + * Copyright (C) 2011-2012 Matthew Khouzam + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_exitfast + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if !defined(_TRACEPOINT_UST_TESTS_EXITFAST_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_EXITFAST_H + +#include + +TRACEPOINT_EVENT(ust_tests_exitfast, message, + TP_ARGS(char *, text), + TP_FIELDS(ctf_string(message, text)) +) + +TRACEPOINT_LOGLEVEL(ust_tests_exitfast, message, TRACE_INFO) + +#endif /* _TRACEPOINT_UST_TESTS_EXITFAST_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_exitfast.h" + +#include + +#ifdef __cplusplus +} +#endif /* __cplusplus */ -- 1.8.2 From jeremie.galarneau at efficios.com Mon Mar 25 20:28:34 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Mon, 25 Mar 2013 20:28:34 -0400 Subject: [lttng-dev] [PATCH lttng-tools 5/7] Tests: Add "fork" ust regression test In-Reply-To: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <1364257716-5739-5-git-send-email-jeremie.galarneau@efficios.com> Based on the "fork" test formerly part of lttng-ust. Signed-off-by: J?r?mie Galarneau --- .gitignore | 2 + configure.ac | 1 + tests/fast_regression | 1 + tests/long_regression | 1 + tests/regression/ust/Makefile.am | 2 +- tests/regression/ust/fork/Makefile.am | 20 +++++ tests/regression/ust/fork/README | 26 ++++++ tests/regression/ust/fork/fork.c | 62 +++++++++++++++ tests/regression/ust/fork/fork2.c | 32 ++++++++ tests/regression/ust/fork/test_fork | 35 ++++++++ tests/regression/ust/fork/test_fork.py | 124 +++++++++++++++++++++++++++++ tests/regression/ust/fork/ust_tests_fork.h | 66 +++++++++++++++ 12 files changed, 371 insertions(+), 1 deletion(-) create mode 100644 tests/regression/ust/fork/Makefile.am create mode 100644 tests/regression/ust/fork/README create mode 100644 tests/regression/ust/fork/fork.c create mode 100644 tests/regression/ust/fork/fork2.c create mode 100755 tests/regression/ust/fork/test_fork create mode 100644 tests/regression/ust/fork/test_fork.py create mode 100644 tests/regression/ust/fork/ust_tests_fork.h diff --git a/.gitignore b/.gitignore index 4c186d2..533973a 100644 --- a/.gitignore +++ b/.gitignore @@ -69,5 +69,7 @@ tests/regression/ust/linking/demo_static tests/regression/ust/linking/demo tests/regression/ust/daemon/daemon tests/regression/ust/exit-fast/exit-fast +tests/regression/ust/fork/fork +tests/regression/ust/fork/fork2 benchmark/ diff --git a/configure.ac b/configure.ac index 88d8a33..d7ca253 100644 --- a/configure.ac +++ b/configure.ac @@ -335,6 +335,7 @@ AC_CONFIG_FILES([ tests/regression/ust/linking/Makefile tests/regression/ust/daemon/Makefile tests/regression/ust/exit-fast/Makefile + tests/regression/ust/fork/Makefile tests/unit/Makefile tests/utils/Makefile tests/utils/tap/Makefile diff --git a/tests/fast_regression b/tests/fast_regression index e588661..cc561fb 100644 --- a/tests/fast_regression +++ b/tests/fast_regression @@ -15,3 +15,4 @@ regression/ust/test_event_wildcard regression/ust/linking/test_linking regression/ust/daemon/test_daemon regression/ust/exit-fast/test_exit-fast +regression/ust/fork/test_fork diff --git a/tests/long_regression b/tests/long_regression index a81d094..810b661 100644 --- a/tests/long_regression +++ b/tests/long_regression @@ -17,3 +17,4 @@ regression/ust/test_event_wildcard regression/ust/linking/test_linking regression/ust/daemon/test_daemon regression/ust/exit-fast/test_exit-fast +regression/ust/fork/test_fork diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am index 1631ba6..23613bd 100644 --- a/tests/regression/ust/Makefile.am +++ b/tests/regression/ust/Makefile.am @@ -1,6 +1,6 @@ if HAVE_LIBLTTNG_UST_CTL SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ - overlap buffers-uid linking daemon exit-fast + overlap buffers-uid linking daemon exit-fast fork EXTRA_DIST = test_event_basic test_event_wildcard diff --git a/tests/regression/ust/fork/Makefile.am b/tests/regression/ust/fork/Makefile.am new file mode 100644 index 0000000..97f134f --- /dev/null +++ b/tests/regression/ust/fork/Makefile.am @@ -0,0 +1,20 @@ +AM_CPPFLAGS = -I$(srcdir) + +noinst_PROGRAMS = fork fork2 +fork_SOURCES = fork.c ust_tests_fork.h +fork_LDADD = -llttng-ust -llttng-ust-fork + +fork2_SOURCES = fork2.c +fork2_LDADD = -llttng-ust -llttng-ust-fork + +if LTTNG_TOOLS_BUILD_WITH_LIBDL +fork_LDADD += -ldl +fork2_LDADD += -ldl +endif +if LTTNG_TOOLS_BUILD_WITH_LIBC_DL +fork_LDADD += -lc +fork2_LDADD += -lc +endif + +noinst_SCRIPTS = test_fork test_fork.py +EXTRA_DIST = test_fork test_fork.py diff --git a/tests/regression/ust/fork/README b/tests/regression/ust/fork/README new file mode 100644 index 0000000..eb36100 --- /dev/null +++ b/tests/regression/ust/fork/README @@ -0,0 +1,26 @@ +Fork tracing test +------------------- + +This test checks if tracing works correctly in a child process created by a +fork() call, as well as after an exec() call. + +DESCRIPTION +----------- + +The test_fork script launches a binary that forks and calls exec() with +the command provided as the argument. Tracepoints are placed before and +after these calls to verify tracing remains operational at all times. + +The binary loaded as the new process image also logs an event. + +The resulting trace is parsed to make sure the every event was logged +successfully with the correct PIDs. + +DEPENDENCIES +------------ + +To run this test, you will need: + + - lttng-tools (with python bindings) + - babeltrace + - python 3.0 or better diff --git a/tests/regression/ust/fork/fork.c b/tests/regression/ust/fork/fork.c new file mode 100644 index 0000000..744e920 --- /dev/null +++ b/tests/regression/ust/fork/fork.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 Pierre-Marc Fournier + * Copyright (C) 2011 Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 of + * the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include + +#define TRACEPOINT_DEFINE +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_fork.h" + +int main(int argc, char **argv, char *env[]) +{ + int result; + + if (argc < 2) { + fprintf(stderr, "usage: fork PROG_TO_EXEC\n"); + exit(1); + } + + printf("parent_pid %d\n", getpid()); + tracepoint(ust_tests_fork, before_fork, getpid()); + + result = fork(); + if (result == -1) { + perror("fork"); + return 1; + } + if (result == 0) { + char *args[] = { "fork2", NULL }; + + tracepoint(ust_tests_fork, after_fork_child, getpid()); + + result = execve(argv[1], args, env); + if (result == -1) { + perror("execve"); + return 1; + } + } else { + printf("child_pid %d\n", result); + tracepoint(ust_tests_fork, after_fork_parent, getpid()); + } + + return 0; +} diff --git a/tests/regression/ust/fork/fork2.c b/tests/regression/ust/fork/fork2.c new file mode 100644 index 0000000..ee0f36b --- /dev/null +++ b/tests/regression/ust/fork/fork2.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2009 Pierre-Marc Fournier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#define TRACEPOINT_DEFINE +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_fork.h" + +int main() +{ + printf("IN FORK2\n"); + + tracepoint(ust_tests_fork, after_exec, getpid()); + + return 0; +} diff --git a/tests/regression/ust/fork/test_fork b/tests/regression/ust/fork/test_fork new file mode 100755 index 0000000..e05b556 --- /dev/null +++ b/tests/regression/ust/fork/test_fork @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Check for a running sessiond +`pidof lt-lttng-sessiond` +STOP_SESSIOND=$? + +CURDIR=$(dirname $0) +TESTDIR=${CURDIR}/../../.. + +# Try to launch a sessiond before invoking the python test script +if [ $STOP_SESSIOND -ne 0 ]; then + DIR=$(readlink -f ${TESTDIR}) + ${DIR}/../src/bin/lttng-sessiond/lttng-sessiond --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" +fi + +python3 ${CURDIR}/test_fork.py + +if [ $STOP_SESSIOND -ne 0 ]; then + kill `pidof lt-lttng-sessiond` +fi diff --git a/tests/regression/ust/fork/test_fork.py b/tests/regression/ust/fork/test_fork.py new file mode 100644 index 0000000..62faf71 --- /dev/null +++ b/tests/regression/ust/fork/test_fork.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import os +import subprocess +import re +import shutil +import sys + +test_path = os.path.dirname(os.path.abspath(__file__)) + "/" +test_utils_path = test_path +for i in range(4): + test_utils_path = os.path.dirname(test_utils_path) +test_utils_path = test_utils_path + "/utils" +sys.path.append(test_utils_path) +from test_utils import * + + +NR_TESTS = 6 +current_test = 1 +print("1..{0}".format(NR_TESTS)) + +# Check if a sessiond is running... bail out if none found. +if session_daemon_alive() == 0: + bail("No sessiond running. Please make sure you are running this test with the \"run\" shell script and verify that the lttng tools are properly installed.") + +session_info = create_session() +enable_ust_tracepoint_event(session_info, "ust_tests_fork*") +start_session(session_info) + +fork_process = subprocess.Popen([test_path + "fork", test_path + "fork2"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + +if sys.version_info >= (3, 3): + try: + fork_process.wait(5) + except TimeoutExpired: + fork_process.kill() + bail("Failed to run fork test application (time out)", session_info) +else: + fork_process.wait() + +parent_pid = -1 +child_pid = -1 +for line in fork_process.stdout: + line = line.decode('utf-8').replace("\n", "") + match = re.search(r"child_pid (\d+)", line) + if match: + child_pid = match.group(1) + match = re.search(r"parent_pid (\d+)", line) + if match: + parent_pid = match.group(1) + +print_test_result(fork_process.returncode == 0, current_test, "Fork test application exited normally") +current_test += 1 + +stop_session(session_info) + +# Check both events (normal exit and suicide messages) are present in the resulting trace +try: + babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +except FileNotFoundError: + bail("Could not open babeltrace. Please make sure it is installed.", session_info) + +event_lines = [] +for event_line in babeltrace_process.stdout: + event_line = event_line.decode('utf-8').replace("\n", "") + if re.search(r"warning", event_line) is not None or re.search(r"error", event_line) is not None: + print( "# " + event_line ) + else: + event_lines.append(event_line) + +babeltrace_process.wait() + +print_test_result(babeltrace_process.returncode == 0, current_test, "Resulting trace is readable") +current_test += 1 + +if babeltrace_process.returncode != 0: + bail("Unreadable trace; can't proceed with analysis.", session_info) + +event_before_fork = False +event_after_fork_parent = False +event_after_fork_child = False +event_after_exec = False + +for event_line in event_lines: + match = re.search(r".*pid = (\d+)", event_line) + if match is not None: + event_pid = match.group(1) + else: + continue + + if re.search(r"before_fork", event_line): + event_before_fork = (event_pid == parent_pid) + if re.search(r"after_fork_parent", event_line): + event_after_fork_parent = (event_pid == parent_pid) + if re.search(r"after_fork_child", event_line): + event_after_fork_child = (event_pid == child_pid) + if re.search(r"after_exec", event_line): + event_after_exec = (event_pid == child_pid) + +print_test_result(event_before_fork, current_test, "before_fork event logged by parent process found in trace") +current_test += 1 +print_test_result(event_after_fork_parent, current_test, "after_fork_parent event logged by parent process found in trace") +current_test += 1 +print_test_result(event_after_fork_child, current_test, "after_fork_child event logged by child process found in trace") +current_test += 1 +print_test_result(event_after_exec, current_test, "after_exec event logged by child process found in trace") +current_test += 1 + +shutil.rmtree(session_info.tmp_directory) diff --git a/tests/regression/ust/fork/ust_tests_fork.h b/tests/regression/ust/fork/ust_tests_fork.h new file mode 100644 index 0000000..b034f9f --- /dev/null +++ b/tests/regression/ust/fork/ust_tests_fork.h @@ -0,0 +1,66 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_fork + +#if !defined(_TRACEPOINT_UST_TESTS_FORK_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_FORK_H + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include + +TRACEPOINT_EVENT(ust_tests_fork, before_fork, + TP_ARGS(pid_t, pid), + TP_FIELDS( + ctf_integer(pid_t, pid, pid) + ) +) + +TRACEPOINT_EVENT(ust_tests_fork, after_fork_child, + TP_ARGS(pid_t, pid), + TP_FIELDS( + ctf_integer(pid_t, pid, pid) + ) +) + +TRACEPOINT_EVENT(ust_tests_fork, after_fork_parent, + TP_ARGS(pid_t, pid), + TP_FIELDS( + ctf_integer(pid_t, pid, pid) + ) +) + +TRACEPOINT_EVENT(ust_tests_fork, after_exec, + TP_ARGS(pid_t, pid), + TP_FIELDS( + ctf_integer(pid_t, pid, pid) + ) +) + +#endif /* _TRACEPOINT_UST_TESTS_FORK_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_fork.h" + +/* This part must be outside ifdef protection */ +#include -- 1.8.2 From jeremie.galarneau at efficios.com Mon Mar 25 20:28:35 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Mon, 25 Mar 2013 20:28:35 -0400 Subject: [lttng-dev] [PATCH lttng-tools 6/7] Tests: Add "libc-wrapper" ust regression test In-Reply-To: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <1364257716-5739-6-git-send-email-jeremie.galarneau@efficios.com> Based on the "test-libustinstr-malloc" test formerly part of lttng-ust. Signed-off-by: J?r?mie Galarneau --- .gitignore | 1 + configure.ac | 1 + tests/fast_regression | 1 + tests/long_regression | 1 + tests/regression/ust/Makefile.am | 2 +- tests/regression/ust/libc-wrapper/Makefile.am | 8 ++ tests/regression/ust/libc-wrapper/README | 22 ++++++ tests/regression/ust/libc-wrapper/prog.c | 48 +++++++++++ .../regression/ust/libc-wrapper/test_libc-wrapper | 35 ++++++++ .../ust/libc-wrapper/test_libc-wrapper.py | 92 ++++++++++++++++++++++ 10 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 tests/regression/ust/libc-wrapper/Makefile.am create mode 100644 tests/regression/ust/libc-wrapper/README create mode 100644 tests/regression/ust/libc-wrapper/prog.c create mode 100755 tests/regression/ust/libc-wrapper/test_libc-wrapper create mode 100644 tests/regression/ust/libc-wrapper/test_libc-wrapper.py diff --git a/.gitignore b/.gitignore index 533973a..8e2e63d 100644 --- a/.gitignore +++ b/.gitignore @@ -71,5 +71,6 @@ tests/regression/ust/daemon/daemon tests/regression/ust/exit-fast/exit-fast tests/regression/ust/fork/fork tests/regression/ust/fork/fork2 +tests/regression/ust/libc-wrapper/prog benchmark/ diff --git a/configure.ac b/configure.ac index d7ca253..e2c2a4f 100644 --- a/configure.ac +++ b/configure.ac @@ -336,6 +336,7 @@ AC_CONFIG_FILES([ tests/regression/ust/daemon/Makefile tests/regression/ust/exit-fast/Makefile tests/regression/ust/fork/Makefile + tests/regression/ust/libc-wrapper/Makefile tests/unit/Makefile tests/utils/Makefile tests/utils/tap/Makefile diff --git a/tests/fast_regression b/tests/fast_regression index cc561fb..175bb03 100644 --- a/tests/fast_regression +++ b/tests/fast_regression @@ -16,3 +16,4 @@ regression/ust/linking/test_linking regression/ust/daemon/test_daemon regression/ust/exit-fast/test_exit-fast regression/ust/fork/test_fork +regression/ust/libc-wrapper/test_libc-wrapper diff --git a/tests/long_regression b/tests/long_regression index 810b661..8b1cbfc 100644 --- a/tests/long_regression +++ b/tests/long_regression @@ -18,3 +18,4 @@ regression/ust/linking/test_linking regression/ust/daemon/test_daemon regression/ust/exit-fast/test_exit-fast regression/ust/fork/test_fork +regression/ust/libc-wrapper/test_libc-wrapper diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am index 23613bd..e622544 100644 --- a/tests/regression/ust/Makefile.am +++ b/tests/regression/ust/Makefile.am @@ -1,6 +1,6 @@ if HAVE_LIBLTTNG_UST_CTL SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ - overlap buffers-uid linking daemon exit-fast fork + overlap buffers-uid linking daemon exit-fast fork libc-wrapper EXTRA_DIST = test_event_basic test_event_wildcard diff --git a/tests/regression/ust/libc-wrapper/Makefile.am b/tests/regression/ust/libc-wrapper/Makefile.am new file mode 100644 index 0000000..af12d31 --- /dev/null +++ b/tests/regression/ust/libc-wrapper/Makefile.am @@ -0,0 +1,8 @@ +AM_CPPFLAGS = -I$(srcdir) + +noinst_PROGRAMS = prog +prog_SOURCES = prog.c +prog_LDADD = -llttng-ust -llttng-ust-libc-wrapper + +noinst_SCRIPTS = test_libc-wrapper test_libc-wrapper.py +EXTRA_DIST = test_libc-wrapper test_libc-wrapper.py diff --git a/tests/regression/ust/libc-wrapper/README b/tests/regression/ust/libc-wrapper/README new file mode 100644 index 0000000..adcd425 --- /dev/null +++ b/tests/regression/ust/libc-wrapper/README @@ -0,0 +1,22 @@ +libc-wrapper malloc/free tracing test +------------------------------------- + +This test checks if tracing works correctly when applications are linked against +the UST libc wrapper which provides tracepoints in the malloc and free libc +functions. + +DESCRIPTION +----------- + +The test application performs a series of calls to malloc()/free() and the +resulting trace is checked for the presence of ust-libc:malloc and ust-libc:free +events. + +DEPENDENCIES +------------ + +To run this test, you will need: + + - lttng-tools (with python bindings) + - babeltrace + - python 3.0 or better diff --git a/tests/regression/ust/libc-wrapper/prog.c b/tests/regression/ust/libc-wrapper/prog.c new file mode 100644 index 0000000..3068257 --- /dev/null +++ b/tests/regression/ust/libc-wrapper/prog.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2009 Pierre-Marc Fournier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* This program is used to test malloc instrumentation with libustinstr-malloc. + */ + +#include +#include + +#define N_ITER 1000 + +int main() +{ + int i; + const char teststr[] = "Hello World! 1234567890abc"; + void *ptrs[N_ITER]; + + for (i = 0; i < N_ITER; i++) { + ptrs[i] = malloc(i+1000); + + memcpy(ptrs[i], teststr, sizeof(teststr)); + + if (i % 2 == 0) { + free(ptrs[i]); + } + } + + for (i = 0; i < N_ITER; i++) { + if (i % 2 == 1) + free(ptrs[i]); + } + + return 0; +} diff --git a/tests/regression/ust/libc-wrapper/test_libc-wrapper b/tests/regression/ust/libc-wrapper/test_libc-wrapper new file mode 100755 index 0000000..8c6b128 --- /dev/null +++ b/tests/regression/ust/libc-wrapper/test_libc-wrapper @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Check for a running sessiond +`pidof lt-lttng-sessiond` +STOP_SESSIOND=$? + +CURDIR=$(dirname $0) +TESTDIR=${CURDIR}/../../.. + +# Try to launch a sessiond before invoking the python test script +if [ $STOP_SESSIOND -ne 0 ]; then + DIR=$(readlink -f ${TESTDIR}) + ${DIR}/../src/bin/lttng-sessiond/lttng-sessiond --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" +fi + +python3 ${CURDIR}/test_libc-wrapper.py + +if [ $STOP_SESSIOND -ne 0 ]; then + kill `pidof lt-lttng-sessiond` +fi diff --git a/tests/regression/ust/libc-wrapper/test_libc-wrapper.py b/tests/regression/ust/libc-wrapper/test_libc-wrapper.py new file mode 100644 index 0000000..d45b71a --- /dev/null +++ b/tests/regression/ust/libc-wrapper/test_libc-wrapper.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +# +# Copyright (C) - 2013 J?r?mie Galarneau +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License, version 2 only, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import os +import subprocess +import re +import shutil +import sys + +test_path = os.path.dirname(os.path.abspath(__file__)) + "/" +test_utils_path = test_path +for i in range(4): + test_utils_path = os.path.dirname(test_utils_path) +test_utils_path = test_utils_path + "/utils" +sys.path.append(test_utils_path) +from test_utils import * + + +NR_TESTS = 4 +current_test = 1 +print("1..{0}".format(NR_TESTS)) + +# Check if a sessiond is running... bail out if none found. +if session_daemon_alive() == 0: + bail("No sessiond running. Please make sure you are running this test with the \"run\" shell script and verify that the lttng tools are properly installed.") + +session_info = create_session() +enable_ust_tracepoint_event(session_info, "ust_libc*") +start_session(session_info) + +malloc_process = subprocess.Popen(test_path + "prog", stdout=subprocess.PIPE, stderr=subprocess.PIPE) +if sys.version_info >= (3, 3): + try: + malloc_process.wait(5) + except TimeoutExpired: + malloc_process.kill() + bail("Failed to run libustinstr-malloc test application.", session_info) +else: + malloc_process.wait() + +print_test_result(malloc_process.returncode == 0, current_test, "Test application exited normally") +current_test += 1 + +stop_session(session_info) + +# Check for malloc events in the resulting trace +try: + babeltrace_process = subprocess.Popen(["babeltrace", session_info.trace_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +except FileNotFoundError: + bail("Could not open babeltrace. Please make sure it is installed.", session_info) + +malloc_event_found = False +free_event_found = False + +for event_line in babeltrace_process.stdout: + # Let babeltrace finish to get the return code + if malloc_event_found and free_event_found: + continue + + event_line = event_line.decode('utf-8').replace("\n", "") + if re.search(r".*ust_libc:malloc.*", event_line) is not None: + malloc_event_found = True + + if re.search(r".*ust_libc:free.*", event_line) is not None: + free_event_found = True + +babeltrace_process.wait() + +print_test_result(babeltrace_process.returncode == 0, current_test, "Resulting trace is readable") +current_test += 1 + +print_test_result(free_event_found, current_test, "ust_libc:malloc event found in resulting trace") +current_test += 1 + +print_test_result(free_event_found, current_test, "ust_libc:free event found in resulting trace") +current_test += 1 + +shutil.rmtree(session_info.tmp_directory) -- 1.8.2 From jeremie.galarneau at efficios.com Mon Mar 25 20:28:36 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Mon, 25 Mar 2013 20:28:36 -0400 Subject: [lttng-dev] [PATCH lttng-tools 7/7] Add optional Python >= 3.0 dependency to README In-Reply-To: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <1364257716-5739-7-git-send-email-jeremie.galarneau@efficios.com> Signed-off-by: J?r?mie Galarneau --- README | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README b/README index cfbf1ac..9aab80f 100644 --- a/README +++ b/README @@ -31,6 +31,11 @@ REQUIREMENTS: - Perl (optional) Needed for make check and tests. + - Python >= 3.0 (optional) + Needed for make check and tests. + + * Debian/Ubuntu package: python3 + - SWIG >= 2.0 (optional) Needed for Python bindings (--enable-python-bindings). -- 1.8.2 From jdesfossez at efficios.com Mon Mar 25 22:27:05 2013 From: jdesfossez at efficios.com (Julien Desfossez) Date: Mon, 25 Mar 2013 22:27:05 -0400 Subject: [lttng-dev] [LTTNG-TOOLS PATCH] UST periodical metadata flush Message-ID: <1364264825-13550-1-git-send-email-jdesfossez@efficios.com> Add a new socket between the sessiond and the ust-consumer to allow periodical flush of the metadata channel. If enabled (by specifying the --switch-timer option on the metadata channel), a new timer thread in the consumer asks the session daemon for new metadata for a specific session. All the metadata collected is written into a metadata cache in the consumer, this mechanism is useful for synchronisation (to avoid race conditions between two metadata updates) and will also be useful when we implement the snapshots. Signed-off-by: Julien Desfossez --- src/bin/lttng-consumerd/lttng-consumerd.c | 53 ++++- src/bin/lttng-sessiond/consumer.c | 20 +- src/bin/lttng-sessiond/consumer.h | 4 + src/bin/lttng-sessiond/lttng-ust-ctl.h | 1 + src/bin/lttng-sessiond/main.c | 223 +++++++++++++---- src/bin/lttng-sessiond/ust-app.c | 38 ++- src/bin/lttng-sessiond/ust-app.h | 4 + src/bin/lttng-sessiond/ust-consumer.c | 92 +++++++ src/bin/lttng-sessiond/ust-consumer.h | 1 + src/common/Makefile.am | 5 +- src/common/consumer-metadata-cache.c | 213 +++++++++++++++++ src/common/consumer-metadata-cache.h | 34 +++ src/common/consumer.c | 16 ++ src/common/consumer.h | 65 ++++- src/common/defaults.h | 9 + src/common/sessiond-comm/sessiond-comm.h | 20 ++ src/common/ust-consumer/ust-consumer.c | 369 +++++++++++++++++++++++++++-- src/common/ust-consumer/ust-consumer.h | 4 + tests/unit/Makefile.am | 1 + 19 files changed, 1072 insertions(+), 100 deletions(-) create mode 100644 src/common/consumer-metadata-cache.c create mode 100644 src/common/consumer-metadata-cache.h diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index 8486807..afac445 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c @@ -52,7 +52,8 @@ /* TODO : support UST (all direct kernel-ctl accesses). */ /* threads (channel handling, poll, metadata, sessiond) */ -static pthread_t channel_thread, data_thread, metadata_thread, sessiond_thread; +static pthread_t channel_thread, data_thread, metadata_thread, + sessiond_thread, metadata_timer_thread; /* to count the number of times the user pressed ctrl+c */ static int sigintcount = 0; @@ -64,6 +65,7 @@ static int opt_daemon; static const char *progname; static char command_sock_path[PATH_MAX]; /* Global command socket path */ static char error_sock_path[PATH_MAX]; /* Global error path */ +static char metadata_sock_path[PATH_MAX]; /* UST metadata socket path */ static enum lttng_consumer_type opt_type = LTTNG_CONSUMER_KERNEL; /* the liblttngconsumerd context */ @@ -138,6 +140,8 @@ static void usage(FILE *fp) "Specify path for the command socket\n"); fprintf(fp, " -e, --consumerd-err-sock PATH " "Specify path for the error socket\n"); + fprintf(fp, " -e, --consumerd-metadata-sock PATH " + "Specify path for the metadata socket (UST only)\n"); fprintf(fp, " -d, --daemonize " "Start as a daemon.\n"); fprintf(fp, " -q, --quiet " @@ -168,6 +172,7 @@ static void parse_args(int argc, char **argv) static struct option long_options[] = { { "consumerd-cmd-sock", 1, 0, 'c' }, { "consumerd-err-sock", 1, 0, 'e' }, + { "consumerd-metadata-sock", 1, 0, 'm' }, { "daemonize", 0, 0, 'd' }, { "help", 0, 0, 'h' }, { "quiet", 0, 0, 'q' }, @@ -182,7 +187,7 @@ static void parse_args(int argc, char **argv) while (1) { int option_index = 0; - c = getopt_long(argc, argv, "dhqvVku" "c:e:", long_options, &option_index); + c = getopt_long(argc, argv, "dhqvVku" "c:e:m:", long_options, &option_index); if (c == -1) { break; } @@ -200,6 +205,9 @@ static void parse_args(int argc, char **argv) case 'e': snprintf(error_sock_path, PATH_MAX, "%s", optarg); break; + case 'm': + snprintf(metadata_sock_path, PATH_MAX, "%s", optarg); + break; case 'd': opt_daemon = 1; break; @@ -339,10 +347,14 @@ int main(int argc, char **argv) case LTTNG_CONSUMER64_UST: snprintf(error_sock_path, PATH_MAX, DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH, DEFAULT_LTTNG_RUNDIR); + snprintf(metadata_sock_path, PATH_MAX, + DEFAULT_USTCONSUMERD64_META_SOCK_PATH, DEFAULT_LTTNG_RUNDIR); break; case LTTNG_CONSUMER32_UST: snprintf(error_sock_path, PATH_MAX, DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH, DEFAULT_LTTNG_RUNDIR); + snprintf(metadata_sock_path, PATH_MAX, + DEFAULT_USTCONSUMERD32_META_SOCK_PATH, DEFAULT_LTTNG_RUNDIR); break; default: WARN("Unknown consumerd type"); @@ -363,6 +375,27 @@ int main(int argc, char **argv) } lttng_consumer_set_error_sock(ctx, ret); + /* metadata socket only for UST */ + if (*metadata_sock_path != '\0') { + /* Connect to the socket created by lttng-sessiond to ask metadata */ + DBG("Connecting to error socket %s", metadata_sock_path); + ret = lttcomm_connect_unix_sock(metadata_sock_path); + /* not a fatal error, but all communication with lttng-sessiond will fail */ + if (ret < 0) { + WARN("Cannot connect to metadata socket (is lttng-sessiond started?)"); + } + lttng_consumer_set_metadata_sock(ctx, ret); + } + + /* + * for UST consumer, we block RT signals used for periodical + * metadata flush in main and create a dedicated thread + * to handle these signals. + */ + if (opt_type != LTTNG_CONSUMER_KERNEL) { + consumer_signal_init(); + } + /* Create thread to manage channels */ ret = pthread_create(&channel_thread, NULL, consumer_thread_channel_poll, (void *) ctx); @@ -395,6 +428,22 @@ int main(int argc, char **argv) goto sessiond_error; } + if (opt_type != LTTNG_CONSUMER_KERNEL) { + /* Create the thread to manage the metadata periodic timers */ + ret = pthread_create(&metadata_timer_thread, NULL, consumer_thread_metadata_timer, + (void *) ctx); + if (ret != 0) { + perror("pthread_create"); + goto metadata_timer_error; + } + ret = pthread_detach(metadata_timer_thread); + if (ret) { + errno = ret; + perror("pthread_detach"); + } + } + +metadata_timer_error: ret = pthread_join(sessiond_thread, &status); if (ret != 0) { perror("pthread_join"); diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 57b5b19..ff3dde2 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -1107,17 +1107,19 @@ int consumer_push_metadata(struct consumer_socket *socket, goto end; } - DBG3("Consumer pushing metadata on sock %d of len %lu", socket->fd, len); + if (len > 0) { + DBG3("Consumer pushing metadata on sock %d of len %lu", socket->fd, len); - ret = lttcomm_send_unix_sock(socket->fd, metadata_str, len); - if (ret < 0) { - goto end; - } + ret = lttcomm_send_unix_sock(socket->fd, metadata_str, len); + if (ret < 0) { + goto end; + } - health_code_update(); - ret = consumer_recv_status_reply(socket); - if (ret < 0) { - goto end; + health_code_update(); + ret = consumer_recv_status_reply(socket); + if (ret < 0) { + goto end; + } } end: diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index cde2d0d..01e96fe 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -84,6 +84,10 @@ struct consumer_data { char err_unix_sock_path[PATH_MAX]; char cmd_unix_sock_path[PATH_MAX]; + /* metadata socket to ask UST metadata to the sessiond */ + char metadata_unix_sock_path[PATH_MAX]; + int metadata_sock; + /* communication lock */ pthread_mutex_t lock; }; diff --git a/src/bin/lttng-sessiond/lttng-ust-ctl.h b/src/bin/lttng-sessiond/lttng-ust-ctl.h index 7f59b86..cea35ba 100644 --- a/src/bin/lttng-sessiond/lttng-ust-ctl.h +++ b/src/bin/lttng-sessiond/lttng-ust-ctl.h @@ -50,6 +50,7 @@ struct ustctl_consumer_channel_attr { int overwrite; /* 1: overwrite, 0: discard */ unsigned int switch_timer_interval; /* usec */ unsigned int read_timer_interval; /* usec */ + timer_t read_timer; /* timer ID */ enum lttng_ust_output output; /* splice, mmap */ uint32_t chan_id; /* channel ID */ unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index d88bafe..8d5b38a 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,7 @@ static struct consumer_data kconsumer_data = { .cmd_unix_sock_path = DEFAULT_KCONSUMERD_CMD_SOCK_PATH, .err_sock = -1, .cmd_sock = -1, + .metadata_sock = -1, .pid_mutex = PTHREAD_MUTEX_INITIALIZER, .lock = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, @@ -98,8 +100,10 @@ static struct consumer_data ustconsumer64_data = { .type = LTTNG_CONSUMER64_UST, .err_unix_sock_path = DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH, .cmd_unix_sock_path = DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH, + .metadata_unix_sock_path = DEFAULT_USTCONSUMERD64_META_SOCK_PATH, .err_sock = -1, .cmd_sock = -1, + .metadata_sock = -1, .pid_mutex = PTHREAD_MUTEX_INITIALIZER, .lock = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, @@ -109,8 +113,10 @@ static struct consumer_data ustconsumer32_data = { .type = LTTNG_CONSUMER32_UST, .err_unix_sock_path = DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH, .cmd_unix_sock_path = DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH, + .metadata_unix_sock_path = DEFAULT_USTCONSUMERD32_META_SOCK_PATH, .err_sock = -1, .cmd_sock = -1, + .metadata_sock = -1, .pid_mutex = PTHREAD_MUTEX_INITIALIZER, .lock = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, @@ -857,6 +863,8 @@ static void *thread_manage_consumer(void *data) enum lttcomm_return_code code; struct lttng_poll_event events; struct consumer_data *consumer_data = data; + int metadata_sock_fd; + struct consumer_socket *metadata_sock = NULL; DBG("[thread] Manage consumer started"); @@ -865,10 +873,11 @@ static void *thread_manage_consumer(void *data) health_code_update(); /* - * Pass 2 as size here for the thread quit pipe and kconsumerd_err_sock. + * Pass 3 as size here for the thread quit pipe, kconsumerd_err_sock + * and the metadata_sock. * Nothing more will be added to this poll set. */ - ret = sessiond_set_thread_pollset(&events, 2); + ret = sessiond_set_thread_pollset(&events, 3); if (ret < 0) { goto error_poll; } @@ -884,8 +893,9 @@ static void *thread_manage_consumer(void *data) } health_code_update(); + metadata_sock_fd = -1; - /* Inifinite blocking call, waiting for transmission */ + /* Infinite blocking call, waiting for transmission */ restart: health_poll_entry(); @@ -982,60 +992,132 @@ restart: goto error; } - health_code_update(); - - /* Inifinite blocking call, waiting for transmission */ -restart_poll: - health_poll_entry(); - ret = lttng_poll_wait(&events, -1); - health_poll_exit(); + /* + * The metadata socket here is already in a listening state which was done + * just before spawning this thread to avoid a race between the consumer + * daemon exec trying to connect and the listen() call. + */ + ret = lttng_poll_add(&events, consumer_data->metadata_sock, LPOLLIN | LPOLLRDHUP); if (ret < 0) { - /* - * Restart interrupted system call. - */ - if (errno == EINTR) { - goto restart_poll; - } goto error; } - nb_fd = ret; + health_code_update(); - for (i = 0; i < nb_fd; i++) { - /* Fetch once the poll data */ - revents = LTTNG_POLL_GETEV(&events, i); - pollfd = LTTNG_POLL_GETFD(&events, i); + /* Infinite blocking call, waiting for transmission */ +restart_poll: + while (1) { + health_poll_entry(); + ret = lttng_poll_wait(&events, -1); + health_poll_exit(); + if (ret < 0) { + /* + * Restart interrupted system call. + */ + if (errno == EINTR) { + goto restart_poll; + } + goto error; + } - health_code_update(); + nb_fd = ret; - /* Thread quit pipe has been closed. Killing thread. */ - ret = sessiond_check_thread_quit_pipe(pollfd, revents); - if (ret) { - err = 0; - goto exit; - } + for (i = 0; i < nb_fd; i++) { + /* Fetch once the poll data */ + revents = LTTNG_POLL_GETEV(&events, i); + pollfd = LTTNG_POLL_GETFD(&events, i); - /* Event on the kconsumerd socket */ - if (pollfd == sock) { - if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { - ERR("consumer err socket second poll error"); - goto error; + health_code_update(); + + /* Thread quit pipe has been closed. Killing thread. */ + ret = sessiond_check_thread_quit_pipe(pollfd, revents); + if (ret) { + err = 0; + goto exit; } - } - } - health_code_update(); + if (pollfd == sock) { + /* Event on the kconsumerd socket */ + if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { + ERR("consumer err socket second poll error"); + goto error; + } + health_code_update(); + /* Wait for any kconsumerd error */ + ret = lttcomm_recv_unix_sock(sock, &code, + sizeof(enum lttcomm_return_code)); + if (ret <= 0) { + ERR("consumer closed the command socket"); + goto error; + } - /* Wait for any kconsumerd error */ - ret = lttcomm_recv_unix_sock(sock, &code, - sizeof(enum lttcomm_return_code)); - if (ret <= 0) { - ERR("consumer closed the command socket"); - goto error; - } + ERR("consumer return code : %s", + lttcomm_get_readable_code(-code)); - ERR("consumer return code : %s", lttcomm_get_readable_code(-code)); + goto exit; + } else if (pollfd == consumer_data->metadata_sock) { + /* first connection on consumer_data->metadata_sock */ + metadata_sock_fd = + lttcomm_accept_unix_sock( + consumer_data->metadata_sock); + if (metadata_sock_fd < 0) { + goto error; + } + DBG("Metadata socket (fd: %d)", metadata_sock_fd); + metadata_sock = consumer_allocate_socket(metadata_sock_fd); + if (metadata_sock == NULL) { + ret = -1; + goto error; + } + metadata_sock->lock = zmalloc(sizeof(pthread_mutex_t)); + if (metadata_sock->lock == NULL) { + PERROR("zmalloc pthread mutex"); + ret = -1; + goto error_free_sock; + } + pthread_mutex_init(metadata_sock->lock, NULL); + + /* + * Set the CLOEXEC flag. Return code is + * useless because either way, the + * show must go on. + */ + (void) utils_set_fd_cloexec(metadata_sock_fd); + + /* + * Remove the consumerd metadata sock since + * we've established a connexion + */ + ret = lttng_poll_del(&events, + consumer_data->metadata_sock); + if (ret < 0) { + goto error_free_sock; + } + + ret = lttng_poll_add(&events, metadata_sock_fd, + LPOLLIN | LPOLLRDHUP); + if (ret < 0) { + goto error_free_sock; + } + break; + } else if (pollfd == metadata_sock_fd) { + /* UST metadata requests */ + ret = ust_consumer_metadata_request(metadata_sock); + if (ret < 0) { + ERR("Handling metadata request"); + goto error_free_sock; + } + break; + } else { + ERR("Unknown pollfd"); + goto error_free_sock; + } + } + health_code_update(); + } +error_free_sock: + consumer_destroy_socket(metadata_sock); exit: error: /* Immediately set the consumerd state to stopped */ @@ -1061,6 +1143,12 @@ error: PERROR("close"); } } + if (consumer_data->metadata_sock >= 0) { + ret = close(consumer_data->metadata_sock); + if (ret) { + PERROR("close"); + } + } if (sock >= 0) { ret = close(sock); if (ret) { @@ -1070,6 +1158,7 @@ error: unlink(consumer_data->err_unix_sock_path); unlink(consumer_data->cmd_unix_sock_path); + unlink(consumer_data->metadata_unix_sock_path); consumer_data->pid = 0; lttng_poll_clean(&events); @@ -1893,6 +1982,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) ret = execl(consumerd64_bin, "lttng-consumerd", verbosity, "-u", "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path, "--consumerd-err-sock", consumer_data->err_unix_sock_path, + "--consumerd-metadata-sock", consumer_data->metadata_unix_sock_path, NULL); if (consumerd64_libdir[0] != '\0') { free(tmpnew); @@ -1938,6 +2028,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) ret = execl(consumerd32_bin, "lttng-consumerd", verbosity, "-u", "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path, "--consumerd-err-sock", consumer_data->err_unix_sock_path, + "--consumerd-metadata-sock", consumer_data->metadata_unix_sock_path, NULL); if (consumerd32_libdir[0] != '\0') { free(tmpnew); @@ -1981,6 +2072,10 @@ static int start_consumerd(struct consumer_data *consumer_data) if (ret < 0) { goto error; } + ret = lttcomm_listen_unix_sock(consumer_data->metadata_sock); + if (ret < 0) { + goto error; + } pthread_mutex_lock(&consumer_data->pid_mutex); if (consumer_data->pid != 0) { @@ -2011,7 +2106,7 @@ end: return 0; error: - /* Cleanup already created socket on error. */ + /* Cleanup already created sockets on error. */ if (consumer_data->err_sock >= 0) { int err; @@ -2020,6 +2115,14 @@ error: PERROR("close consumer data error socket"); } } + if (consumer_data->metadata_sock >= 0) { + int err; + + err = close(consumer_data->metadata_sock); + if (err < 0) { + PERROR("close consumer metadata socket"); + } + } return ret; } @@ -3846,6 +3949,28 @@ static int set_consumer_sockets(struct consumer_data *consumer_data, goto error; } + if (consumer_data->type != LTTNG_CONSUMER_KERNEL) { + /* Create the consumerd metadata unix socket for UST */ + consumer_data->metadata_sock = + lttcomm_create_unix_sock(consumer_data->metadata_unix_sock_path); + if (consumer_data->metadata_sock < 0) { + ERR("Create unix sock failed: %s", + consumer_data->metadata_unix_sock_path); + ret = -1; + goto error; + } + + /* File permission MUST be 660 */ + ret = chmod(consumer_data->metadata_unix_sock_path, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + if (ret < 0) { + ERR("Set file permissions failed: %s", + consumer_data->metadata_unix_sock_path); + PERROR("chmod"); + goto error; + } + } + error: return ret; } @@ -4119,22 +4244,30 @@ int main(int argc, char **argv) DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH, rundir); snprintf(ustconsumer32_data.cmd_unix_sock_path, PATH_MAX, DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH, rundir); + snprintf(ustconsumer32_data.metadata_unix_sock_path, PATH_MAX, + DEFAULT_USTCONSUMERD32_META_SOCK_PATH, rundir); DBG2("UST consumer 32 bits err path: %s", ustconsumer32_data.err_unix_sock_path); DBG2("UST consumer 32 bits cmd path: %s", ustconsumer32_data.cmd_unix_sock_path); + DBG2("UST consumer 32 bits metadata path: %s", + ustconsumer32_data.metadata_unix_sock_path); /* 64 bits consumerd path setup */ snprintf(ustconsumer64_data.err_unix_sock_path, PATH_MAX, DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH, rundir); snprintf(ustconsumer64_data.cmd_unix_sock_path, PATH_MAX, DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH, rundir); + snprintf(ustconsumer64_data.metadata_unix_sock_path, PATH_MAX, + DEFAULT_USTCONSUMERD64_META_SOCK_PATH, rundir); DBG2("UST consumer 64 bits err path: %s", ustconsumer64_data.err_unix_sock_path); DBG2("UST consumer 64 bits cmd path: %s", ustconsumer64_data.cmd_unix_sock_path); + DBG2("UST consumer 64 bits metadata path: %s", + ustconsumer64_data.metadata_unix_sock_path); /* * See if daemon already exist. diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 979ae7c..2250d0f 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -370,11 +371,15 @@ void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan, /* * For a given application and session, push metadata to consumer. The session * lock MUST be acquired here before calling this. + * Either sock or consumer is required : if sock is NULL, the default + * socket to send the metadata is retrieved from consumer, if sock + * is not NULL we use it to send the metadata. * * Return 0 on success else a negative error. */ -static int push_metadata(struct ust_registry_session *registry, - struct consumer_output *consumer) +int ust_app_push_metadata(struct ust_registry_session *registry, + struct consumer_output *consumer, + struct consumer_socket *sock) { int ret; char *metadata_str = NULL; @@ -382,7 +387,12 @@ static int push_metadata(struct ust_registry_session *registry, struct consumer_socket *socket; assert(registry); - assert(consumer); + if (consumer == NULL) { + assert(sock); + } + if (sock == NULL) { + assert(consumer); + } rcu_read_lock(); @@ -395,12 +405,16 @@ static int push_metadata(struct ust_registry_session *registry, goto error_rcu_unlock; } - /* Get consumer socket to use to push the metadata.*/ - socket = consumer_find_socket_by_bitness(registry->bits_per_long, - consumer); - if (!socket) { - ret = -1; - goto error_rcu_unlock; + if (sock == NULL) { + /* Get consumer socket to use to push the metadata.*/ + socket = consumer_find_socket_by_bitness(registry->bits_per_long, + consumer); + if (!socket) { + ret = -1; + goto error_rcu_unlock; + } + } else { + socket = sock; } /* @@ -527,7 +541,7 @@ void delete_ust_app_session(int sock, struct ust_app_session *ua_sess, registry = get_session_registry(ua_sess); if (registry) { /* Push metadata for application before freeing the application. */ - (void) push_metadata(registry, ua_sess->consumer); + (void) ust_app_push_metadata(registry, ua_sess->consumer, NULL); /* * Don't ask to close metadata for global per UID buffers. Close @@ -2770,7 +2784,7 @@ void ust_app_unregister(int sock) registry = get_session_registry(ua_sess); if (registry) { /* Push metadata for application before freeing the application. */ - (void) push_metadata(registry, ua_sess->consumer); + (void) ust_app_push_metadata(registry, ua_sess->consumer, NULL); /* * Don't ask to close metadata for global per UID buffers. Close @@ -3682,7 +3696,7 @@ int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app) registry = get_session_registry(ua_sess); assert(registry); /* Push metadata for application before freeing the application. */ - (void) push_metadata(registry, ua_sess->consumer); + (void) ust_app_push_metadata(registry, ua_sess->consumer, NULL); pthread_mutex_unlock(&ua_sess->lock); end_no_session: diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 67088a7..32fb0fa 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -300,6 +300,10 @@ void ust_app_add(struct ust_app *app); struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock); void ust_app_notify_sock_unregister(int sock); +int ust_app_push_metadata(struct ust_registry_session *registry, + struct consumer_output *consumer, + struct consumer_socket *sock); + #else /* HAVE_LIBLTTNG_UST_CTL */ static inline diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index ba74112..cf62553 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -30,6 +30,8 @@ #include "consumer.h" #include "health.h" #include "ust-consumer.h" +#include "buffer-registry.h" +#include "session.h" /* * Return allocated full pathname of the session using the consumer trace path @@ -405,3 +407,93 @@ int ust_consumer_send_channel_to_ust(struct ust_app *app, error: return ret; } + +/* + * Handle the metadata requests from the UST consumer + */ +int ust_consumer_metadata_request(struct consumer_socket *sock) +{ + int ret; + struct lttcomm_metadata request; + struct buffer_reg_uid *reg_uid; + struct buffer_reg_pid *reg_pid; + struct ust_registry_session *ust_reg; + struct lttcomm_consumer_msg msg; + uint64_t len; + + /* Wait for a metadata request */ + ret = lttcomm_recv_unix_sock(sock->fd, &request, + sizeof(struct lttcomm_metadata)); + if (ret <= 0) { + ERR("consumer closed the metadata socket"); + ret = -1; + goto end; + } + + switch (request.command) { + case LTTCOMM_METADATA_REQUEST: + DBG("Metadata request received for session %u, key %" PRIu64, + request.u.metadata_request.session_id, + request.u.metadata_request.key); + + rcu_read_lock(); + reg_uid = buffer_reg_uid_find(request.u.metadata_request.session_id, + request.u.metadata_request.bits_per_long, + request.u.metadata_request.uid); + if (reg_uid) { + ust_reg = reg_uid->registry->reg.ust; + } else { + reg_pid = buffer_reg_pid_find( + request.u.metadata_request.session_id); + if (!reg_pid) { + DBG("Registry not found"); + + msg.cmd_type = LTTNG_ERR_UND; + ret = consumer_send_msg(sock, &msg); + if (ret < 0) { + ERR("Sending registry not found to consumer"); + } + goto end_unlock; + } + ust_reg = reg_pid->registry->reg.ust; + } + + pthread_mutex_lock(&ust_reg->lock); + len = ust_reg->metadata_len - ust_reg->metadata_len_sent; + pthread_mutex_unlock(&ust_reg->lock); + + if (len == 0) { + DBG("No metadata to push"); + + pthread_mutex_lock(sock->lock); + ret = consumer_push_metadata(sock, + request.u.metadata_request.key, + NULL, len, 0); + if (ret < 0) { + ERR("Sending len = 0 to consumer"); + } + pthread_mutex_unlock(sock->lock); + goto end_unlock; + } + + session_lock_list(); + ret = ust_app_push_metadata(ust_reg, NULL, sock); + if (ret < 0) { + ERR("Pushing metadata"); + session_unlock_list(); + goto end_unlock; + } + session_unlock_list(); + DBG("Pushed metadata"); + break; + default: + ERR("Unknown metadata request message"); + ret = -1; + goto end; + } + +end_unlock: + rcu_read_unlock(); +end: + return ret; +} diff --git a/src/bin/lttng-sessiond/ust-consumer.h b/src/bin/lttng-sessiond/ust-consumer.h index f5f63d9..d378202 100644 --- a/src/bin/lttng-sessiond/ust-consumer.h +++ b/src/bin/lttng-sessiond/ust-consumer.h @@ -36,5 +36,6 @@ int ust_consumer_send_stream_to_ust(struct ust_app *app, int ust_consumer_send_channel_to_ust(struct ust_app *app, struct ust_app_session *ua_sess, struct ust_app_channel *channel); +int ust_consumer_metadata_request(struct consumer_socket *sock); #endif /* _UST_CONSUMER_H */ diff --git a/src/common/Makefile.am b/src/common/Makefile.am index c3a947a..f90a132 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -6,7 +6,8 @@ SUBDIRS = compat hashtable kernel-ctl sessiond-comm relayd \ AM_CFLAGS = -fno-strict-aliasing noinst_HEADERS = lttng-kernel.h defaults.h macros.h error.h futex.h \ - uri.h utils.h lttng-kernel-old.h + uri.h utils.h lttng-kernel-old.h \ + consumer-metadata-cache.h # Common library noinst_LTLIBRARIES = libcommon.la @@ -18,7 +19,7 @@ libcommon_la_LIBADD = -luuid # Consumer library noinst_LTLIBRARIES += libconsumer.la -libconsumer_la_SOURCES = consumer.c consumer.h +libconsumer_la_SOURCES = consumer.c consumer.h consumer-metadata-cache.c libconsumer_la_LIBADD = \ $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \ diff --git a/src/common/consumer-metadata-cache.c b/src/common/consumer-metadata-cache.c new file mode 100644 index 0000000..f794c92 --- /dev/null +++ b/src/common/consumer-metadata-cache.c @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2013 - Julien Desfossez + * David Goulet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "consumer-metadata-cache.h" + +#ifndef max_t +#define max_t(type, a, b) ((type) ((a) > (b) ? (a) : (b))) +#endif + + +/* + * Extend the allocated size of the metadata cache. + * Called only from lttng_ustconsumer_write_metadata_cache. + * + * Return 0 on success, a negative value on error. + */ +int lttng_consumer_extend_metadata_cache(struct lttng_consumer_channel *channel, + unsigned int size) +{ + int ret = 0; + char *tmp_data_ptr; + unsigned int new_size; + + assert(channel); + assert(channel->metadata_cache); + + new_size = max_t(unsigned int, + channel->metadata_cache->cache_alloc_size + size, + channel->metadata_cache->cache_alloc_size << 1); + DBG("Extending metadata cache to %u", new_size); + tmp_data_ptr = realloc(channel->metadata_cache->data, new_size); + if (!tmp_data_ptr) { + ERR("Reallocating metadata cache"); + free(channel->metadata_cache->data); + ret = -1; + goto end; + } + channel->metadata_cache->data = tmp_data_ptr; + channel->metadata_cache->cache_alloc_size = new_size; + +end: + return ret; +} + +/* + * Write metadata to the cache, extend the cache if necessary. + * We support non-contiguous updates but not overlapping ones. + * If there is contiguous metadata in the cache, we send it to the ring buffer. + * The metadata cache lock MUST be acquired to write in the cache. + * + * Return 0 on success, a negative value on error. + */ +int lttng_consumer_write_metadata_cache(struct lttng_consumer_channel *channel, + unsigned int offset, unsigned int len, char *data) +{ + int ret = 0; + struct lttng_consumer_metadata_cache *cache; + + assert(channel); + assert(channel->metadata_cache); + + cache = channel->metadata_cache; + DBG("Writing %u bytes from offset %u in metadata cache", + len, offset); + + if (offset + len > cache->cache_alloc_size) { + ret = lttng_consumer_extend_metadata_cache(channel, + len - cache->cache_alloc_size + offset); + if (ret < 0) { + ERR("Extending metadata cache"); + goto end; + } + } + + memcpy(cache->data + offset, data, len); + cache->total_bytes_written += len; + if (offset + len > cache->max_offset) { + cache->max_offset = offset + len; + } + + if (cache->max_offset == cache->total_bytes_written) { + offset = cache->rb_pushed; + len = cache->total_bytes_written - cache->rb_pushed; + ret = lttng_ustconsumer_push_metadata(channel, cache->data, offset, len); + if (ret < 0) { + ERR("Pushing metadata"); + goto end; + } + } + +end: + return ret; +} + +/* + * Create the metadata cache, original allocated size : max_sb_size + * + * Return 0 on success, a negative value on error. + */ +int lttng_consumer_allocate_metadata_cache(struct lttng_consumer_channel *channel) +{ + int ret; + + channel->metadata_cache = zmalloc(sizeof(struct lttng_consumer_metadata_cache)); + if (!channel->metadata_cache) { + PERROR("zmalloc metadata cache struct"); + ret = -1; + goto end; + } + ret = pthread_mutex_init(&channel->metadata_cache->lock, NULL); + if (ret != 0) { + PERROR("mutex init"); + goto end_free_cache; + } + + channel->metadata_cache->cache_alloc_size = + DEFAULT_METADATA_CACHE_SIZE; + channel->metadata_cache->data = zmalloc( + channel->metadata_cache->cache_alloc_size * sizeof(char)); + if (!channel->metadata_cache->data) { + PERROR("zmalloc metadata cache data"); + ret = -1; + goto end_free_mutex; + } + DBG("Allocated metadata cache of %" PRIu64 " bytes", + channel->metadata_cache->cache_alloc_size); + + ret = 0; + goto end; + +end_free_mutex: + pthread_mutex_destroy(&channel->metadata_cache->lock); +end_free_cache: + free(channel->metadata_cache); +end: + return ret; +} + +/* + * Destroy and free the metadata cache + */ +void lttng_consumer_destroy_metadata_cache(struct lttng_consumer_channel *channel) +{ + if (!channel || !channel->metadata_cache) { + return; + } + DBG("Destroying metadata cache"); + + if (channel->metadata_cache->max_offset > + channel->metadata_cache->rb_pushed) { + ERR("Destroying a cache not entirely commited"); + } + pthread_mutex_destroy(&channel->metadata_cache->lock); + free(channel->metadata_cache->data); + free(channel->metadata_cache); +} + +/* + * Check if the cache is flushed up to the offset passed in parameter. + * + * Return 0 if everything has been flushed, 1 if there is data not flushed. + */ +int lttng_consumer_flushed_cache(struct lttng_consumer_channel *channel, + uint64_t offset) +{ + struct lttng_consumer_metadata_cache *cache; + int ret; + + assert(channel); + assert(channel->metadata_cache); + + cache = channel->metadata_cache; + + pthread_mutex_lock(&channel->metadata_cache->lock); + if (cache->rb_pushed >= offset) { + ret = 0; + } else { + ret = 1; + } + pthread_mutex_unlock(&channel->metadata_cache->lock); + + return ret; +} diff --git a/src/common/consumer-metadata-cache.h b/src/common/consumer-metadata-cache.h new file mode 100644 index 0000000..fe0d833 --- /dev/null +++ b/src/common/consumer-metadata-cache.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2013 - Julien Desfossez + * David Goulet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef METADATA_CACHE_H +#define METADATA_CACHE_H + +#include + +int lttng_consumer_extend_metadata_cache( + struct lttng_consumer_channel *channel, + unsigned int size); +int lttng_consumer_write_metadata_cache( + struct lttng_consumer_channel *channel, + unsigned int offset, unsigned int len, char *data); +int lttng_consumer_allocate_metadata_cache(struct lttng_consumer_channel *channel); +void lttng_consumer_destroy_metadata_cache(struct lttng_consumer_channel *channel); +int lttng_consumer_flushed_cache(struct lttng_consumer_channel *channel, + uint64_t offset); +#endif /* METADATA_CACHE_H */ diff --git a/src/common/consumer.c b/src/common/consumer.c index 29bd0c0..d739839 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1006,6 +1007,15 @@ void lttng_consumer_set_command_sock_path( } /* + * Set the metadata socket. + */ +void lttng_consumer_set_metadata_sock(struct lttng_consumer_local_data *ctx, + int sock) +{ + ctx->consumer_metadata_socket = sock; +} + +/* * Send return code to the session daemon. * If the socket is not defined, we return 0, it is not a fatal error */ @@ -1141,6 +1151,7 @@ struct lttng_consumer_local_data *lttng_consumer_create( } ctx->consumer_error_socket = -1; + ctx->consumer_metadata_socket = -1; /* assign the callbacks */ ctx->on_buffer_ready = buffer_ready; ctx->on_recv_channel = recv_channel; @@ -1227,6 +1238,10 @@ void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx) if (ret) { PERROR("close"); } + ret = close(ctx->consumer_metadata_socket); + if (ret) { + PERROR("close"); + } utils_close_pipe(ctx->consumer_thread_pipe); utils_close_pipe(ctx->consumer_channel_pipe); utils_close_pipe(ctx->consumer_data_pipe); @@ -1328,6 +1343,7 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap( goto end; } ret = lttng_ustctl_get_mmap_read_offset(stream, &mmap_offset); + break; default: ERR("Unknown consumer_data type"); diff --git a/src/common/consumer.h b/src/common/consumer.h index 82b9bc6..5aff6b5 100644 --- a/src/common/consumer.h +++ b/src/common/consumer.h @@ -32,6 +32,10 @@ #include #include +#define LTTNG_CONSUMER_SIG_SWITCH SIGRTMIN + 10 +#define LTTNG_CONSUMER_SIG_TEARDOWN SIGRTMIN + 11 +#define CLOCKID CLOCK_MONOTONIC + /* Commands for consumer */ enum lttng_consumer_command { LTTNG_CONSUMER_ADD_CHANNEL, @@ -89,6 +93,33 @@ struct stream_list { unsigned int count; }; +struct lttng_consumer_metadata_cache { + char *data; + uint64_t cache_alloc_size; + /* + * How many bytes from the cache were already sent to + * the ring buffer + */ + uint64_t rb_pushed; + /* + * How many bytes are written in the buffer (excluding the wholes) + */ + uint64_t total_bytes_written; + /* + * The upper-limit of data written inside the buffer. + * + * With the total_bytes_written it allows us to keep track of when the + * cache contains contiguous metadata ready to be sent to the RB. + * The metadata cache updates must not overlap. + */ + uint64_t max_offset; + /* + * Lock to update the metadata cache and push into the + * ring_buffer (ustctl_write_metadata_to_channel) + */ + pthread_mutex_t lock; +}; + struct lttng_consumer_channel { /* HT node used for consumer_data.channel_ht */ struct lttng_ht_node_u64 node; @@ -132,16 +163,17 @@ struct lttng_consumer_channel { * regular channel, this is always set to NULL. */ struct lttng_consumer_stream *metadata_stream; - /* - * Metadata written so far. Helps keeping track of - * contiguousness and order. - */ - uint64_t contig_metadata_written; /* for UST */ int wait_fd; /* Node within channel thread ht */ struct lttng_ht_node_u64 wait_fd_node; + + /* Metadata cache is metadata channel */ + struct lttng_consumer_metadata_cache *metadata_cache; + /* For metadata periodical flush */ + int switch_timer_enabled; + timer_t switch_timer; }; /* @@ -324,6 +356,8 @@ struct lttng_consumer_local_data { int (*on_update_stream)(int sessiond_key, uint32_t state); /* socket to communicate errors with sessiond */ int consumer_error_socket; + /* socket to ask metadata to sessiond */ + int consumer_metadata_socket; /* socket to exchange commands with sessiond */ char *consumer_command_sock_path; /* communication with splice */ @@ -389,6 +423,19 @@ struct lttng_consumer_global_data { }; /* + * Handle timer teardown race wrt memory free of private data by + * consumer signals are handled by a single thread, which permits + * a synchronization point between handling of each signal. + */ +struct timer_signal_data { + pthread_t tid; /* thread id managing signals */ + int setup_done; + int qs_done; +}; + +struct timer_signal_data timer_signal; + +/* * Init consumer data structures. */ void lttng_consumer_init(void); @@ -406,6 +453,12 @@ void lttng_consumer_set_command_sock_path( struct lttng_consumer_local_data *ctx, char *sock); /* + * Set the socket to ask metadata to the sessiond + */ +void lttng_consumer_set_metadata_sock(struct lttng_consumer_local_data *ctx, + int sock); + +/* * Send return code to session daemon. * * Returns the return code of sendmsg : the number of bytes transmitted or -1 @@ -494,6 +547,7 @@ void *consumer_thread_metadata_poll(void *data); void *consumer_thread_data_poll(void *data); void *consumer_thread_sessiond_poll(void *data); void *consumer_thread_channel_poll(void *data); +void *consumer_thread_metadata_timer(void *data); int lttng_consumer_recv_cmd(struct lttng_consumer_local_data *ctx, int sock, struct pollfd *consumer_sockpoll); @@ -510,5 +564,6 @@ int consumer_data_pending(uint64_t id); int consumer_send_status_msg(int sock, int ret_code); int consumer_send_status_channel(int sock, struct lttng_consumer_channel *channel); +void consumer_signal_init(void); #endif /* LIB_CONSUMER_H */ diff --git a/src/common/defaults.h b/src/common/defaults.h index 658e7d3..5271181 100644 --- a/src/common/defaults.h +++ b/src/common/defaults.h @@ -70,11 +70,13 @@ #define DEFAULT_USTCONSUMERD64_PATH DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd64" #define DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH DEFAULT_USTCONSUMERD64_PATH "/command" #define DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH DEFAULT_USTCONSUMERD64_PATH "/error" +#define DEFAULT_USTCONSUMERD64_META_SOCK_PATH DEFAULT_USTCONSUMERD64_PATH "/metadata" /* UST 32-bit consumer path */ #define DEFAULT_USTCONSUMERD32_PATH DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd32" #define DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/command" #define DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/error" +#define DEFAULT_USTCONSUMERD32_META_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/metadata" /* Default lttng run directory */ @@ -124,6 +126,7 @@ #define DEFAULT_METADATA_SUBBUF_SIZE 4096 #define DEFAULT_METADATA_SUBBUF_NUM 2 +#define DEFAULT_METADATA_CACHE_SIZE 4096 /* Kernel has different defaults */ @@ -179,6 +182,12 @@ #define DEFAULT_DATA_AVAILABILITY_WAIT_TIME 200000 /* usec */ /* + * Wait period before retrying the lttng_consumer_flushed_cache when + * the consumer receives metadata. + */ +#define DEFAULT_METADATA_AVAILABILITY_WAIT_TIME 200000 /* usec */ + +/* * Default receiving and sending timeout for an application socket. */ #define DEFAULT_APP_SOCKET_RW_TIMEOUT 5 /* sec */ diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 6350fd1..eb0df5e 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -138,6 +138,26 @@ enum lttcomm_sock_domain { LTTCOMM_INET6 = 1, }; +enum lttcomm_metadata_command { + LTTCOMM_METADATA_REQUEST = 1, +}; + +/* + * Commands sent from the consumerd to the sessiond to request + * if new metadata is available + */ +struct lttcomm_metadata { + enum lttcomm_metadata_command command; + union { + struct { + unsigned int session_id; /* Tracing session id */ + uint32_t bits_per_long; /* Consumer ABI */ + uint32_t uid; + uint64_t key; /* Metadata channel key. */ + } LTTNG_PACKED metadata_request; + } u; +} LTTNG_PACKED; + struct lttcomm_sockaddr { enum lttcomm_sock_domain type; union { diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 06b59c5..108e18b 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -30,11 +30,13 @@ #include #include #include +#include #include #include #include #include +#include #include "ust-consumer.h" @@ -530,10 +532,12 @@ error: /* * Write metadata to the given channel using ustctl to convert the string to * the ringbuffer. + * Called only from lttng_consumer_write_metadata_cache. + * The metadata cache lock MUST be acquired to write in the cache. * * Return 0 on success else a negative value. */ -static int push_metadata(struct lttng_consumer_channel *metadata, +int lttng_ustconsumer_push_metadata(struct lttng_consumer_channel *metadata, const char *metadata_str, uint64_t target_offset, uint64_t len) { int ret; @@ -543,13 +547,13 @@ static int push_metadata(struct lttng_consumer_channel *metadata, DBG("UST consumer writing metadata to channel %s", metadata->name); - assert(target_offset == metadata->contig_metadata_written); + assert(target_offset <= metadata->metadata_cache->max_offset); ret = ustctl_write_metadata_to_channel(metadata->uchan, metadata_str, len); if (ret < 0) { ERR("ustctl write metadata fail with ret %d, len %ld", ret, len); goto error; } - metadata->contig_metadata_written += len; + metadata->metadata_cache->rb_pushed += len; ustctl_flush_buffer(metadata->metadata_stream->ustream, 1); @@ -557,6 +561,54 @@ error: return ret; } +static +void consumer_switch_timer_stop(struct lttng_consumer_channel *channel) +{ + sigset_t pending_set; + int ret; + + ret = timer_delete(channel->switch_timer); + if (ret == -1) { + PERROR("timer_delete"); + } + + /* + * Ensure we don't have any signal queued for this channel. + */ + for (;;) { + ret = sigemptyset(&pending_set); + if (ret == -1) { + PERROR("sigemptyset"); + } + ret = sigpending(&pending_set); + if (ret == -1) { + PERROR("sigpending"); + } + if (!sigismember(&pending_set, LTTNG_CONSUMER_SIG_SWITCH)) + break; + caa_cpu_relax(); + } + + /* + * From this point, no new signal handler will be fired that + * would try to access "chan". However, we still need to wait + * for any currently executing handler to complete. + */ + cmm_smp_mb(); + CMM_STORE_SHARED(timer_signal.qs_done, 0); + cmm_smp_mb(); + /* + * Kill with LTTNG_CONSUMER_SIG_TEARDOWN, so signal management + * thread wakes up. + */ + kill(getpid(), LTTNG_CONSUMER_SIG_TEARDOWN); + + while (!CMM_LOAD_SHARED(timer_signal.qs_done)) { + caa_cpu_relax(); + } + cmm_smp_mb(); +} + /* * Flush channel's streams using the given key to retrieve the channel. * @@ -619,6 +671,11 @@ static int close_metadata(uint64_t chan_key) ret = LTTCOMM_CONSUMERD_ERROR_METADATA; goto error; } + if (channel->switch_timer_enabled == 1) { + DBG("Deleting timer on metadata channel"); + consumer_switch_timer_stop(channel); + } + lttng_consumer_destroy_metadata_cache(channel); error: return ret; @@ -679,6 +736,88 @@ error: } /* + * Set the timer for periodical metadata flush + */ +static void consumer_switch_timer_start(struct lttng_consumer_channel *channel, + struct ustctl_consumer_channel_attr *attr) +{ + struct sigevent sev; + struct itimerspec its; + int ret; + + if (attr->switch_timer_interval == 0) { + return; + } + + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = LTTNG_CONSUMER_SIG_SWITCH; + sev.sigev_value.sival_ptr = channel; + ret = timer_create(CLOCKID, &sev, &channel->switch_timer); + if (ret == -1) { + PERROR("timer_create"); + } + channel->switch_timer_enabled = 1; + + its.it_value.tv_sec = attr->switch_timer_interval / 1000000; + its.it_value.tv_nsec = attr->switch_timer_interval % 1000000; + its.it_interval.tv_sec = its.it_value.tv_sec; + its.it_interval.tv_nsec = its.it_value.tv_nsec; + + ret = timer_settime(channel->switch_timer, 0, &its, NULL); + if (ret == -1) { + PERROR("timer_settime"); + } + attr->switch_timer_interval = 0; +} + +/* + * Receive the metadata updates from the sessiond. + */ +int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset, + uint64_t len, struct lttng_consumer_channel *channel) +{ + int ret, ret_code = LTTNG_OK; + char *metadata_str; + + DBG("UST consumer push metadata key %lu of len %lu", key, len); + + metadata_str = zmalloc(len * sizeof(char)); + if (!metadata_str) { + PERROR("zmalloc metadata string"); + ret_code = LTTCOMM_CONSUMERD_ENOMEM; + goto end; + } + + /* Receive metadata string. */ + ret = lttcomm_recv_unix_sock(sock, metadata_str, len); + if (ret < 0) { + /* Session daemon is dead so return gracefully. */ + ret_code = ret; + goto end_free; + } + + pthread_mutex_lock(&channel->metadata_cache->lock); + ret = lttng_consumer_write_metadata_cache(channel, offset, len, + metadata_str); + if (ret < 0) { + /* Unable to handle metadata. Notify session daemon. */ + ret_code = LTTCOMM_CONSUMERD_ERROR_METADATA; + } + pthread_mutex_unlock(&channel->metadata_cache->lock); + + while (lttng_consumer_flushed_cache(channel, offset + len)) { + DBG("Waiting for metadata to be flushed"); + usleep(DEFAULT_METADATA_AVAILABILITY_WAIT_TIME); + } + +end_free: + free(metadata_str); + +end: + return ret_code; +} + +/* * Receive command from session daemon and process it. * * Return 1 on success else a negative value or 0. @@ -847,6 +986,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, goto end_channel_error; } + /* * Channel and streams are now created. Inform the session daemon that * everything went well and should wait to receive the channel and @@ -861,6 +1001,15 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, goto end_nosignal; } + if (msg.u.ask_channel.type == LTTNG_UST_CHAN_METADATA) { + ret = lttng_consumer_allocate_metadata_cache(channel); + if (ret < 0) { + ERR("Allocating metadata cache"); + goto end_channel_error; + } + consumer_switch_timer_start(channel, &attr); + } + break; } case LTTNG_CONSUMER_GET_CHANNEL: @@ -957,10 +1106,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, { int ret; uint64_t len = msg.u.push_metadata.len; - uint64_t target_offset = msg.u.push_metadata.target_offset; uint64_t key = msg.u.push_metadata.key; + uint64_t offset = msg.u.push_metadata.target_offset; struct lttng_consumer_channel *channel; - char *metadata_str; DBG("UST consumer push metadata key %lu of len %lu", key, len); @@ -968,14 +1116,6 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, if (!channel) { ERR("UST consumer push metadata %lu not found", key); ret_code = LTTNG_ERR_UST_CHAN_NOT_FOUND; - goto end_msg_sessiond; - } - - metadata_str = zmalloc(len * sizeof(char)); - if (!metadata_str) { - PERROR("zmalloc metadata string"); - ret_code = LTTCOMM_CONSUMERD_ENOMEM; - goto end_msg_sessiond; } /* Tell session daemon we are ready to receive the metadata. */ @@ -990,22 +1130,15 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, goto end_nosignal; } - /* Receive metadata string. */ - ret = lttcomm_recv_unix_sock(sock, metadata_str, len); + ret = lttng_ustconsumer_recv_metadata(sock, key, offset, + len, channel); if (ret < 0) { - /* Session daemon is dead so return gracefully. */ + /* error receiving from sessiond */ goto end_nosignal; - } - - ret = push_metadata(channel, metadata_str, target_offset, len); - free(metadata_str); - if (ret < 0) { - /* Unable to handle metadata. Notify session daemon. */ - ret_code = LTTCOMM_CONSUMERD_ERROR_METADATA; + } else { + ret_code = ret; goto end_msg_sessiond; } - - goto end_msg_sessiond; } case LTTNG_CONSUMER_SETUP_METADATA: { @@ -1223,6 +1356,7 @@ int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream, } err = ustctl_put_next_subbuf(ustream); assert(err == 0); + end: return ret; } @@ -1343,3 +1477,188 @@ void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream) ERR("Unable to close wakeup fd"); } } + +static void consumer_setmask(sigset_t *mask) +{ + int ret; + + ret = sigemptyset(mask); + if (ret) { + PERROR("sigemptyset"); + } + ret = sigaddset(mask, LTTNG_CONSUMER_SIG_SWITCH); + if (ret) { + PERROR("sigaddset"); + } + ret = sigaddset(mask, LTTNG_CONSUMER_SIG_TEARDOWN); + if (ret) { + PERROR("sigaddset"); + } +} + +/* + * Block the RT signals for the entire process. It must be called + * from the consumer main before creating the threads + */ +void consumer_signal_init(void) +{ + sigset_t mask; + int ret; + + /* + * Block signal for entire process, so only our thread processes + * it. + */ + consumer_setmask(&mask); + ret = pthread_sigmask(SIG_BLOCK, &mask, NULL); + if (ret) { + errno = ret; + PERROR("pthread_sigmask"); + } +} + +static int sessiond_request_metadata(struct lttng_consumer_local_data *ctx, + struct lttng_consumer_channel *channel) +{ + struct lttcomm_metadata metadata_request; + struct lttcomm_consumer_msg msg; + enum lttng_error_code ret_code = LTTNG_OK; + uint64_t len, key, offset; + int ret; + + assert(channel); + assert(channel->metadata_cache); + + /* send the metadata request to sessiond */ + metadata_request.command = LTTCOMM_METADATA_REQUEST; + switch (consumer_data.type) { + case LTTNG_CONSUMER64_UST: + metadata_request.u.metadata_request.bits_per_long = 64; + break; + case LTTNG_CONSUMER32_UST: + metadata_request.u.metadata_request.bits_per_long = 32; + break; + default: + metadata_request.u.metadata_request.bits_per_long = 0; + break; + } + metadata_request.u.metadata_request.session_id = + channel->session_id; + metadata_request.u.metadata_request.uid = + channel->uid; + metadata_request.u.metadata_request.key = + channel->key; + DBG("Sending metadata request to sessiond, session %" PRIu64, + channel->session_id); + ret = lttcomm_send_unix_sock(ctx->consumer_metadata_socket, + &metadata_request, + sizeof(metadata_request)); + if (ret < 0) { + ERR("Asking metadata to sessiond"); + goto end; + } + + /* Receive the metadata from sessiond */ + ret = lttcomm_recv_unix_sock(ctx->consumer_metadata_socket, + &msg, sizeof(msg)); + if (ret != sizeof(msg)) { + DBG("Consumer received unexpected message size %d (expects %lu)", + ret, sizeof(msg)); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_CMD); + /* + * The ret value might 0 meaning an orderly shutdown but this is ok + * since the caller handles this. + */ + goto end; + } + if (msg.cmd_type == LTTNG_ERR_UND) { + /* No registry found */ + (void) consumer_send_status_msg(ctx->consumer_metadata_socket, + ret_code); + ret = 0; + goto end; + } else if (msg.cmd_type != LTTNG_CONSUMER_PUSH_METADATA) { + ERR("Unexpected cmd_type received %d", msg.cmd_type); + ret = -1; + goto end; + } + + len = msg.u.push_metadata.len; + key = msg.u.push_metadata.key; + offset = msg.u.push_metadata.target_offset; + + assert(key == channel->key); + if (len == 0) { + DBG("No new metadata to receive"); + ret = 0; + } + + /* Tell session daemon we are ready to receive the metadata. */ + ret = consumer_send_status_msg(ctx->consumer_metadata_socket, + LTTNG_OK); + if (ret < 0) { + /* Somehow, the session daemon is not responding anymore. */ + goto end; + } + + if (len > 0) { + ret_code = lttng_ustconsumer_recv_metadata( + ctx->consumer_metadata_socket, + key, offset, len, channel); + (void) consumer_send_status_msg(ctx->consumer_metadata_socket, + ret_code); + ret = 0; + } + +end: + return ret; +} + +static +void consumer_switch_timer(struct lttng_consumer_local_data *ctx, int sig, + siginfo_t *si, void *uc) +{ + struct lttng_consumer_channel *channel; + + channel = si->si_value.sival_ptr; + DBG("Switch timer for channel %" PRIu64, channel->key); + sessiond_request_metadata(ctx, channel); +} + +/* + * This thread is the sighandler for signals LTTNG_CONSUMER_SIG_SWITCH and + * LTTNG_CONSUMER_SIG_TEARDOWN that are emitted by the + * periodic timer to check if new metadata is available. + */ +void *consumer_thread_metadata_timer(void *data) +{ + sigset_t mask; + siginfo_t info; + int signr; + struct lttng_consumer_local_data *ctx = data; + + /* Only self thread will receive signal mask. */ + consumer_setmask(&mask); + CMM_STORE_SHARED(timer_signal.tid, pthread_self()); + + for (;;) { + signr = sigwaitinfo(&mask, &info); + if (signr == -1) { + if (errno != EINTR) + PERROR("sigwaitinfo"); + continue; + } + if (signr == LTTNG_CONSUMER_SIG_SWITCH) { + consumer_switch_timer(ctx, info.si_signo, + &info, NULL); + } else if (signr == LTTNG_CONSUMER_SIG_TEARDOWN) { + cmm_smp_mb(); + CMM_STORE_SHARED(timer_signal.qs_done, 1); + cmm_smp_mb(); + DBG("Signal teardown"); + } else { + ERR("Unexpected signal %d\n", info.si_signo); + } + } + return NULL; +} diff --git a/src/common/ust-consumer/ust-consumer.h b/src/common/ust-consumer/ust-consumer.h index bbaff6c..6011f8b 100644 --- a/src/common/ust-consumer/ust-consumer.h +++ b/src/common/ust-consumer/ust-consumer.h @@ -51,6 +51,10 @@ void *lttng_ustctl_get_mmap_base(struct lttng_consumer_stream *stream); int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream); void lttng_ustconsumer_close_metadata(struct lttng_ht *ht); void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream); +int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset, + uint64_t len, struct lttng_consumer_channel *channel); +int lttng_ustconsumer_push_metadata(struct lttng_consumer_channel *metadata, + const char *metadata_str, uint64_t target_offset, uint64_t len); #else /* HAVE_LIBLTTNG_UST_CTL */ diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index a9d65ab..76210f1 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -47,6 +47,7 @@ UST_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-ust.c \ $(top_srcdir)/src/bin/lttng-sessiond/ust-consumer.c \ $(top_srcdir)/src/bin/lttng-sessiond/fd-limit.c \ $(top_srcdir)/src/bin/lttng-sessiond/health.c \ + $(top_srcdir)/src/bin/lttng-sessiond/session.c \ $(top_srcdir)/src/common/uri.c \ $(top_srcdir)/src/common/utils.c -- 1.7.10.4 From mathieu.desnoyers at efficios.com Mon Mar 25 22:35:46 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Mon, 25 Mar 2013 22:35:46 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Fix: UST context activation Message-ID: <20130326023546.GA7176@Krystal> Signed-off-by: Mathieu Desnoyers --- diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index a83cb46..b55254b 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -262,7 +262,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, } /* Get UST channel if defined */ - if (channel_name != '\0') { + if (channel_name[0] != '\0') { uchan = trace_ust_find_channel_by_name(chan_ht, channel_name); if (uchan == NULL) { ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From barthelemy at crans.org Tue Mar 26 07:24:36 2013 From: barthelemy at crans.org (=?ISO-8859-1?Q?S=E9bastien_Barth=E9l=E9my?=) Date: Tue, 26 Mar 2013 12:24:36 +0100 Subject: [lttng-dev] TMF: inconsistencies in the context vtid reporting In-Reply-To: <514CCC2B.1040802@voxpopuli.im> References: <514CCC2B.1040802@voxpopuli.im> Message-ID: On Fri, Mar 22, 2013 at 10:24 PM, Alexandre Montplaisir wrote: > Hi S?bastien, > > On 13-03-22 06:02 AM, S?bastien Barth?l?my wrote: >> Hello, >> >> I'm using simultaneous kernel and userspace tracing in order to >> understand how a multi threaded application (mis)behaves at shutdown. >> >> The idea is to use userspace tracepoints in the application, augmented >> with the vtid context, in order to know which thread is calling what >> and to relate that with the threads lifespan as reconstructed from the >> kernel scheduler traces. >> >> First, is the approach ok? Am I right to expect the vtid attached to >> ust event to match the tid shown in the reconstructed kernel scheduler >> state? > > It should work, yes. However note that the concept of "vtid" (virtual > thread ID) is used to differentiate the tid assigned to a process when > used within a container (LXC) vs. its tid on the host. You could use > context.tid too, but if you don't use containers those two should be the > same. Thank you for the clarification. I didn't knew tip could be attached to a UST event. >> I believe my kernel trace is complete, since the following command >> shows no output. >> >> $ babeltrace lttng-traces/auto-20130321-172308/kernel/ > /dev/null >> >> My userspace trace is not complete. But I believe it does not matter, >> because the missing events are seconds before the time window I'm >> interested in, and AFAIK, there is no state reconstruction involved >> (but may be there is?). > > It could happen ; maybe the tracer missed an important sched_switch > event that set a process in a particular state. I wouldn't recommend > running analyses on traces with missing events, some information could > be all wrong. My kernel trace is *not* reported as incomplete, so I do not think I'm missing sched_switch event. Should I? > Unless you are on an embedded platform with very limited memory, it's > usually safe to increase the buffer size to a couple MBs. See > --enable-channel and --subbuf-size in the LTTng man page. I have to warn > you about https://bugs.lttng.org/issues/228 in advance though... ok, thank you for the tip. > I still think the default value should be higher (and have the embedded > guys use --subbuf-size to reduce it), but I don't call those shots ;) > >> I eventually came to a more blatant inconsistency: the displayed >> context vtid of an event is not always the same. >> >> [...] >> >> I'm using TMF 2.0.0.201303211612 (nightly build from yesterday). > > Are your traces available somewhere (if they can be made public)? I > would like to take a look at it, it seems the CTF parser gets confused > between vtid and vpid for some weird reason... No, sorry, I cannot easily share the trace. And I have not found a simple way to trig the bug. From dgoulet at efficios.com Tue Mar 26 09:39:44 2013 From: dgoulet at efficios.com (David Goulet) Date: Tue, 26 Mar 2013 09:39:44 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Fix: UST context activation In-Reply-To: <20130326023546.GA7176@Krystal> References: <20130326023546.GA7176@Krystal> Message-ID: <5151A520.9050601@efficios.com> Merged! Davd Mathieu Desnoyers: > Signed-off-by: Mathieu Desnoyers > --- > diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c > index a83cb46..b55254b 100644 > --- a/src/bin/lttng-sessiond/context.c > +++ b/src/bin/lttng-sessiond/context.c > @@ -262,7 +262,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, > } > > /* Get UST channel if defined */ > - if (channel_name != '\0') { > + if (channel_name[0] != '\0') { > uchan = trace_ust_find_channel_by_name(chan_ht, channel_name); > if (uchan == NULL) { > ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; > From mathieu.desnoyers at efficios.com Tue Mar 26 09:48:52 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Tue, 26 Mar 2013 09:48:52 -0400 Subject: [lttng-dev] Pull request: lttng-ust tests clean-up In-Reply-To: References: Message-ID: <20130326134852.GA14753@Krystal> * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: > Hi all, > > I'd like to propose a set of patches to clean-up the lttng-ust tests. > Since the clean-up now weighs in at a fairly hefty 21 patches, I think > a link to my personal repository might be more appropriate than > posting the patch-set on this list. > > The relevant commits are 8ae5122...0060eb2 > > I will also be posting a set of patches that fixes and moves some of > the lttng-ust tests to lttng-tools since they depend on it. > > Git access: > git://github.com/jgalar/lttng-ust-tests-cleanup.git -b test-cleanup > > Web interface: > https://github.com/jgalar/lttng-ust-tests-cleanup I tried running the various batch files under tests/ in your tree, and they pretty much all complain about: compudj at thinkos:~/git/jgalar/lttng-ust-tests-cleanup/tests$ (git:test-cleanup)> ./runtests ./runtests: line 31: .//snprintf/run: No such file or directory Is that expected ? Also, make check only runs a single test: snprintf/test_snprintf .. ok All tests successful. Files=1, Tests=1, 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU) Result: PASS Is that expected too ? Thanks, Mathieu > > Comments are welcome, as always! > > Regards, > J?r?mie > > -- > J?r?mie Galarneau > EfficiOS Inc. > http://www.efficios.com > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From Daniel.Thibault at drdc-rddc.gc.ca Tue Mar 26 10:01:06 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Tue, 26 Mar 2013 14:01:06 +0000 Subject: [lttng-dev] [LTTNG-TOOLS PATCH] UST periodical metadata flush Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD029735@VAL-E-01.valcartier.drdc-rddc.gc.ca> -----Message d'origine----- Date: Mon, 25 Mar 2013 22:27:05 -0400 From: Julien Desfossez diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index 8486807..afac445 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c [...] @@ -138,6 +140,8 @@ static void usage(FILE *fp) "Specify path for the command socket\n"); fprintf(fp, " -e, --consumerd-err-sock PATH " "Specify path for the error socket\n"); + fprintf(fp, " -e, --consumerd-metadata-sock PATH " + "Specify path for the metadata socket (UST only)\n"); fprintf(fp, " -d, --daemonize " "Start as a daemon.\n"); fprintf(fp, " -q, --quiet " [...] @@ -200,6 +205,9 @@ static void parse_args(int argc, char **argv) case 'e': snprintf(error_sock_path, PATH_MAX, "%s", optarg); break; + case 'm': + snprintf(metadata_sock_path, PATH_MAX, "%s", optarg); + break; case 'd': opt_daemon = 1; break; + "--consumerd-metadata-sock", consumer_data->metadata_unix_sock_path, NULL); if (consumerd64_libdir[0] != '\0') { free(tmpnew); -----Fin du message d'origine----- Shouldn't the first part be: + fprintf(fp, " -m, --consumerd-metadata-sock PATH " + "Specify path for the metadata socket (UST only)\n"); ...so it matches the second part (and doesn't ambiguate itself with with --consumerd-err-sock)? Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC G3J 1X5 CANADA Vox : (418) 844-4000 x4245 Fax : (418) 844-4538 NAC : 918V QSDJ Gouvernement du Canada / Government of Canada From jeremie.galarneau at efficios.com Tue Mar 26 10:48:19 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Tue, 26 Mar 2013 10:48:19 -0400 Subject: [lttng-dev] Pull request: lttng-ust tests clean-up In-Reply-To: <20130326134852.GA14753@Krystal> References: <20130326134852.GA14753@Krystal> Message-ID: On Tue, Mar 26, 2013 at 9:48 AM, Mathieu Desnoyers wrote: > * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: >> Hi all, >> >> I'd like to propose a set of patches to clean-up the lttng-ust tests. >> Since the clean-up now weighs in at a fairly hefty 21 patches, I think >> a link to my personal repository might be more appropriate than >> posting the patch-set on this list. >> >> The relevant commits are 8ae5122...0060eb2 >> >> I will also be posting a set of patches that fixes and moves some of >> the lttng-ust tests to lttng-tools since they depend on it. >> >> Git access: >> git://github.com/jgalar/lttng-ust-tests-cleanup.git -b test-cleanup >> >> Web interface: >> https://github.com/jgalar/lttng-ust-tests-cleanup > > I tried running the various batch files under tests/ in your tree, and > they pretty much all complain about: > > compudj at thinkos:~/git/jgalar/lttng-ust-tests-cleanup/tests$ > (git:test-cleanup)> ./runtests > ./runtests: line 31: .//snprintf/run: No such file or directory > > Is that expected ? > I meant to remove that file since, with Christian's recent lttng-tools patches, we moved away from using runner scripts to using prove + test lists. I'll correct the last commit (Tests: Use Perl prove as the testsuite runner). > Also, make check only runs a single test: > > snprintf/test_snprintf .. ok > All tests successful. > Files=1, Tests=1, 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU) > Result: PASS > > Is that expected too ? Yes, most of the tests were moved to lttng-tools since they depend on lttng-sessiond. Hopefully, now that the infrastructure is in place, It'll be easier to add self-contained UST tests. I'll take the opportunity to ask if you, or anyone else really, have suggestions for UST unit tests that don't depend on lttng-tools? I can think of a few, such as validating the header files outputted by lttng-gen-tp, testing the filter bytecode interpretation mechanisms, etc. But I wonder if unit testing the control interface, for instance, is realistic since it tends to change fairly often. Of course, lttng contributors are welcome to submit new tests! As for my lttng-tools patches, some of the new tests depend on the lttng-tools python bindings (not included in the default configuration). I'm wondering what woud be the best way to get tests to run conditionally depending on the "configure" options now that we are using Christian's "prove + test lists" scheme. I have discussed the issue with him privately and we both agreed that we could have separate test lists that would be used depending on the current project configuration. While this would certainly be good enough for now, manually maintaining test lists based on configuration dependancies may grow tedious as we add configuration options and tests. Perhaps we could dynamically generate test lists depending on the configuration options and each tests' requirements... but that certainly sounds like overkill right now. Thoughts? J?r?mie > > Thanks, > > Mathieu > >> >> Comments are welcome, as always! >> >> Regards, >> J?r?mie >> >> -- >> J?r?mie Galarneau >> EfficiOS Inc. >> http://www.efficios.com >> >> _______________________________________________ >> lttng-dev mailing list >> lttng-dev at lists.lttng.org >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com -- J?r?mie Galarneau EfficiOS Inc. http://www.efficios.com From alexmonthy at voxpopuli.im Tue Mar 26 11:03:11 2013 From: alexmonthy at voxpopuli.im (Alexandre Montplaisir) Date: Tue, 26 Mar 2013 11:03:11 -0400 Subject: [lttng-dev] TMF: inconsistencies in the context vtid reporting In-Reply-To: References: <514CCC2B.1040802@voxpopuli.im> Message-ID: <5151B8AF.1030009@voxpopuli.im> On 13-03-26 07:24 AM, S?bastien Barth?l?my wrote: > >>> I believe my kernel trace is complete, since the following command >>> shows no output. >>> >>> $ babeltrace lttng-traces/auto-20130321-172308/kernel/ > /dev/null >>> >>> My userspace trace is not complete. But I believe it does not matter, >>> because the missing events are seconds before the time window I'm >>> interested in, and AFAIK, there is no state reconstruction involved >>> (but may be there is?). >> It could happen ; maybe the tracer missed an important sched_switch >> event that set a process in a particular state. I wouldn't recommend >> running analyses on traces with missing events, some information could >> be all wrong. > My kernel trace is *not* reported as incomplete, so I do not think I'm > missing sched_switch event. Should I? My bad, I read too quickly ;) The kernel state system (which populates the Control Flow View and co.) only uses the kernel trace, so if you're not missing events in that one you sould be fine. If you create an experiment only with your UST trace, does the vtid show correctly? Alternatively, if you create an experiment with your UST and a second unrelated trace, are the results still the same? From christian.babeux at efficios.com Tue Mar 26 11:08:51 2013 From: christian.babeux at efficios.com (Christian Babeux) Date: Tue, 26 Mar 2013 11:08:51 -0400 Subject: [lttng-dev] Pull request: lttng-ust tests clean-up In-Reply-To: References: <20130326134852.GA14753@Krystal> Message-ID: Hi J?r?mie, > I'm wondering what would be the best way to get tests > to run conditionally depending on the "configure" options now that we > are using Christian's "prove + test lists" scheme. What I have in mind is something along this way: In the lttng-tools/tests/Makefile.am: if USE_PYTHON check-am: ./run.sh unit_tests ./run.sh fast_regression ./run.sh with_bindings_regression else check-am: ./run.sh unit_tests ./run.sh fast_regression endif The testlist with_bindings_regression would contain the appropriate tests that have a dependency on the lttng-tools Python bindings. > While this would certainly be good > enough for now, manually maintaining test lists based on configuration > dependancies may grow tedious as we add configuration options and > tests. Agreed. This would only apply of course if we add those tests to the default "make check" target. > Perhaps we could dynamically generate test lists depending on the > configuration options and each tests' requirements... but that > certainly sounds like overkill right now. Let's keep it simple for now :). Christian On Tue, Mar 26, 2013 at 10:48 AM, J?r?mie Galarneau wrote: > On Tue, Mar 26, 2013 at 9:48 AM, Mathieu Desnoyers > wrote: >> * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: >>> Hi all, >>> >>> I'd like to propose a set of patches to clean-up the lttng-ust tests. >>> Since the clean-up now weighs in at a fairly hefty 21 patches, I think >>> a link to my personal repository might be more appropriate than >>> posting the patch-set on this list. >>> >>> The relevant commits are 8ae5122...0060eb2 >>> >>> I will also be posting a set of patches that fixes and moves some of >>> the lttng-ust tests to lttng-tools since they depend on it. >>> >>> Git access: >>> git://github.com/jgalar/lttng-ust-tests-cleanup.git -b test-cleanup >>> >>> Web interface: >>> https://github.com/jgalar/lttng-ust-tests-cleanup >> >> I tried running the various batch files under tests/ in your tree, and >> they pretty much all complain about: >> >> compudj at thinkos:~/git/jgalar/lttng-ust-tests-cleanup/tests$ >> (git:test-cleanup)> ./runtests >> ./runtests: line 31: .//snprintf/run: No such file or directory >> >> Is that expected ? >> > > I meant to remove that file since, with Christian's recent lttng-tools > patches, we moved away from using runner scripts to using prove + test > lists. I'll correct the last commit (Tests: Use Perl prove as the > testsuite runner). > >> Also, make check only runs a single test: >> >> snprintf/test_snprintf .. ok >> All tests successful. >> Files=1, Tests=1, 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU) >> Result: PASS >> >> Is that expected too ? > > Yes, most of the tests were moved to lttng-tools since they depend on > lttng-sessiond. Hopefully, now that the infrastructure is in place, > It'll be easier to add self-contained UST tests. > > I'll take the opportunity to ask if you, or anyone else really, have > suggestions for UST unit tests that don't depend on lttng-tools? > > I can think of a few, such as validating the header files outputted by > lttng-gen-tp, testing the filter bytecode interpretation mechanisms, > etc. But I wonder if unit testing the control interface, for instance, > is realistic since it tends to change fairly often. Of course, lttng > contributors are welcome to submit new tests! > > As for my lttng-tools patches, some of the new tests depend on the > lttng-tools python bindings (not included in the default > configuration). I'm wondering what woud be the best way to get tests > to run conditionally depending on the "configure" options now that we > are using Christian's "prove + test lists" scheme. > > I have discussed the issue with him privately and we both agreed that > we could have separate test lists that would be used depending on the > current project configuration. While this would certainly be good > enough for now, manually maintaining test lists based on configuration > dependancies may grow tedious as we add configuration options and > tests. > > Perhaps we could dynamically generate test lists depending on the > configuration options and each tests' requirements... but that > certainly sounds like overkill right now. Thoughts? > > J?r?mie > >> >> Thanks, >> >> Mathieu >> >>> >>> Comments are welcome, as always! >>> >>> Regards, >>> J?r?mie >>> >>> -- >>> J?r?mie Galarneau >>> EfficiOS Inc. >>> http://www.efficios.com >>> >>> _______________________________________________ >>> lttng-dev mailing list >>> lttng-dev at lists.lttng.org >>> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev >> >> -- >> Mathieu Desnoyers >> EfficiOS Inc. >> http://www.efficios.com > > > > -- > J?r?mie Galarneau > EfficiOS Inc. > http://www.efficios.com From mathieu.desnoyers at efficios.com Tue Mar 26 11:24:38 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Tue, 26 Mar 2013 11:24:38 -0400 Subject: [lttng-dev] Pull request: lttng-ust tests clean-up In-Reply-To: References: Message-ID: <20130326152438.GA16058@Krystal> * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: > Hi all, > > I'd like to propose a set of patches to clean-up the lttng-ust tests. > Since the clean-up now weighs in at a fairly hefty 21 patches, I think > a link to my personal repository might be more appropriate than > posting the patch-set on this list. merged, thanks! I rebased it on master. Mathieu > > The relevant commits are 8ae5122...0060eb2 > > I will also be posting a set of patches that fixes and moves some of > the lttng-ust tests to lttng-tools since they depend on it. > > Git access: > git://github.com/jgalar/lttng-ust-tests-cleanup.git -b test-cleanup > > Web interface: > https://github.com/jgalar/lttng-ust-tests-cleanup > > Comments are welcome, as always! > > Regards, > J?r?mie > > -- > J?r?mie Galarneau > EfficiOS Inc. > http://www.efficios.com > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From dgoulet at efficios.com Tue Mar 26 13:49:59 2013 From: dgoulet at efficios.com (David Goulet) Date: Tue, 26 Mar 2013 13:49:59 -0400 Subject: [lttng-dev] [PATCH lttng-tools] UST periodical metadata flush Message-ID: <1364320199-30440-1-git-send-email-dgoulet@efficios.com> From: Julien Desfossez Add a socket between the sessiond and the ust-consumer to allow periodical flush of the metadata channel. If enabled (by specifying the --switch-timer option on the metadata channel), a new timer thread in the consumer asks the session daemon for new metadata for a specific session. All the metadata collected is written into a metadata cache in the consumer, this mechanism is useful for synchronisation (to avoid race conditions between two metadata updates) and will also be useful when we implement the snapshots. Signed-off-by: Julien Desfossez Signed-off-by: David Goulet --- src/bin/lttng-consumerd/lttng-consumerd.c | 29 ++++ src/bin/lttng-sessiond/consumer.c | 4 +- src/bin/lttng-sessiond/consumer.h | 2 + src/bin/lttng-sessiond/main.c | 147 +++++++++++++------- src/bin/lttng-sessiond/ust-app.c | 109 +++++++++------ src/bin/lttng-sessiond/ust-app.h | 8 ++ src/bin/lttng-sessiond/ust-consumer.c | 77 ++++++++++ src/bin/lttng-sessiond/ust-consumer.h | 1 + src/common/Makefile.am | 6 +- src/common/consumer-metadata-cache.c | 214 ++++++++++++++++++++++++++++ src/common/consumer-metadata-cache.h | 58 ++++++++ src/common/consumer-timer.c | 216 +++++++++++++++++++++++++++++ src/common/consumer-timer.h | 49 +++++++ src/common/consumer.c | 43 ++++++ src/common/consumer.h | 17 ++- src/common/defaults.h | 8 +- src/common/macros.h | 4 + src/common/sessiond-comm/sessiond-comm.h | 15 ++ src/common/ust-consumer/ust-consumer.c | 194 ++++++++++++++++++++++---- src/common/ust-consumer/ust-consumer.h | 6 + tests/unit/Makefile.am | 5 +- 21 files changed, 1082 insertions(+), 130 deletions(-) create mode 100644 src/common/consumer-metadata-cache.c create mode 100644 src/common/consumer-metadata-cache.h create mode 100644 src/common/consumer-timer.c create mode 100644 src/common/consumer-timer.h diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index 8486807..7ca9688 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -52,7 +53,9 @@ /* TODO : support UST (all direct kernel-ctl accesses). */ /* threads (channel handling, poll, metadata, sessiond) */ + static pthread_t channel_thread, data_thread, metadata_thread, sessiond_thread; +static pthread_t metadata_timer_thread; /* to count the number of times the user pressed ctrl+c */ static int sigintcount = 0; @@ -363,6 +366,15 @@ int main(int argc, char **argv) } lttng_consumer_set_error_sock(ctx, ret); + /* + * For UST consumer, we block RT signals used for periodical metadata flush + * in main and create a dedicated thread to handle these signals. + */ + if (opt_type != LTTNG_CONSUMER_KERNEL) { + consumer_signal_init(); + } + ctx->type = opt_type; + /* Create thread to manage channels */ ret = pthread_create(&channel_thread, NULL, consumer_thread_channel_poll, (void *) ctx); @@ -395,6 +407,23 @@ int main(int argc, char **argv) goto sessiond_error; } + if (opt_type != LTTNG_CONSUMER_KERNEL) { + /* Create the thread to manage the metadata periodic timers */ + ret = pthread_create(&metadata_timer_thread, NULL, + consumer_timer_metadata_thread, (void *) ctx); + if (ret != 0) { + perror("pthread_create"); + goto metadata_timer_error; + } + + ret = pthread_detach(metadata_timer_thread); + if (ret) { + errno = ret; + perror("pthread_detach"); + } + } + +metadata_timer_error: ret = pthread_join(sessiond_thread, &status); if (ret != 0) { perror("pthread_join"); diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 57b5b19..6719051 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -1072,7 +1072,7 @@ end: } /* - * Send metadata string to consumer. + * Send metadata string to consumer. Socket lock MUST be acquired. * * Return 0 on success else a negative value. */ @@ -1103,7 +1103,7 @@ int consumer_push_metadata(struct consumer_socket *socket, health_code_update(); ret = consumer_send_msg(socket, &msg); - if (ret < 0) { + if (ret < 0 || len == 0) { goto end; } diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index cde2d0d..b767589 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -78,7 +78,9 @@ struct consumer_data { pid_t pid; int err_sock; + /* These two sockets uses the cmd_unix_sock_path. */ int cmd_sock; + struct consumer_socket metadata_sock; /* consumer error and command Unix socket path */ char err_unix_sock_path[PATH_MAX]; diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index d88bafe..a98b4f2 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,7 @@ static struct consumer_data kconsumer_data = { .cmd_unix_sock_path = DEFAULT_KCONSUMERD_CMD_SOCK_PATH, .err_sock = -1, .cmd_sock = -1, + .metadata_sock.fd = -1, .pid_mutex = PTHREAD_MUTEX_INITIALIZER, .lock = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, @@ -100,6 +102,7 @@ static struct consumer_data ustconsumer64_data = { .cmd_unix_sock_path = DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH, .err_sock = -1, .cmd_sock = -1, + .metadata_sock.fd = -1, .pid_mutex = PTHREAD_MUTEX_INITIALIZER, .lock = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, @@ -111,6 +114,7 @@ static struct consumer_data ustconsumer32_data = { .cmd_unix_sock_path = DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH, .err_sock = -1, .cmd_sock = -1, + .metadata_sock.fd = -1, .pid_mutex = PTHREAD_MUTEX_INITIALIZER, .lock = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, @@ -865,10 +869,10 @@ static void *thread_manage_consumer(void *data) health_code_update(); /* - * Pass 2 as size here for the thread quit pipe and kconsumerd_err_sock. - * Nothing more will be added to this poll set. + * Pass 3 as size here for the thread quit pipe, consumerd_err_sock and the + * metadata_sock. Nothing more will be added to this poll set. */ - ret = sessiond_set_thread_pollset(&events, 2); + ret = sessiond_set_thread_pollset(&events, 3); if (ret < 0) { goto error_poll; } @@ -885,7 +889,7 @@ static void *thread_manage_consumer(void *data) health_code_update(); - /* Inifinite blocking call, waiting for transmission */ + /* Infinite blocking call, waiting for transmission */ restart: health_poll_entry(); @@ -955,87 +959,126 @@ restart: health_code_update(); if (code == LTTCOMM_CONSUMERD_COMMAND_SOCK_READY) { + /* Connect both socket, command and metadata. */ consumer_data->cmd_sock = lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path); - if (consumer_data->cmd_sock < 0) { + consumer_data->metadata_sock.fd = + lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path); + if (consumer_data->cmd_sock < 0 || + consumer_data->metadata_sock.fd < 0) { + PERROR("consumer connect cmd socket"); /* On error, signal condition and quit. */ signal_consumer_condition(consumer_data, -1); - PERROR("consumer connect"); goto error; } + /* Create metadata socket lock. */ + consumer_data->metadata_sock.lock = zmalloc(sizeof(pthread_mutex_t)); + if (consumer_data->metadata_sock.lock == NULL) { + PERROR("zmalloc pthread mutex"); + ret = -1; + goto error; + } + pthread_mutex_init(consumer_data->metadata_sock.lock, NULL); + signal_consumer_condition(consumer_data, 1); - DBG("Consumer command socket ready"); + DBG("Consumer command socket ready (fd: %d", consumer_data->cmd_sock); + DBG("Consumer metadata socket ready (fd: %d)", + consumer_data->metadata_sock.fd); } else { ERR("consumer error when waiting for SOCK_READY : %s", lttcomm_get_readable_code(-code)); goto error; } - /* Remove the kconsumerd error sock since we've established a connexion */ + /* Remove the consumerd error sock since we've established a connexion */ ret = lttng_poll_del(&events, consumer_data->err_sock); if (ret < 0) { goto error; } + /* Add new accepted error socket. */ ret = lttng_poll_add(&events, sock, LPOLLIN | LPOLLRDHUP); if (ret < 0) { goto error; } + /* Add metadata socket that is successfully connected. */ + ret = lttng_poll_add(&events, consumer_data->metadata_sock.fd, + LPOLLIN | LPOLLRDHUP); + if (ret < 0) { + goto error; + } + health_code_update(); - /* Inifinite blocking call, waiting for transmission */ + /* Infinite blocking call, waiting for transmission */ restart_poll: - health_poll_entry(); - ret = lttng_poll_wait(&events, -1); - health_poll_exit(); - if (ret < 0) { - /* - * Restart interrupted system call. - */ - if (errno == EINTR) { - goto restart_poll; + while (1) { + health_poll_entry(); + ret = lttng_poll_wait(&events, -1); + health_poll_exit(); + if (ret < 0) { + /* + * Restart interrupted system call. + */ + if (errno == EINTR) { + goto restart_poll; + } + goto error; } - goto error; - } - nb_fd = ret; + nb_fd = ret; - for (i = 0; i < nb_fd; i++) { - /* Fetch once the poll data */ - revents = LTTNG_POLL_GETEV(&events, i); - pollfd = LTTNG_POLL_GETFD(&events, i); + for (i = 0; i < nb_fd; i++) { + /* Fetch once the poll data */ + revents = LTTNG_POLL_GETEV(&events, i); + pollfd = LTTNG_POLL_GETFD(&events, i); - health_code_update(); + health_code_update(); - /* Thread quit pipe has been closed. Killing thread. */ - ret = sessiond_check_thread_quit_pipe(pollfd, revents); - if (ret) { - err = 0; - goto exit; - } + /* Thread quit pipe has been closed. Killing thread. */ + ret = sessiond_check_thread_quit_pipe(pollfd, revents); + if (ret) { + err = 0; + goto exit; + } - /* Event on the kconsumerd socket */ - if (pollfd == sock) { - if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { - ERR("consumer err socket second poll error"); + if (pollfd == sock) { + /* Event on the consumerd socket */ + if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { + ERR("consumer err socket second poll error"); + goto error; + } + health_code_update(); + /* Wait for any kconsumerd error */ + ret = lttcomm_recv_unix_sock(sock, &code, + sizeof(enum lttcomm_return_code)); + if (ret <= 0) { + ERR("consumer closed the command socket"); + goto error; + } + + ERR("consumer return code : %s", + lttcomm_get_readable_code(-code)); + + goto exit; + } else if (pollfd == consumer_data->metadata_sock.fd) { + /* UST metadata requests */ + ret = ust_consumer_metadata_request( + &consumer_data->metadata_sock); + if (ret < 0) { + ERR("Handling metadata request"); + goto error; + } + break; + } else { + ERR("Unknown pollfd"); goto error; } } + health_code_update(); } - health_code_update(); - - /* Wait for any kconsumerd error */ - ret = lttcomm_recv_unix_sock(sock, &code, - sizeof(enum lttcomm_return_code)); - if (ret <= 0) { - ERR("consumer closed the command socket"); - goto error; - } - - ERR("consumer return code : %s", lttcomm_get_readable_code(-code)); - exit: error: /* Immediately set the consumerd state to stopped */ @@ -1061,6 +1104,12 @@ error: PERROR("close"); } } + if (consumer_data->metadata_sock.fd >= 0) { + ret = close(consumer_data->metadata_sock.fd); + if (ret) { + PERROR("close"); + } + } if (sock >= 0) { ret = close(sock); if (ret) { @@ -2011,7 +2060,7 @@ end: return 0; error: - /* Cleanup already created socket on error. */ + /* Cleanup already created sockets on error. */ if (consumer_data->err_sock >= 0) { int err; diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 979ae7c..2cb92e4 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -368,17 +369,72 @@ void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan, } /* + * Push metadata to consumer socket. The socket lock MUST be acquired. + * + * On success, return the len of metadata pushed or else a negative value. + */ +ssize_t ust_app_push_metadata(struct ust_registry_session *registry, + struct consumer_socket *socket) +{ + int ret; + char *metadata_str = NULL; + size_t len, offset; + ssize_t ret_val; + + assert(registry); + assert(socket); + + pthread_mutex_lock(®istry->lock); + + offset = registry->metadata_len_sent; + len = registry->metadata_len - registry->metadata_len_sent; + if (len == 0) { + DBG3("No metadata to push for metadata key %" PRIu64, + registry->metadata_key); + goto end; + } + + /* Allocate only what we have to send. */ + metadata_str = zmalloc(len); + if (!metadata_str) { + PERROR("zmalloc ust app metadata string"); + ret_val = -ENOMEM; + goto error; + } + /* Copy what we haven't send out. */ + memcpy(metadata_str, registry->metadata + offset, len); + + ret = consumer_push_metadata(socket, registry->metadata_key, + metadata_str, len, offset); + if (ret < 0) { + ret_val = ret; + goto error; + } + + registry->metadata_len_sent += len; + +end: + ret_val = len; +error: + free(metadata_str); + pthread_mutex_unlock(®istry->lock); + return ret_val; +} + +/* * For a given application and session, push metadata to consumer. The session * lock MUST be acquired here before calling this. + * Either sock or consumer is required : if sock is NULL, the default + * socket to send the metadata is retrieved from consumer, if sock + * is not NULL we use it to send the metadata. * * Return 0 on success else a negative error. */ static int push_metadata(struct ust_registry_session *registry, struct consumer_output *consumer) { - int ret; - char *metadata_str = NULL; - size_t len, offset; + int ret_val; + ssize_t ret; struct consumer_socket *socket; assert(registry); @@ -391,7 +447,7 @@ static int push_metadata(struct ust_registry_session *registry, * no start has been done previously. */ if (!registry->metadata_key) { - ret = 0; + ret_val = 0; goto error_rcu_unlock; } @@ -399,7 +455,7 @@ static int push_metadata(struct ust_registry_session *registry, socket = consumer_find_socket_by_bitness(registry->bits_per_long, consumer); if (!socket) { - ret = -1; + ret_val = -1; goto error_rcu_unlock; } @@ -414,54 +470,19 @@ static int push_metadata(struct ust_registry_session *registry, * ability to reorder the metadata it receives. */ pthread_mutex_lock(socket->lock); - pthread_mutex_lock(®istry->lock); - - offset = registry->metadata_len_sent; - len = registry->metadata_len - registry->metadata_len_sent; - if (len == 0) { - DBG3("No metadata to push for metadata key %" PRIu64, - registry->metadata_key); - ret = 0; - goto error_reg_unlock; - } - assert(len > 0); - - /* Allocate only what we have to send. */ - metadata_str = zmalloc(len); - if (!metadata_str) { - PERROR("zmalloc ust app metadata string"); - ret = -ENOMEM; - goto error_reg_unlock; - } - /* Copy what we haven't send out. */ - memcpy(metadata_str, registry->metadata + offset, len); - - pthread_mutex_unlock(®istry->lock); - - ret = consumer_push_metadata(socket, registry->metadata_key, - metadata_str, len, offset); + ret = ust_app_push_metadata(registry, socket); + pthread_mutex_unlock(socket->lock); if (ret < 0) { - pthread_mutex_unlock(socket->lock); + ret_val = ret; goto error_rcu_unlock; } - /* Update len sent of the registry. */ - pthread_mutex_lock(®istry->lock); - registry->metadata_len_sent += len; - pthread_mutex_unlock(®istry->lock); - pthread_mutex_unlock(socket->lock); - rcu_read_unlock(); - free(metadata_str); return 0; -error_reg_unlock: - pthread_mutex_unlock(®istry->lock); - pthread_mutex_unlock(socket->lock); error_rcu_unlock: rcu_read_unlock(); - free(metadata_str); - return ret; + return ret_val; } /* diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 67088a7..776dc0e 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -299,6 +299,8 @@ int ust_app_recv_notify(int sock); void ust_app_add(struct ust_app *app); struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock); void ust_app_notify_sock_unregister(int sock); +ssize_t ust_app_push_metadata(struct ust_registry_session *registry, + struct consumer_socket *socket); #else /* HAVE_LIBLTTNG_UST_CTL */ @@ -485,6 +487,12 @@ static inline void ust_app_notify_sock_unregister(int sock) { } +static inline +ssize_t ust_app_push_metadata(struct ust_registry_session *registry, + struct consumer_socket *socket) +{ + return 0; +} #endif /* HAVE_LIBLTTNG_UST_CTL */ diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index ba74112..2b6f813 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -30,6 +30,8 @@ #include "consumer.h" #include "health.h" #include "ust-consumer.h" +#include "buffer-registry.h" +#include "session.h" /* * Return allocated full pathname of the session using the consumer trace path @@ -405,3 +407,78 @@ int ust_consumer_send_channel_to_ust(struct ust_app *app, error: return ret; } + +/* + * Handle the metadata requests from the UST consumer + * + * Return 0 on success else a negative value. + */ +int ust_consumer_metadata_request(struct consumer_socket *socket) +{ + int ret; + ssize_t ret_push; + struct lttcomm_metadata_request_msg request; + struct buffer_reg_uid *reg_uid; + struct ust_registry_session *ust_reg; + struct lttcomm_consumer_msg msg; + uint64_t len; + + assert(socket); + + rcu_read_lock(); + pthread_mutex_lock(socket->lock); + + health_code_update(); + + /* Wait for a metadata request */ + ret = lttcomm_recv_unix_sock(socket->fd, &request, sizeof(request)); + if (ret <= 0) { + ERR("Consumer closed the metadata socket"); + ret = -1; + goto end; + } + + DBG("Metadata request received for session %u, key %" PRIu64, + request.session_id, request.key); + + reg_uid = buffer_reg_uid_find(request.session_id, + request.bits_per_long, request.uid); + if (reg_uid) { + ust_reg = reg_uid->registry->reg.ust; + } else { + struct buffer_reg_pid *reg_pid = + buffer_reg_pid_find(request.session_id); + if (!reg_pid) { + DBG("PID registry not found for session id %u", + request.session_id); + + msg.cmd_type = LTTNG_ERR_UND; + (void) consumer_send_msg(socket, &msg); + ret = -1; + goto end; + } + ust_reg = reg_pid->registry->reg.ust; + } + assert(ust_reg); + + len = ust_reg->metadata_len - ust_reg->metadata_len_sent; + if (len == 0) { + DBG("No metadata to push"); + ret = consumer_push_metadata(socket, request.key, NULL, len, 0); + goto end; + } + + ret_push = ust_app_push_metadata(ust_reg, socket); + if (ret_push < 0) { + ERR("Pushing metadata"); + ret = -1; + goto end; + } + DBG("UST Consumer metadata pushed successfully"); + ret = 0; + +end: + pthread_mutex_unlock(socket->lock); + rcu_read_unlock(); + return ret; +} diff --git a/src/bin/lttng-sessiond/ust-consumer.h b/src/bin/lttng-sessiond/ust-consumer.h index f5f63d9..d378202 100644 --- a/src/bin/lttng-sessiond/ust-consumer.h +++ b/src/bin/lttng-sessiond/ust-consumer.h @@ -36,5 +36,6 @@ int ust_consumer_send_stream_to_ust(struct ust_app *app, int ust_consumer_send_channel_to_ust(struct ust_app *app, struct ust_app_session *ua_sess, struct ust_app_channel *channel); +int ust_consumer_metadata_request(struct consumer_socket *sock); #endif /* _UST_CONSUMER_H */ diff --git a/src/common/Makefile.am b/src/common/Makefile.am index c3a947a..f2ea40a 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -6,7 +6,8 @@ SUBDIRS = compat hashtable kernel-ctl sessiond-comm relayd \ AM_CFLAGS = -fno-strict-aliasing noinst_HEADERS = lttng-kernel.h defaults.h macros.h error.h futex.h \ - uri.h utils.h lttng-kernel-old.h + uri.h utils.h lttng-kernel-old.h \ + consumer-metadata-cache.h consumer-timer.h # Common library noinst_LTLIBRARIES = libcommon.la @@ -18,7 +19,8 @@ libcommon_la_LIBADD = -luuid # Consumer library noinst_LTLIBRARIES += libconsumer.la -libconsumer_la_SOURCES = consumer.c consumer.h +libconsumer_la_SOURCES = consumer.c consumer.h consumer-metadata-cache.c \ + consumer-timer.c libconsumer_la_LIBADD = \ $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \ diff --git a/src/common/consumer-metadata-cache.c b/src/common/consumer-metadata-cache.c new file mode 100644 index 0000000..979521f --- /dev/null +++ b/src/common/consumer-metadata-cache.c @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2013 - Julien Desfossez + * David Goulet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "consumer-metadata-cache.h" + +/* + * Extend the allocated size of the metadata cache. Called only from + * lttng_ustconsumer_write_metadata_cache. + * + * Return 0 on success, a negative value on error. + */ +static int extend_metadata_cache(struct lttng_consumer_channel *channel, + unsigned int size) +{ + int ret = 0; + char *tmp_data_ptr; + unsigned int new_size; + + assert(channel); + assert(channel->metadata_cache); + + new_size = max_t(unsigned int, + channel->metadata_cache->cache_alloc_size + size, + channel->metadata_cache->cache_alloc_size << 1); + DBG("Extending metadata cache to %u", new_size); + tmp_data_ptr = realloc(channel->metadata_cache->data, new_size); + if (!tmp_data_ptr) { + ERR("Reallocating metadata cache"); + free(channel->metadata_cache->data); + ret = -1; + goto end; + } + channel->metadata_cache->data = tmp_data_ptr; + channel->metadata_cache->cache_alloc_size = new_size; + +end: + return ret; +} + +/* + * Write metadata to the cache, extend the cache if necessary. We support + * non-contiguous updates but not overlapping ones. If there is contiguous + * metadata in the cache, we send it to the ring buffer. The metadata cache + * lock MUST be acquired to write in the cache. + * + * Return 0 on success, a negative value on error. + */ +int consumer_metadata_cache_write(struct lttng_consumer_channel *channel, + unsigned int offset, unsigned int len, char *data) +{ + int ret = 0; + struct consumer_metadata_cache *cache; + + assert(channel); + assert(channel->metadata_cache); + + cache = channel->metadata_cache; + DBG("Writing %u bytes from offset %u in metadata cache", + len, offset); + + if (offset + len > cache->cache_alloc_size) { + ret = extend_metadata_cache(channel, + len - cache->cache_alloc_size + offset); + if (ret < 0) { + ERR("Extending metadata cache"); + goto end; + } + } + + memcpy(cache->data + offset, data, len); + cache->total_bytes_written += len; + if (offset + len > cache->max_offset) { + cache->max_offset = offset + len; + } + + if (cache->max_offset == cache->total_bytes_written) { + offset = cache->rb_pushed; + len = cache->total_bytes_written - cache->rb_pushed; + ret = lttng_ustconsumer_push_metadata(channel, cache->data, offset, + len); + if (ret < 0) { + ERR("Pushing metadata"); + goto end; + } + cache->rb_pushed += len; + } + +end: + return ret; +} + +/* + * Create the metadata cache, original allocated size: max_sb_size + * + * Return 0 on success, a negative value on error. + */ +int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel) +{ + int ret; + + assert(channel); + + channel->metadata_cache = zmalloc( + sizeof(struct consumer_metadata_cache)); + if (!channel->metadata_cache) { + PERROR("zmalloc metadata cache struct"); + ret = -1; + goto end; + } + ret = pthread_mutex_init(&channel->metadata_cache->lock, NULL); + if (ret != 0) { + PERROR("mutex init"); + goto end_free_cache; + } + + channel->metadata_cache->cache_alloc_size = DEFAULT_METADATA_CACHE_SIZE; + channel->metadata_cache->data = zmalloc( + channel->metadata_cache->cache_alloc_size * sizeof(char)); + if (!channel->metadata_cache->data) { + PERROR("zmalloc metadata cache data"); + ret = -1; + goto end_free_mutex; + } + DBG("Allocated metadata cache of %" PRIu64 " bytes", + channel->metadata_cache->cache_alloc_size); + + ret = 0; + goto end; + +end_free_mutex: + pthread_mutex_destroy(&channel->metadata_cache->lock); +end_free_cache: + free(channel->metadata_cache); +end: + return ret; +} + +/* + * Destroy and free the metadata cache + */ +void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel) +{ + if (!channel || !channel->metadata_cache) { + return; + } + + DBG("Destroying metadata cache"); + + if (channel->metadata_cache->max_offset > + channel->metadata_cache->rb_pushed) { + ERR("Destroying a cache not entirely commited"); + } + + pthread_mutex_destroy(&channel->metadata_cache->lock); + free(channel->metadata_cache->data); + free(channel->metadata_cache); +} + +/* + * Check if the cache is flushed up to the offset passed in parameter. + * + * Return 0 if everything has been flushed, 1 if there is data not flushed. + */ +int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, + uint64_t offset) +{ + int ret; + struct consumer_metadata_cache *cache; + + assert(channel); + assert(channel->metadata_cache); + + cache = channel->metadata_cache; + + pthread_mutex_lock(&channel->metadata_cache->lock); + if (cache->rb_pushed >= offset) { + ret = 0; + } else { + ret = 1; + } + pthread_mutex_unlock(&channel->metadata_cache->lock); + + return ret; +} diff --git a/src/common/consumer-metadata-cache.h b/src/common/consumer-metadata-cache.h new file mode 100644 index 0000000..1d76b50 --- /dev/null +++ b/src/common/consumer-metadata-cache.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2013 - Julien Desfossez + * David Goulet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef CONSUMER_METADATA_CACHE_H +#define CONSUMER_METADATA_CACHE_H + +#include + +struct consumer_metadata_cache { + char *data; + uint64_t cache_alloc_size; + /* + * How many bytes from the cache were already sent to + * the ring buffer + */ + uint64_t rb_pushed; + /* + * How many bytes are written in the buffer (excluding the wholes) + */ + uint64_t total_bytes_written; + /* + * The upper-limit of data written inside the buffer. + * + * With the total_bytes_written it allows us to keep track of when the + * cache contains contiguous metadata ready to be sent to the RB. + * The metadata cache updates must not overlap. + */ + uint64_t max_offset; + /* + * Lock to update the metadata cache and push into the + * ring_buffer (ustctl_write_metadata_to_channel) + */ + pthread_mutex_t lock; +}; + +int consumer_metadata_cache_write(struct lttng_consumer_channel *channel, + unsigned int offset, unsigned int len, char *data); +int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel); +void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel); +int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, + uint64_t offset); + +#endif /* CONSUMER_METADATA_CACHE_H */ diff --git a/src/common/consumer-timer.c b/src/common/consumer-timer.c new file mode 100644 index 0000000..80087fd --- /dev/null +++ b/src/common/consumer-timer.c @@ -0,0 +1,216 @@ +/* + * Copyright (C) 2012 - Julien Desfossez + * David Goulet + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License, version 2 only, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#define _GNU_SOURCE +#include +#include +#include + +#include + +#include "consumer-timer.h" +#include "ust-consumer/ust-consumer.h" + +static struct timer_signal_data timer_signal; + +/* + * Set custom signal mask to current thread. + */ +static void setmask(sigset_t *mask) +{ + int ret; + + ret = sigemptyset(mask); + if (ret) { + PERROR("sigemptyset"); + } + ret = sigaddset(mask, LTTNG_CONSUMER_SIG_SWITCH); + if (ret) { + PERROR("sigaddset"); + } + ret = sigaddset(mask, LTTNG_CONSUMER_SIG_TEARDOWN); + if (ret) { + PERROR("sigaddset"); + } +} + +/* + * Execute action on a timer switch. + */ +static void metadata_switch_timer(struct lttng_consumer_local_data *ctx, + int sig, siginfo_t *si, void *uc) +{ + struct lttng_consumer_channel *channel; + + channel = si->si_value.sival_ptr; + assert(channel); + + DBG("Switch timer for channel %" PRIu64, channel->key); + switch (ctx->type) { + case LTTNG_CONSUMER32_UST: + case LTTNG_CONSUMER64_UST: + (void) lttng_ustconsumer_request_metadata(ctx, channel); + break; + case LTTNG_CONSUMER_KERNEL: + case LTTNG_CONSUMER_UNKNOWN: + assert(0); + break; + } +} + +/* + * Set the timer for periodical metadata flush. + */ +void consumer_timer_switch_start(struct lttng_consumer_channel *channel, + unsigned int switch_timer_interval) +{ + int ret; + struct sigevent sev; + struct itimerspec its; + + if (switch_timer_interval == 0) { + return; + } + + sev.sigev_notify = SIGEV_SIGNAL; + sev.sigev_signo = LTTNG_CONSUMER_SIG_SWITCH; + sev.sigev_value.sival_ptr = channel; + ret = timer_create(CLOCKID, &sev, &channel->switch_timer); + if (ret == -1) { + PERROR("timer_create"); + } + channel->switch_timer_enabled = 1; + + its.it_value.tv_sec = switch_timer_interval / 1000000; + its.it_value.tv_nsec = switch_timer_interval % 1000000; + its.it_interval.tv_sec = its.it_value.tv_sec; + its.it_interval.tv_nsec = its.it_value.tv_nsec; + + ret = timer_settime(channel->switch_timer, 0, &its, NULL); + if (ret == -1) { + PERROR("timer_settime"); + } +} + +/* + * Stop and delete timer. + */ +void consumer_timer_switch_stop(struct lttng_consumer_channel *channel) +{ + int ret; + sigset_t pending_set; + + assert(channel); + + ret = timer_delete(channel->switch_timer); + if (ret == -1) { + PERROR("timer_delete"); + } + + /* Ensure we don't have any signal queued for this channel. */ + for (;;) { + ret = sigemptyset(&pending_set); + if (ret == -1) { + PERROR("sigemptyset"); + } + ret = sigpending(&pending_set); + if (ret == -1) { + PERROR("sigpending"); + } + if (!sigismember(&pending_set, LTTNG_CONSUMER_SIG_SWITCH)) { + break; + } + caa_cpu_relax(); + } + + /* + * From this point, no new signal handler will be fired that would try to + * access "chan". However, we still need to wait for any currently + * executing handler to complete. + */ + cmm_smp_mb(); + CMM_STORE_SHARED(timer_signal.qs_done, 0); + cmm_smp_mb(); + + /* + * Kill with LTTNG_CONSUMER_SIG_TEARDOWN, so signal management thread wakes + * up. + */ + kill(getpid(), LTTNG_CONSUMER_SIG_TEARDOWN); + + while (!CMM_LOAD_SHARED(timer_signal.qs_done)) { + caa_cpu_relax(); + } + cmm_smp_mb(); +} + +/* + * Block the RT signals for the entire process. It must be called from the + * consumer main before creating the threads + */ +void consumer_signal_init(void) +{ + int ret; + sigset_t mask; + + /* Block signal for entire process, so only our thread processes it. */ + setmask(&mask); + ret = pthread_sigmask(SIG_BLOCK, &mask, NULL); + if (ret) { + errno = ret; + PERROR("pthread_sigmask"); + } +} + +/* + * This thread is the sighandler for signals LTTNG_CONSUMER_SIG_SWITCH and + * LTTNG_CONSUMER_SIG_TEARDOWN that are emitted by the periodic timer to check + * if new metadata is available. + */ +void *consumer_timer_metadata_thread(void *data) +{ + int signr; + sigset_t mask; + siginfo_t info; + struct lttng_consumer_local_data *ctx = data; + + /* Only self thread will receive signal mask. */ + setmask(&mask); + CMM_STORE_SHARED(timer_signal.tid, pthread_self()); + + while (1) { + signr = sigwaitinfo(&mask, &info); + if (signr == -1) { + if (errno != EINTR) { + PERROR("sigwaitinfo"); + } + continue; + } else if (signr == LTTNG_CONSUMER_SIG_SWITCH) { + metadata_switch_timer(ctx, info.si_signo, &info, NULL); + } else if (signr == LTTNG_CONSUMER_SIG_TEARDOWN) { + cmm_smp_mb(); + CMM_STORE_SHARED(timer_signal.qs_done, 1); + cmm_smp_mb(); + DBG("Signal timer metadata thread teardown"); + } else { + ERR("Unexpected signal %d\n", info.si_signo); + } + } + + return NULL; +} diff --git a/src/common/consumer-timer.h b/src/common/consumer-timer.h new file mode 100644 index 0000000..8406158 --- /dev/null +++ b/src/common/consumer-timer.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011 - Julien Desfossez + * Mathieu Desnoyers + * 2012 - David Goulet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef CONSUMER_TIMER_H +#define CONSUMER_TIMER_H + +#include + +#include "consumer.h" + +#define LTTNG_CONSUMER_SIG_SWITCH SIGRTMIN + 10 +#define LTTNG_CONSUMER_SIG_TEARDOWN SIGRTMIN + 11 + +#define CLOCKID CLOCK_MONOTONIC + +/* + * Handle timer teardown race wrt memory free of private data by consumer + * signals are handled by a single thread, which permits a synchronization + * point between handling of each signal. + */ +struct timer_signal_data { + pthread_t tid; /* thread id managing signals */ + int setup_done; + int qs_done; +}; + +void consumer_timer_switch_start(struct lttng_consumer_channel *channel, + unsigned int switch_timer_interval); +void consumer_timer_switch_stop(struct lttng_consumer_channel *channel); +void *consumer_timer_metadata_thread(void *data); +void consumer_signal_init(void); + +#endif /* CONSUMER_TIMER_H */ diff --git a/src/common/consumer.c b/src/common/consumer.c index 29bd0c0..5f87f4b 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1141,6 +1142,7 @@ struct lttng_consumer_local_data *lttng_consumer_create( } ctx->consumer_error_socket = -1; + ctx->consumer_metadata_socket = -1; /* assign the callbacks */ ctx->on_buffer_ready = buffer_ready; ctx->on_recv_channel = recv_channel; @@ -1227,6 +1229,10 @@ void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx) if (ret) { PERROR("close"); } + ret = close(ctx->consumer_metadata_socket); + if (ret) { + PERROR("close"); + } utils_close_pipe(ctx->consumer_thread_pipe); utils_close_pipe(ctx->consumer_channel_pipe); utils_close_pipe(ctx->consumer_data_pipe); @@ -1328,6 +1334,7 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap( goto end; } ret = lttng_ustctl_get_mmap_read_offset(stream, &mmap_offset); + break; default: ERR("Unknown consumer_data type"); @@ -2707,6 +2714,33 @@ end_ht: return NULL; } +static int set_metadata_socket(struct lttng_consumer_local_data *ctx, + struct pollfd *sockpoll, int client_socket) +{ + int ret; + + assert(ctx); + assert(sockpoll); + + if (lttng_consumer_poll_socket(sockpoll) < 0) { + ret = -1; + goto error; + } + DBG("Metadata connection on client_socket"); + + /* Blocking call, waiting for transmission */ + ctx->consumer_metadata_socket = lttcomm_accept_unix_sock(client_socket); + if (ctx->consumer_metadata_socket < 0) { + WARN("On accept metadata"); + ret = -1; + goto error; + } + ret = 0; + +error: + return ret; +} + /* * This thread listens on the consumerd socket and receives the file * descriptors from the session daemon. @@ -2773,6 +2807,15 @@ void *consumer_thread_sessiond_poll(void *data) goto end; } + /* + * Setup metadata socket which is the second socket connection on the + * command unix socket. + */ + ret = set_metadata_socket(ctx, consumer_sockpoll, client_socket); + if (ret < 0) { + goto end; + } + /* This socket is not useful anymore. */ ret = close(client_socket); if (ret < 0) { diff --git a/src/common/consumer.h b/src/common/consumer.h index 82b9bc6..4638752 100644 --- a/src/common/consumer.h +++ b/src/common/consumer.h @@ -89,6 +89,9 @@ struct stream_list { unsigned int count; }; +/* Stub. */ +struct consumer_metadata_cache; + struct lttng_consumer_channel { /* HT node used for consumer_data.channel_ht */ struct lttng_ht_node_u64 node; @@ -132,16 +135,17 @@ struct lttng_consumer_channel { * regular channel, this is always set to NULL. */ struct lttng_consumer_stream *metadata_stream; - /* - * Metadata written so far. Helps keeping track of - * contiguousness and order. - */ - uint64_t contig_metadata_written; /* for UST */ int wait_fd; /* Node within channel thread ht */ struct lttng_ht_node_u64 wait_fd_node; + + /* Metadata cache is metadata channel */ + struct consumer_metadata_cache *metadata_cache; + /* For metadata periodical flush */ + int switch_timer_enabled; + timer_t switch_timer; }; /* @@ -322,8 +326,11 @@ struct lttng_consumer_local_data { * < 0 (error) */ int (*on_update_stream)(int sessiond_key, uint32_t state); + enum lttng_consumer_type type; /* socket to communicate errors with sessiond */ int consumer_error_socket; + /* socket to ask metadata to sessiond */ + int consumer_metadata_socket; /* socket to exchange commands with sessiond */ char *consumer_command_sock_path; /* communication with splice */ diff --git a/src/common/defaults.h b/src/common/defaults.h index 658e7d3..94a2a35 100644 --- a/src/common/defaults.h +++ b/src/common/defaults.h @@ -76,7 +76,6 @@ #define DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/command" #define DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/error" - /* Default lttng run directory */ #define DEFAULT_LTTNG_RUNDIR "/var/run/lttng" #define DEFAULT_LTTNG_HOME_RUNDIR "%s/.lttng" @@ -124,6 +123,7 @@ #define DEFAULT_METADATA_SUBBUF_SIZE 4096 #define DEFAULT_METADATA_SUBBUF_NUM 2 +#define DEFAULT_METADATA_CACHE_SIZE 4096 /* Kernel has different defaults */ @@ -179,6 +179,12 @@ #define DEFAULT_DATA_AVAILABILITY_WAIT_TIME 200000 /* usec */ /* + * Wait period before retrying the lttng_consumer_flushed_cache when + * the consumer receives metadata. + */ +#define DEFAULT_METADATA_AVAILABILITY_WAIT_TIME 200000 /* usec */ + +/* * Default receiving and sending timeout for an application socket. */ #define DEFAULT_APP_SOCKET_RW_TIMEOUT 5 /* sec */ diff --git a/src/common/macros.h b/src/common/macros.h index f6f975d..fc159c0 100644 --- a/src/common/macros.h +++ b/src/common/macros.h @@ -56,6 +56,10 @@ #define max(a, b) ((a) > (b) ? (a) : (b)) #endif +#ifndef max_t +#define max_t(type, a, b) ((type) max(a, b)) +#endif + #ifndef min #define min(a, b) ((a) < (b) ? (a) : (b)) #endif diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 6350fd1..cb5a88b 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -138,6 +138,21 @@ enum lttcomm_sock_domain { LTTCOMM_INET6 = 1, }; +enum lttcomm_metadata_command { + LTTCOMM_METADATA_REQUEST = 1, +}; + +/* + * Commands sent from the consumerd to the sessiond to request + * if new metadata is available + */ +struct lttcomm_metadata_request_msg { + unsigned int session_id; /* Tracing session id */ + uint32_t bits_per_long; /* Consumer ABI */ + uint32_t uid; + uint64_t key; /* Metadata channel key. */ +} LTTNG_PACKED; + struct lttcomm_sockaddr { enum lttcomm_sock_domain type; union { diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 06b59c5..e56f023 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -30,11 +30,14 @@ #include #include #include +#include #include #include #include #include +#include +#include #include "ust-consumer.h" @@ -530,10 +533,12 @@ error: /* * Write metadata to the given channel using ustctl to convert the string to * the ringbuffer. + * Called only from consumer_metadata_cache_write. + * The metadata cache lock MUST be acquired to write in the cache. * * Return 0 on success else a negative value. */ -static int push_metadata(struct lttng_consumer_channel *metadata, +int lttng_ustconsumer_push_metadata(struct lttng_consumer_channel *metadata, const char *metadata_str, uint64_t target_offset, uint64_t len) { int ret; @@ -543,13 +548,13 @@ static int push_metadata(struct lttng_consumer_channel *metadata, DBG("UST consumer writing metadata to channel %s", metadata->name); - assert(target_offset == metadata->contig_metadata_written); + assert(target_offset <= metadata->metadata_cache->max_offset); ret = ustctl_write_metadata_to_channel(metadata->uchan, metadata_str, len); if (ret < 0) { ERR("ustctl write metadata fail with ret %d, len %ld", ret, len); goto error; } - metadata->contig_metadata_written += len; + metadata->metadata_cache->rb_pushed += len; ustctl_flush_buffer(metadata->metadata_stream->ustream, 1); @@ -619,6 +624,11 @@ static int close_metadata(uint64_t chan_key) ret = LTTCOMM_CONSUMERD_ERROR_METADATA; goto error; } + if (channel->switch_timer_enabled == 1) { + DBG("Deleting timer on metadata channel"); + consumer_timer_switch_stop(channel); + } + consumer_metadata_cache_destroy(channel); error: return ret; @@ -679,6 +689,51 @@ error: } /* + * Receive the metadata updates from the sessiond. + */ +int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset, + uint64_t len, struct lttng_consumer_channel *channel) +{ + int ret, ret_code = LTTNG_OK; + char *metadata_str; + + DBG("UST consumer push metadata key %lu of len %lu", key, len); + + metadata_str = zmalloc(len * sizeof(char)); + if (!metadata_str) { + PERROR("zmalloc metadata string"); + ret_code = LTTCOMM_CONSUMERD_ENOMEM; + goto end; + } + + /* Receive metadata string. */ + ret = lttcomm_recv_unix_sock(sock, metadata_str, len); + if (ret < 0) { + /* Session daemon is dead so return gracefully. */ + ret_code = ret; + goto end_free; + } + + pthread_mutex_lock(&channel->metadata_cache->lock); + ret = consumer_metadata_cache_write(channel, offset, len, metadata_str); + if (ret < 0) { + /* Unable to handle metadata. Notify session daemon. */ + ret_code = LTTCOMM_CONSUMERD_ERROR_METADATA; + } + pthread_mutex_unlock(&channel->metadata_cache->lock); + + while (consumer_metadata_cache_flushed(channel, offset + len)) { + DBG("Waiting for metadata to be flushed"); + usleep(DEFAULT_METADATA_AVAILABILITY_WAIT_TIME); + } + +end_free: + free(metadata_str); +end: + return ret_code; +} + +/* * Receive command from session daemon and process it. * * Return 1 on success else a negative value or 0. @@ -847,6 +902,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, goto end_channel_error; } + /* * Channel and streams are now created. Inform the session daemon that * everything went well and should wait to receive the channel and @@ -861,6 +917,16 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, goto end_nosignal; } + if (msg.u.ask_channel.type == LTTNG_UST_CHAN_METADATA) { + ret = consumer_metadata_cache_allocate(channel); + if (ret < 0) { + ERR("Allocating metadata cache"); + goto end_channel_error; + } + consumer_timer_switch_start(channel, attr.switch_timer_interval); + attr.switch_timer_interval = 0; + } + break; } case LTTNG_CONSUMER_GET_CHANNEL: @@ -957,10 +1023,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, { int ret; uint64_t len = msg.u.push_metadata.len; - uint64_t target_offset = msg.u.push_metadata.target_offset; uint64_t key = msg.u.push_metadata.key; + uint64_t offset = msg.u.push_metadata.target_offset; struct lttng_consumer_channel *channel; - char *metadata_str; DBG("UST consumer push metadata key %lu of len %lu", key, len); @@ -968,14 +1033,6 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, if (!channel) { ERR("UST consumer push metadata %lu not found", key); ret_code = LTTNG_ERR_UST_CHAN_NOT_FOUND; - goto end_msg_sessiond; - } - - metadata_str = zmalloc(len * sizeof(char)); - if (!metadata_str) { - PERROR("zmalloc metadata string"); - ret_code = LTTCOMM_CONSUMERD_ENOMEM; - goto end_msg_sessiond; } /* Tell session daemon we are ready to receive the metadata. */ @@ -990,22 +1047,15 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, goto end_nosignal; } - /* Receive metadata string. */ - ret = lttcomm_recv_unix_sock(sock, metadata_str, len); + ret = lttng_ustconsumer_recv_metadata(sock, key, offset, + len, channel); if (ret < 0) { - /* Session daemon is dead so return gracefully. */ + /* error receiving from sessiond */ goto end_nosignal; - } - - ret = push_metadata(channel, metadata_str, target_offset, len); - free(metadata_str); - if (ret < 0) { - /* Unable to handle metadata. Notify session daemon. */ - ret_code = LTTCOMM_CONSUMERD_ERROR_METADATA; + } else { + ret_code = ret; goto end_msg_sessiond; } - - goto end_msg_sessiond; } case LTTNG_CONSUMER_SETUP_METADATA: { @@ -1223,6 +1273,7 @@ int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream, } err = ustctl_put_next_subbuf(ustream); assert(err == 0); + end: return ret; } @@ -1343,3 +1394,96 @@ void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream) ERR("Unable to close wakeup fd"); } } + +int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx, + struct lttng_consumer_channel *channel) +{ + struct lttcomm_metadata_request_msg request; + struct lttcomm_consumer_msg msg; + enum lttng_error_code ret_code = LTTNG_OK; + uint64_t len, key, offset; + int ret; + + assert(channel); + assert(channel->metadata_cache); + + /* send the metadata request to sessiond */ + switch (consumer_data.type) { + case LTTNG_CONSUMER64_UST: + request.bits_per_long = 64; + break; + case LTTNG_CONSUMER32_UST: + request.bits_per_long = 32; + break; + default: + request.bits_per_long = 0; + break; + } + + request.session_id = channel->session_id; + request.uid = channel->uid; + request.key = channel->key; + DBG("Sending metadata request to sessiond, session %" PRIu64, + channel->session_id); + + ret = lttcomm_send_unix_sock(ctx->consumer_metadata_socket, &request, + sizeof(request)); + if (ret < 0) { + ERR("Asking metadata to sessiond"); + goto end; + } + + /* Receive the metadata from sessiond */ + ret = lttcomm_recv_unix_sock(ctx->consumer_metadata_socket, &msg, + sizeof(msg)); + if (ret != sizeof(msg)) { + DBG("Consumer received unexpected message size %d (expects %lu)", + ret, sizeof(msg)); + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_CMD); + /* + * The ret value might 0 meaning an orderly shutdown but this is ok + * since the caller handles this. + */ + goto end; + } + + if (msg.cmd_type == LTTNG_ERR_UND) { + /* No registry found */ + (void) consumer_send_status_msg(ctx->consumer_metadata_socket, + ret_code); + ret = 0; + goto end; + } else if (msg.cmd_type != LTTNG_CONSUMER_PUSH_METADATA) { + ERR("Unexpected cmd_type received %d", msg.cmd_type); + ret = -1; + goto end; + } + + len = msg.u.push_metadata.len; + key = msg.u.push_metadata.key; + offset = msg.u.push_metadata.target_offset; + + assert(key == channel->key); + if (len == 0) { + DBG("No new metadata to receive for key %" PRIu64, key); + } + + /* Tell session daemon we are ready to receive the metadata. */ + ret = consumer_send_status_msg(ctx->consumer_metadata_socket, + LTTNG_OK); + if (ret < 0 || len == 0) { + /* + * Somehow, the session daemon is not responding anymore or there is + * nothing to receive. + */ + goto end; + } + + ret_code = lttng_ustconsumer_recv_metadata(ctx->consumer_metadata_socket, + key, offset, len, channel); + (void) consumer_send_status_msg(ctx->consumer_metadata_socket, ret_code); + ret = 0; + +end: + return ret; +} diff --git a/src/common/ust-consumer/ust-consumer.h b/src/common/ust-consumer/ust-consumer.h index bbaff6c..d748582 100644 --- a/src/common/ust-consumer/ust-consumer.h +++ b/src/common/ust-consumer/ust-consumer.h @@ -51,6 +51,12 @@ void *lttng_ustctl_get_mmap_base(struct lttng_consumer_stream *stream); int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream); void lttng_ustconsumer_close_metadata(struct lttng_ht *ht); void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream); +int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset, + uint64_t len, struct lttng_consumer_channel *channel); +int lttng_ustconsumer_push_metadata(struct lttng_consumer_channel *metadata, + const char *metadata_str, uint64_t target_offset, uint64_t len); +int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx, + struct lttng_consumer_channel *channel); #else /* HAVE_LIBLTTNG_UST_CTL */ diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index a9d65ab..169ca2e 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -47,8 +47,9 @@ UST_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-ust.c \ $(top_srcdir)/src/bin/lttng-sessiond/ust-consumer.c \ $(top_srcdir)/src/bin/lttng-sessiond/fd-limit.c \ $(top_srcdir)/src/bin/lttng-sessiond/health.c \ - $(top_srcdir)/src/common/uri.c \ - $(top_srcdir)/src/common/utils.c + $(top_srcdir)/src/bin/lttng-sessiond/session.c \ + $(top_srcdir)/src/common/uri.c \ + $(top_srcdir)/src/common/utils.c test_ust_data_SOURCES = test_ust_data.c $(UST_DATA_TRACE) test_ust_data_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBSESSIOND_COMM) $(LIBHASHTABLE) \ -- 1.7.10.4 From mathieu.desnoyers at efficios.com Tue Mar 26 14:59:38 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Tue, 26 Mar 2013 14:59:38 -0400 Subject: [lttng-dev] [PATCH lttng-tools] UST periodical metadata flush In-Reply-To: <1364320199-30440-1-git-send-email-dgoulet@efficios.com> References: <1364320199-30440-1-git-send-email-dgoulet@efficios.com> Message-ID: <20130326185938.GA18985@Krystal> * David Goulet (dgoulet at efficios.com) wrote: > From: Julien Desfossez > > Add a socket between the sessiond and the ust-consumer to allow > periodical flush of the metadata channel. > > If enabled (by specifying the --switch-timer option on the metadata > channel), a new timer thread in the consumer asks the session daemon for > new metadata for a specific session. > > All the metadata collected is written into a metadata cache in the > consumer, this mechanism is useful for synchronisation (to avoid race > conditions between two metadata updates) and will also be useful when we > implement the snapshots. > > Signed-off-by: Julien Desfossez > Signed-off-by: David Goulet > --- > src/bin/lttng-consumerd/lttng-consumerd.c | 29 ++++ > src/bin/lttng-sessiond/consumer.c | 4 +- > src/bin/lttng-sessiond/consumer.h | 2 + > src/bin/lttng-sessiond/main.c | 147 +++++++++++++------- > src/bin/lttng-sessiond/ust-app.c | 109 +++++++++------ > src/bin/lttng-sessiond/ust-app.h | 8 ++ > src/bin/lttng-sessiond/ust-consumer.c | 77 ++++++++++ > src/bin/lttng-sessiond/ust-consumer.h | 1 + > src/common/Makefile.am | 6 +- > src/common/consumer-metadata-cache.c | 214 ++++++++++++++++++++++++++++ > src/common/consumer-metadata-cache.h | 58 ++++++++ > src/common/consumer-timer.c | 216 +++++++++++++++++++++++++++++ > src/common/consumer-timer.h | 49 +++++++ > src/common/consumer.c | 43 ++++++ > src/common/consumer.h | 17 ++- > src/common/defaults.h | 8 +- > src/common/macros.h | 4 + > src/common/sessiond-comm/sessiond-comm.h | 15 ++ > src/common/ust-consumer/ust-consumer.c | 194 ++++++++++++++++++++++---- > src/common/ust-consumer/ust-consumer.h | 6 + > tests/unit/Makefile.am | 5 +- > 21 files changed, 1082 insertions(+), 130 deletions(-) > create mode 100644 src/common/consumer-metadata-cache.c > create mode 100644 src/common/consumer-metadata-cache.h > create mode 100644 src/common/consumer-timer.c > create mode 100644 src/common/consumer-timer.h > > diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c > index 8486807..7ca9688 100644 > --- a/src/bin/lttng-consumerd/lttng-consumerd.c > +++ b/src/bin/lttng-consumerd/lttng-consumerd.c > @@ -44,6 +44,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -52,7 +53,9 @@ > /* TODO : support UST (all direct kernel-ctl accesses). */ > > /* threads (channel handling, poll, metadata, sessiond) */ > + > static pthread_t channel_thread, data_thread, metadata_thread, sessiond_thread; > +static pthread_t metadata_timer_thread; > > /* to count the number of times the user pressed ctrl+c */ > static int sigintcount = 0; > @@ -363,6 +366,15 @@ int main(int argc, char **argv) > } > lttng_consumer_set_error_sock(ctx, ret); > > + /* > + * For UST consumer, we block RT signals used for periodical metadata flush > + * in main and create a dedicated thread to handle these signals. > + */ > + if (opt_type != LTTNG_CONSUMER_KERNEL) { > + consumer_signal_init(); for each if (opt_type != LTTNG_CONSUMER_KERNEL) can you instead do : switch (opt_type) { case LTTNG_CONSUMER_KERNEL: break; case ... break; default: assert(0); } So if we add a new consumer type, it won't take the "else" for granted ? > + } > + ctx->type = opt_type; > + > /* Create thread to manage channels */ > ret = pthread_create(&channel_thread, NULL, consumer_thread_channel_poll, > (void *) ctx); > @@ -395,6 +407,23 @@ int main(int argc, char **argv) > goto sessiond_error; > } > > + if (opt_type != LTTNG_CONSUMER_KERNEL) { same here. > + /* Create the thread to manage the metadata periodic timers */ > + ret = pthread_create(&metadata_timer_thread, NULL, > + consumer_timer_metadata_thread, (void *) ctx); > + if (ret != 0) { > + perror("pthread_create"); > + goto metadata_timer_error; > + } > + > + ret = pthread_detach(metadata_timer_thread); > + if (ret) { > + errno = ret; > + perror("pthread_detach"); > + } Hrm, if pthread_detach fails, maybe we should join the metadata_timer_thread ? > + } > + > +metadata_timer_error: > ret = pthread_join(sessiond_thread, &status); > if (ret != 0) { > perror("pthread_join"); > diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c > index 57b5b19..6719051 100644 > --- a/src/bin/lttng-sessiond/consumer.c > +++ b/src/bin/lttng-sessiond/consumer.c > @@ -1072,7 +1072,7 @@ end: > } > > /* > - * Send metadata string to consumer. > + * Send metadata string to consumer. Socket lock MUST be acquired. > * > * Return 0 on success else a negative value. > */ > @@ -1103,7 +1103,7 @@ int consumer_push_metadata(struct consumer_socket *socket, > > health_code_update(); > ret = consumer_send_msg(socket, &msg); > - if (ret < 0) { > + if (ret < 0 || len == 0) { > goto end; > } > > diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h > index cde2d0d..b767589 100644 > --- a/src/bin/lttng-sessiond/consumer.h > +++ b/src/bin/lttng-sessiond/consumer.h > @@ -78,7 +78,9 @@ struct consumer_data { > pid_t pid; > > int err_sock; > + /* These two sockets uses the cmd_unix_sock_path. */ > int cmd_sock; > + struct consumer_socket metadata_sock; > > /* consumer error and command Unix socket path */ > char err_unix_sock_path[PATH_MAX]; > diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c > index d88bafe..a98b4f2 100644 > --- a/src/bin/lttng-sessiond/main.c > +++ b/src/bin/lttng-sessiond/main.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -89,6 +90,7 @@ static struct consumer_data kconsumer_data = { > .cmd_unix_sock_path = DEFAULT_KCONSUMERD_CMD_SOCK_PATH, > .err_sock = -1, > .cmd_sock = -1, > + .metadata_sock.fd = -1, > .pid_mutex = PTHREAD_MUTEX_INITIALIZER, > .lock = PTHREAD_MUTEX_INITIALIZER, > .cond = PTHREAD_COND_INITIALIZER, > @@ -100,6 +102,7 @@ static struct consumer_data ustconsumer64_data = { > .cmd_unix_sock_path = DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH, > .err_sock = -1, > .cmd_sock = -1, > + .metadata_sock.fd = -1, > .pid_mutex = PTHREAD_MUTEX_INITIALIZER, > .lock = PTHREAD_MUTEX_INITIALIZER, > .cond = PTHREAD_COND_INITIALIZER, > @@ -111,6 +114,7 @@ static struct consumer_data ustconsumer32_data = { > .cmd_unix_sock_path = DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH, > .err_sock = -1, > .cmd_sock = -1, > + .metadata_sock.fd = -1, > .pid_mutex = PTHREAD_MUTEX_INITIALIZER, > .lock = PTHREAD_MUTEX_INITIALIZER, > .cond = PTHREAD_COND_INITIALIZER, > @@ -865,10 +869,10 @@ static void *thread_manage_consumer(void *data) > health_code_update(); > > /* > - * Pass 2 as size here for the thread quit pipe and kconsumerd_err_sock. > - * Nothing more will be added to this poll set. > + * Pass 3 as size here for the thread quit pipe, consumerd_err_sock and the > + * metadata_sock. Nothing more will be added to this poll set. > */ > - ret = sessiond_set_thread_pollset(&events, 2); > + ret = sessiond_set_thread_pollset(&events, 3); > if (ret < 0) { > goto error_poll; > } > @@ -885,7 +889,7 @@ static void *thread_manage_consumer(void *data) > > health_code_update(); > > - /* Inifinite blocking call, waiting for transmission */ > + /* Infinite blocking call, waiting for transmission */ > restart: > health_poll_entry(); > > @@ -955,87 +959,126 @@ restart: > health_code_update(); > > if (code == LTTCOMM_CONSUMERD_COMMAND_SOCK_READY) { > + /* Connect both socket, command and metadata. */ > consumer_data->cmd_sock = > lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path); > - if (consumer_data->cmd_sock < 0) { > + consumer_data->metadata_sock.fd = > + lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path); > + if (consumer_data->cmd_sock < 0 || > + consumer_data->metadata_sock.fd < 0) { > + PERROR("consumer connect cmd socket"); > /* On error, signal condition and quit. */ > signal_consumer_condition(consumer_data, -1); > - PERROR("consumer connect"); > goto error; > } > + /* Create metadata socket lock. */ > + consumer_data->metadata_sock.lock = zmalloc(sizeof(pthread_mutex_t)); > + if (consumer_data->metadata_sock.lock == NULL) { > + PERROR("zmalloc pthread mutex"); > + ret = -1; > + goto error; > + } > + pthread_mutex_init(consumer_data->metadata_sock.lock, NULL); > + > signal_consumer_condition(consumer_data, 1); > - DBG("Consumer command socket ready"); > + DBG("Consumer command socket ready (fd: %d", consumer_data->cmd_sock); > + DBG("Consumer metadata socket ready (fd: %d)", > + consumer_data->metadata_sock.fd); > } else { > ERR("consumer error when waiting for SOCK_READY : %s", > lttcomm_get_readable_code(-code)); > goto error; > } > > - /* Remove the kconsumerd error sock since we've established a connexion */ > + /* Remove the consumerd error sock since we've established a connexion */ > ret = lttng_poll_del(&events, consumer_data->err_sock); > if (ret < 0) { > goto error; > } > > + /* Add new accepted error socket. */ > ret = lttng_poll_add(&events, sock, LPOLLIN | LPOLLRDHUP); > if (ret < 0) { > goto error; > } > > + /* Add metadata socket that is successfully connected. */ > + ret = lttng_poll_add(&events, consumer_data->metadata_sock.fd, > + LPOLLIN | LPOLLRDHUP); > + if (ret < 0) { > + goto error; > + } > + > health_code_update(); > > - /* Inifinite blocking call, waiting for transmission */ > + /* Infinite blocking call, waiting for transmission */ > restart_poll: > - health_poll_entry(); > - ret = lttng_poll_wait(&events, -1); > - health_poll_exit(); > - if (ret < 0) { > - /* > - * Restart interrupted system call. > - */ > - if (errno == EINTR) { > - goto restart_poll; > + while (1) { why are we getting this refactoring ? Is it necessary ? > + health_poll_entry(); > + ret = lttng_poll_wait(&events, -1); > + health_poll_exit(); > + if (ret < 0) { > + /* > + * Restart interrupted system call. > + */ > + if (errno == EINTR) { > + goto restart_poll; > + } > + goto error; > } > - goto error; > - } > > - nb_fd = ret; > + nb_fd = ret; > > - for (i = 0; i < nb_fd; i++) { > - /* Fetch once the poll data */ > - revents = LTTNG_POLL_GETEV(&events, i); > - pollfd = LTTNG_POLL_GETFD(&events, i); > + for (i = 0; i < nb_fd; i++) { > + /* Fetch once the poll data */ > + revents = LTTNG_POLL_GETEV(&events, i); > + pollfd = LTTNG_POLL_GETFD(&events, i); > > - health_code_update(); > + health_code_update(); > > - /* Thread quit pipe has been closed. Killing thread. */ > - ret = sessiond_check_thread_quit_pipe(pollfd, revents); > - if (ret) { > - err = 0; > - goto exit; > - } > + /* Thread quit pipe has been closed. Killing thread. */ > + ret = sessiond_check_thread_quit_pipe(pollfd, revents); > + if (ret) { > + err = 0; > + goto exit; > + } > > - /* Event on the kconsumerd socket */ > - if (pollfd == sock) { > - if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { > - ERR("consumer err socket second poll error"); > + if (pollfd == sock) { > + /* Event on the consumerd socket */ > + if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { > + ERR("consumer err socket second poll error"); > + goto error; > + } > + health_code_update(); > + /* Wait for any kconsumerd error */ > + ret = lttcomm_recv_unix_sock(sock, &code, > + sizeof(enum lttcomm_return_code)); > + if (ret <= 0) { > + ERR("consumer closed the command socket"); > + goto error; > + } > + > + ERR("consumer return code : %s", > + lttcomm_get_readable_code(-code)); > + > + goto exit; > + } else if (pollfd == consumer_data->metadata_sock.fd) { > + /* UST metadata requests */ > + ret = ust_consumer_metadata_request( > + &consumer_data->metadata_sock); > + if (ret < 0) { > + ERR("Handling metadata request"); > + goto error; > + } > + break; > + } else { > + ERR("Unknown pollfd"); > goto error; > } > } > + health_code_update(); > } > > - health_code_update(); > - > - /* Wait for any kconsumerd error */ > - ret = lttcomm_recv_unix_sock(sock, &code, > - sizeof(enum lttcomm_return_code)); > - if (ret <= 0) { > - ERR("consumer closed the command socket"); > - goto error; > - } > - > - ERR("consumer return code : %s", lttcomm_get_readable_code(-code)); > - > exit: > error: > /* Immediately set the consumerd state to stopped */ > @@ -1061,6 +1104,12 @@ error: > PERROR("close"); > } > } > + if (consumer_data->metadata_sock.fd >= 0) { > + ret = close(consumer_data->metadata_sock.fd); > + if (ret) { > + PERROR("close"); > + } > + } > if (sock >= 0) { > ret = close(sock); > if (ret) { > @@ -2011,7 +2060,7 @@ end: > return 0; > > error: > - /* Cleanup already created socket on error. */ > + /* Cleanup already created sockets on error. */ > if (consumer_data->err_sock >= 0) { > int err; > > diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c > index 979ae7c..2cb92e4 100644 > --- a/src/bin/lttng-sessiond/ust-app.c > +++ b/src/bin/lttng-sessiond/ust-app.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -368,17 +369,72 @@ void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan, > } > > /* > + * Push metadata to consumer socket. The socket lock MUST be acquired. > + * > + * On success, return the len of metadata pushed or else a negative value. > + */ > +ssize_t ust_app_push_metadata(struct ust_registry_session *registry, > + struct consumer_socket *socket) > +{ > + int ret; > + char *metadata_str = NULL; > + size_t len, offset; > + ssize_t ret_val; > + > + assert(registry); > + assert(socket); > + > + pthread_mutex_lock(®istry->lock); > + > + offset = registry->metadata_len_sent; > + len = registry->metadata_len - registry->metadata_len_sent; > + if (len == 0) { > + DBG3("No metadata to push for metadata key %" PRIu64, > + registry->metadata_key); > + goto end; > + } > + > + /* Allocate only what we have to send. */ > + metadata_str = zmalloc(len); > + if (!metadata_str) { > + PERROR("zmalloc ust app metadata string"); > + ret_val = -ENOMEM; > + goto error; > + } > + /* Copy what we haven't send out. */ > + memcpy(metadata_str, registry->metadata + offset, len); > + > + ret = consumer_push_metadata(socket, registry->metadata_key, > + metadata_str, len, offset); I think consumer_push_metadata() sends metadata to consumerd. This is done with the registry lock held. This should _not_ be done. The registry lock _needs_ to be held only for short periods of time. > + if (ret < 0) { > + ret_val = ret; > + goto error; > + } > + > + registry->metadata_len_sent += len; > + > +end: > + ret_val = len; > +error: > + free(metadata_str); > + pthread_mutex_unlock(®istry->lock); > + return ret_val; > +} > + > +/* > * For a given application and session, push metadata to consumer. The session > * lock MUST be acquired here before calling this. > + * Either sock or consumer is required : if sock is NULL, the default > + * socket to send the metadata is retrieved from consumer, if sock > + * is not NULL we use it to send the metadata. > * > * Return 0 on success else a negative error. > */ > static int push_metadata(struct ust_registry_session *registry, > struct consumer_output *consumer) > { > - int ret; > - char *metadata_str = NULL; > - size_t len, offset; > + int ret_val; > + ssize_t ret; > struct consumer_socket *socket; > > assert(registry); > @@ -391,7 +447,7 @@ static int push_metadata(struct ust_registry_session *registry, > * no start has been done previously. > */ > if (!registry->metadata_key) { > - ret = 0; > + ret_val = 0; > goto error_rcu_unlock; > } > > @@ -399,7 +455,7 @@ static int push_metadata(struct ust_registry_session *registry, > socket = consumer_find_socket_by_bitness(registry->bits_per_long, > consumer); > if (!socket) { > - ret = -1; > + ret_val = -1; > goto error_rcu_unlock; > } > > @@ -414,54 +470,19 @@ static int push_metadata(struct ust_registry_session *registry, > * ability to reorder the metadata it receives. > */ > pthread_mutex_lock(socket->lock); > - pthread_mutex_lock(®istry->lock); > - > - offset = registry->metadata_len_sent; > - len = registry->metadata_len - registry->metadata_len_sent; > - if (len == 0) { > - DBG3("No metadata to push for metadata key %" PRIu64, > - registry->metadata_key); > - ret = 0; > - goto error_reg_unlock; > - } > - assert(len > 0); > - > - /* Allocate only what we have to send. */ > - metadata_str = zmalloc(len); > - if (!metadata_str) { > - PERROR("zmalloc ust app metadata string"); > - ret = -ENOMEM; > - goto error_reg_unlock; > - } > - /* Copy what we haven't send out. */ > - memcpy(metadata_str, registry->metadata + offset, len); > - > - pthread_mutex_unlock(®istry->lock); > - > - ret = consumer_push_metadata(socket, registry->metadata_key, > - metadata_str, len, offset); > + ret = ust_app_push_metadata(registry, socket); > + pthread_mutex_unlock(socket->lock); > if (ret < 0) { > - pthread_mutex_unlock(socket->lock); > + ret_val = ret; > goto error_rcu_unlock; > } > > - /* Update len sent of the registry. */ > - pthread_mutex_lock(®istry->lock); > - registry->metadata_len_sent += len; > - pthread_mutex_unlock(®istry->lock); > - pthread_mutex_unlock(socket->lock); > - > rcu_read_unlock(); > - free(metadata_str); > return 0; > > -error_reg_unlock: > - pthread_mutex_unlock(®istry->lock); > - pthread_mutex_unlock(socket->lock); > error_rcu_unlock: > rcu_read_unlock(); > - free(metadata_str); > - return ret; > + return ret_val; > } > > /* > diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h > index 67088a7..776dc0e 100644 > --- a/src/bin/lttng-sessiond/ust-app.h > +++ b/src/bin/lttng-sessiond/ust-app.h > @@ -299,6 +299,8 @@ int ust_app_recv_notify(int sock); > void ust_app_add(struct ust_app *app); > struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock); > void ust_app_notify_sock_unregister(int sock); > +ssize_t ust_app_push_metadata(struct ust_registry_session *registry, > + struct consumer_socket *socket); > > #else /* HAVE_LIBLTTNG_UST_CTL */ > > @@ -485,6 +487,12 @@ static inline > void ust_app_notify_sock_unregister(int sock) > { > } > +static inline > +ssize_t ust_app_push_metadata(struct ust_registry_session *registry, > + struct consumer_socket *socket) > +{ > + return 0; > +} > > #endif /* HAVE_LIBLTTNG_UST_CTL */ > > diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c > index ba74112..2b6f813 100644 > --- a/src/bin/lttng-sessiond/ust-consumer.c > +++ b/src/bin/lttng-sessiond/ust-consumer.c > @@ -30,6 +30,8 @@ > #include "consumer.h" > #include "health.h" > #include "ust-consumer.h" > +#include "buffer-registry.h" > +#include "session.h" > > /* > * Return allocated full pathname of the session using the consumer trace path > @@ -405,3 +407,78 @@ int ust_consumer_send_channel_to_ust(struct ust_app *app, > error: > return ret; > } > + > +/* > + * Handle the metadata requests from the UST consumer > + * > + * Return 0 on success else a negative value. > + */ > +int ust_consumer_metadata_request(struct consumer_socket *socket) > +{ > + int ret; > + ssize_t ret_push; > + struct lttcomm_metadata_request_msg request; > + struct buffer_reg_uid *reg_uid; > + struct ust_registry_session *ust_reg; > + struct lttcomm_consumer_msg msg; > + uint64_t len; > + > + assert(socket); > + > + rcu_read_lock(); > + pthread_mutex_lock(socket->lock); > + > + health_code_update(); > + > + /* Wait for a metadata request */ > + ret = lttcomm_recv_unix_sock(socket->fd, &request, sizeof(request)); > + if (ret <= 0) { > + ERR("Consumer closed the metadata socket"); > + ret = -1; > + goto end; > + } > + > + DBG("Metadata request received for session %u, key %" PRIu64, > + request.session_id, request.key); > + > + reg_uid = buffer_reg_uid_find(request.session_id, > + request.bits_per_long, request.uid); > + if (reg_uid) { > + ust_reg = reg_uid->registry->reg.ust; > + } else { > + struct buffer_reg_pid *reg_pid = > + buffer_reg_pid_find(request.session_id); > + if (!reg_pid) { > + DBG("PID registry not found for session id %u", > + request.session_id); > + > + msg.cmd_type = LTTNG_ERR_UND; > + (void) consumer_send_msg(socket, &msg); > + ret = -1; > + goto end; > + } > + ust_reg = reg_pid->registry->reg.ust; > + } > + assert(ust_reg); > + > + len = ust_reg->metadata_len - ust_reg->metadata_len_sent; > + if (len == 0) { > + DBG("No metadata to push"); > + ret = consumer_push_metadata(socket, request.key, NULL, len, 0); > + goto end; > + } > + > + ret_push = ust_app_push_metadata(ust_reg, socket); > + if (ret_push < 0) { > + ERR("Pushing metadata"); > + ret = -1; > + goto end; > + } > + DBG("UST Consumer metadata pushed successfully"); > + ret = 0; > + > +end: > + pthread_mutex_unlock(socket->lock); > + rcu_read_unlock(); > + return ret; > +} > diff --git a/src/bin/lttng-sessiond/ust-consumer.h b/src/bin/lttng-sessiond/ust-consumer.h > index f5f63d9..d378202 100644 > --- a/src/bin/lttng-sessiond/ust-consumer.h > +++ b/src/bin/lttng-sessiond/ust-consumer.h > @@ -36,5 +36,6 @@ int ust_consumer_send_stream_to_ust(struct ust_app *app, > > int ust_consumer_send_channel_to_ust(struct ust_app *app, > struct ust_app_session *ua_sess, struct ust_app_channel *channel); > +int ust_consumer_metadata_request(struct consumer_socket *sock); > > #endif /* _UST_CONSUMER_H */ > diff --git a/src/common/Makefile.am b/src/common/Makefile.am > index c3a947a..f2ea40a 100644 > --- a/src/common/Makefile.am > +++ b/src/common/Makefile.am > @@ -6,7 +6,8 @@ SUBDIRS = compat hashtable kernel-ctl sessiond-comm relayd \ > AM_CFLAGS = -fno-strict-aliasing > > noinst_HEADERS = lttng-kernel.h defaults.h macros.h error.h futex.h \ > - uri.h utils.h lttng-kernel-old.h > + uri.h utils.h lttng-kernel-old.h \ > + consumer-metadata-cache.h consumer-timer.h > > # Common library > noinst_LTLIBRARIES = libcommon.la > @@ -18,7 +19,8 @@ libcommon_la_LIBADD = -luuid > # Consumer library > noinst_LTLIBRARIES += libconsumer.la > > -libconsumer_la_SOURCES = consumer.c consumer.h > +libconsumer_la_SOURCES = consumer.c consumer.h consumer-metadata-cache.c \ > + consumer-timer.c > > libconsumer_la_LIBADD = \ > $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \ > diff --git a/src/common/consumer-metadata-cache.c b/src/common/consumer-metadata-cache.c > new file mode 100644 > index 0000000..979521f > --- /dev/null > +++ b/src/common/consumer-metadata-cache.c > @@ -0,0 +1,214 @@ > +/* > + * Copyright (C) 2013 - Julien Desfossez > + * David Goulet > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License, version 2 only, > + * as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, but WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + * more details. > + * > + * You should have received a copy of the GNU General Public License along > + * with this program; if not, write to the Free Software Foundation, Inc., > + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > + */ > + > +#define _GNU_SOURCE > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > + > +#include "consumer-metadata-cache.h" > + > +/* > + * Extend the allocated size of the metadata cache. Called only from > + * lttng_ustconsumer_write_metadata_cache. > + * > + * Return 0 on success, a negative value on error. > + */ > +static int extend_metadata_cache(struct lttng_consumer_channel *channel, > + unsigned int size) > +{ > + int ret = 0; > + char *tmp_data_ptr; > + unsigned int new_size; > + > + assert(channel); > + assert(channel->metadata_cache); > + > + new_size = max_t(unsigned int, > + channel->metadata_cache->cache_alloc_size + size, > + channel->metadata_cache->cache_alloc_size << 1); > + DBG("Extending metadata cache to %u", new_size); > + tmp_data_ptr = realloc(channel->metadata_cache->data, new_size); > + if (!tmp_data_ptr) { > + ERR("Reallocating metadata cache"); > + free(channel->metadata_cache->data); > + ret = -1; > + goto end; > + } > + channel->metadata_cache->data = tmp_data_ptr; > + channel->metadata_cache->cache_alloc_size = new_size; > + > +end: > + return ret; > +} > + > +/* > + * Write metadata to the cache, extend the cache if necessary. We support > + * non-contiguous updates but not overlapping ones. If there is contiguous > + * metadata in the cache, we send it to the ring buffer. The metadata cache > + * lock MUST be acquired to write in the cache. > + * > + * Return 0 on success, a negative value on error. > + */ > +int consumer_metadata_cache_write(struct lttng_consumer_channel *channel, > + unsigned int offset, unsigned int len, char *data) > +{ > + int ret = 0; > + struct consumer_metadata_cache *cache; > + > + assert(channel); > + assert(channel->metadata_cache); > + > + cache = channel->metadata_cache; > + DBG("Writing %u bytes from offset %u in metadata cache", > + len, offset); > + > + if (offset + len > cache->cache_alloc_size) { > + ret = extend_metadata_cache(channel, > + len - cache->cache_alloc_size + offset); > + if (ret < 0) { > + ERR("Extending metadata cache"); > + goto end; > + } > + } > + > + memcpy(cache->data + offset, data, len); > + cache->total_bytes_written += len; > + if (offset + len > cache->max_offset) { > + cache->max_offset = offset + len; > + } > + > + if (cache->max_offset == cache->total_bytes_written) { > + offset = cache->rb_pushed; > + len = cache->total_bytes_written - cache->rb_pushed; > + ret = lttng_ustconsumer_push_metadata(channel, cache->data, offset, > + len); > + if (ret < 0) { > + ERR("Pushing metadata"); > + goto end; > + } > + cache->rb_pushed += len; > + } > + > +end: > + return ret; > +} > + > +/* > + * Create the metadata cache, original allocated size: max_sb_size > + * > + * Return 0 on success, a negative value on error. > + */ > +int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel) > +{ > + int ret; > + > + assert(channel); > + > + channel->metadata_cache = zmalloc( > + sizeof(struct consumer_metadata_cache)); > + if (!channel->metadata_cache) { > + PERROR("zmalloc metadata cache struct"); > + ret = -1; > + goto end; > + } > + ret = pthread_mutex_init(&channel->metadata_cache->lock, NULL); > + if (ret != 0) { > + PERROR("mutex init"); > + goto end_free_cache; > + } > + > + channel->metadata_cache->cache_alloc_size = DEFAULT_METADATA_CACHE_SIZE; > + channel->metadata_cache->data = zmalloc( > + channel->metadata_cache->cache_alloc_size * sizeof(char)); > + if (!channel->metadata_cache->data) { > + PERROR("zmalloc metadata cache data"); > + ret = -1; > + goto end_free_mutex; > + } > + DBG("Allocated metadata cache of %" PRIu64 " bytes", > + channel->metadata_cache->cache_alloc_size); > + > + ret = 0; > + goto end; > + > +end_free_mutex: > + pthread_mutex_destroy(&channel->metadata_cache->lock); > +end_free_cache: > + free(channel->metadata_cache); > +end: > + return ret; > +} > + > +/* > + * Destroy and free the metadata cache > + */ > +void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel) > +{ > + if (!channel || !channel->metadata_cache) { > + return; > + } > + > + DBG("Destroying metadata cache"); > + > + if (channel->metadata_cache->max_offset > > + channel->metadata_cache->rb_pushed) { > + ERR("Destroying a cache not entirely commited"); > + } > + > + pthread_mutex_destroy(&channel->metadata_cache->lock); > + free(channel->metadata_cache->data); > + free(channel->metadata_cache); > +} > + > +/* > + * Check if the cache is flushed up to the offset passed in parameter. > + * > + * Return 0 if everything has been flushed, 1 if there is data not flushed. > + */ > +int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, > + uint64_t offset) > +{ > + int ret; > + struct consumer_metadata_cache *cache; > + > + assert(channel); > + assert(channel->metadata_cache); > + > + cache = channel->metadata_cache; > + > + pthread_mutex_lock(&channel->metadata_cache->lock); > + if (cache->rb_pushed >= offset) { > + ret = 0; > + } else { > + ret = 1; > + } > + pthread_mutex_unlock(&channel->metadata_cache->lock); > + > + return ret; > +} > diff --git a/src/common/consumer-metadata-cache.h b/src/common/consumer-metadata-cache.h > new file mode 100644 > index 0000000..1d76b50 > --- /dev/null > +++ b/src/common/consumer-metadata-cache.h > @@ -0,0 +1,58 @@ > +/* > + * Copyright (C) 2013 - Julien Desfossez > + * David Goulet > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License, version 2 only, > + * as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, but WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + * more details. > + * > + * You should have received a copy of the GNU General Public License along > + * with this program; if not, write to the Free Software Foundation, Inc., > + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > + */ > + > +#ifndef CONSUMER_METADATA_CACHE_H > +#define CONSUMER_METADATA_CACHE_H > + > +#include > + > +struct consumer_metadata_cache { > + char *data; > + uint64_t cache_alloc_size; > + /* > + * How many bytes from the cache were already sent to > + * the ring buffer missing . at end of sentence. ;-) > + */ > + uint64_t rb_pushed; > + /* > + * How many bytes are written in the buffer (excluding the wholes) same here. > + */ > + uint64_t total_bytes_written; > + /* > + * The upper-limit of data written inside the buffer. > + * > + * With the total_bytes_written it allows us to keep track of when the > + * cache contains contiguous metadata ready to be sent to the RB. > + * The metadata cache updates must not overlap. > + */ > + uint64_t max_offset; > + /* > + * Lock to update the metadata cache and push into the > + * ring_buffer (ustctl_write_metadata_to_channel) same. > + */ > + pthread_mutex_t lock; > +}; > + > +int consumer_metadata_cache_write(struct lttng_consumer_channel *channel, > + unsigned int offset, unsigned int len, char *data); > +int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel); > +void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel); > +int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, > + uint64_t offset); > + > +#endif /* CONSUMER_METADATA_CACHE_H */ > diff --git a/src/common/consumer-timer.c b/src/common/consumer-timer.c > new file mode 100644 > index 0000000..80087fd > --- /dev/null > +++ b/src/common/consumer-timer.c > @@ -0,0 +1,216 @@ > +/* > + * Copyright (C) 2012 - Julien Desfossez > + * David Goulet > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License, version 2 only, as > + * published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, but WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + * more details. > + * > + * You should have received a copy of the GNU General Public License along with > + * this program; if not, write to the Free Software Foundation, Inc., 51 > + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > + */ > + > +#define _GNU_SOURCE > +#include > +#include > +#include > + > +#include > + > +#include "consumer-timer.h" > +#include "ust-consumer/ust-consumer.h" > + > +static struct timer_signal_data timer_signal; > + > +/* > + * Set custom signal mask to current thread. > + */ > +static void setmask(sigset_t *mask) > +{ > + int ret; > + > + ret = sigemptyset(mask); > + if (ret) { > + PERROR("sigemptyset"); > + } > + ret = sigaddset(mask, LTTNG_CONSUMER_SIG_SWITCH); > + if (ret) { > + PERROR("sigaddset"); > + } > + ret = sigaddset(mask, LTTNG_CONSUMER_SIG_TEARDOWN); > + if (ret) { > + PERROR("sigaddset"); > + } > +} > + > +/* > + * Execute action on a timer switch. > + */ > +static void metadata_switch_timer(struct lttng_consumer_local_data *ctx, > + int sig, siginfo_t *si, void *uc) > +{ > + struct lttng_consumer_channel *channel; > + > + channel = si->si_value.sival_ptr; > + assert(channel); > + > + DBG("Switch timer for channel %" PRIu64, channel->key); > + switch (ctx->type) { > + case LTTNG_CONSUMER32_UST: > + case LTTNG_CONSUMER64_UST: > + (void) lttng_ustconsumer_request_metadata(ctx, channel); > + break; > + case LTTNG_CONSUMER_KERNEL: > + case LTTNG_CONSUMER_UNKNOWN: > + assert(0); > + break; > + } > +} > + > +/* > + * Set the timer for periodical metadata flush. > + */ > +void consumer_timer_switch_start(struct lttng_consumer_channel *channel, > + unsigned int switch_timer_interval) > +{ > + int ret; > + struct sigevent sev; > + struct itimerspec its; > + > + if (switch_timer_interval == 0) { > + return; > + } > + > + sev.sigev_notify = SIGEV_SIGNAL; > + sev.sigev_signo = LTTNG_CONSUMER_SIG_SWITCH; > + sev.sigev_value.sival_ptr = channel; > + ret = timer_create(CLOCKID, &sev, &channel->switch_timer); > + if (ret == -1) { > + PERROR("timer_create"); > + } > + channel->switch_timer_enabled = 1; > + > + its.it_value.tv_sec = switch_timer_interval / 1000000; > + its.it_value.tv_nsec = switch_timer_interval % 1000000; > + its.it_interval.tv_sec = its.it_value.tv_sec; > + its.it_interval.tv_nsec = its.it_value.tv_nsec; > + > + ret = timer_settime(channel->switch_timer, 0, &its, NULL); > + if (ret == -1) { > + PERROR("timer_settime"); > + } > +} > + > +/* > + * Stop and delete timer. > + */ > +void consumer_timer_switch_stop(struct lttng_consumer_channel *channel) > +{ > + int ret; > + sigset_t pending_set; > + > + assert(channel); > + > + ret = timer_delete(channel->switch_timer); > + if (ret == -1) { > + PERROR("timer_delete"); > + } > + > + /* Ensure we don't have any signal queued for this channel. */ > + for (;;) { > + ret = sigemptyset(&pending_set); > + if (ret == -1) { > + PERROR("sigemptyset"); > + } > + ret = sigpending(&pending_set); > + if (ret == -1) { > + PERROR("sigpending"); > + } > + if (!sigismember(&pending_set, LTTNG_CONSUMER_SIG_SWITCH)) { > + break; > + } > + caa_cpu_relax(); > + } > + > + /* > + * From this point, no new signal handler will be fired that would try to > + * access "chan". However, we still need to wait for any currently > + * executing handler to complete. > + */ > + cmm_smp_mb(); > + CMM_STORE_SHARED(timer_signal.qs_done, 0); > + cmm_smp_mb(); > + > + /* > + * Kill with LTTNG_CONSUMER_SIG_TEARDOWN, so signal management thread wakes > + * up. > + */ > + kill(getpid(), LTTNG_CONSUMER_SIG_TEARDOWN); > + > + while (!CMM_LOAD_SHARED(timer_signal.qs_done)) { > + caa_cpu_relax(); > + } > + cmm_smp_mb(); > +} > + > +/* > + * Block the RT signals for the entire process. It must be called from the > + * consumer main before creating the threads > + */ > +void consumer_signal_init(void) > +{ > + int ret; > + sigset_t mask; > + > + /* Block signal for entire process, so only our thread processes it. */ > + setmask(&mask); > + ret = pthread_sigmask(SIG_BLOCK, &mask, NULL); > + if (ret) { > + errno = ret; > + PERROR("pthread_sigmask"); > + } > +} > + > +/* > + * This thread is the sighandler for signals LTTNG_CONSUMER_SIG_SWITCH and > + * LTTNG_CONSUMER_SIG_TEARDOWN that are emitted by the periodic timer to check > + * if new metadata is available. > + */ > +void *consumer_timer_metadata_thread(void *data) > +{ > + int signr; > + sigset_t mask; > + siginfo_t info; > + struct lttng_consumer_local_data *ctx = data; > + > + /* Only self thread will receive signal mask. */ > + setmask(&mask); > + CMM_STORE_SHARED(timer_signal.tid, pthread_self()); > + > + while (1) { > + signr = sigwaitinfo(&mask, &info); > + if (signr == -1) { > + if (errno != EINTR) { > + PERROR("sigwaitinfo"); > + } > + continue; > + } else if (signr == LTTNG_CONSUMER_SIG_SWITCH) { > + metadata_switch_timer(ctx, info.si_signo, &info, NULL); > + } else if (signr == LTTNG_CONSUMER_SIG_TEARDOWN) { > + cmm_smp_mb(); > + CMM_STORE_SHARED(timer_signal.qs_done, 1); > + cmm_smp_mb(); > + DBG("Signal timer metadata thread teardown"); > + } else { > + ERR("Unexpected signal %d\n", info.si_signo); > + } > + } > + > + return NULL; > +} > diff --git a/src/common/consumer-timer.h b/src/common/consumer-timer.h > new file mode 100644 > index 0000000..8406158 > --- /dev/null > +++ b/src/common/consumer-timer.h > @@ -0,0 +1,49 @@ > +/* > + * Copyright (C) 2011 - Julien Desfossez > + * Mathieu Desnoyers > + * 2012 - David Goulet > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License, version 2 only, > + * as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, but WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + * more details. > + * > + * You should have received a copy of the GNU General Public License along > + * with this program; if not, write to the Free Software Foundation, Inc., > + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > + */ > + > +#ifndef CONSUMER_TIMER_H > +#define CONSUMER_TIMER_H > + > +#include > + > +#include "consumer.h" > + > +#define LTTNG_CONSUMER_SIG_SWITCH SIGRTMIN + 10 > +#define LTTNG_CONSUMER_SIG_TEARDOWN SIGRTMIN + 11 > + > +#define CLOCKID CLOCK_MONOTONIC > + > +/* > + * Handle timer teardown race wrt memory free of private data by consumer > + * signals are handled by a single thread, which permits a synchronization > + * point between handling of each signal. > + */ > +struct timer_signal_data { > + pthread_t tid; /* thread id managing signals */ > + int setup_done; > + int qs_done; > +}; > + > +void consumer_timer_switch_start(struct lttng_consumer_channel *channel, > + unsigned int switch_timer_interval); > +void consumer_timer_switch_stop(struct lttng_consumer_channel *channel); > +void *consumer_timer_metadata_thread(void *data); > +void consumer_signal_init(void); > + > +#endif /* CONSUMER_TIMER_H */ > diff --git a/src/common/consumer.c b/src/common/consumer.c > index 29bd0c0..5f87f4b 100644 > --- a/src/common/consumer.c > +++ b/src/common/consumer.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -1141,6 +1142,7 @@ struct lttng_consumer_local_data *lttng_consumer_create( > } > > ctx->consumer_error_socket = -1; > + ctx->consumer_metadata_socket = -1; > /* assign the callbacks */ > ctx->on_buffer_ready = buffer_ready; > ctx->on_recv_channel = recv_channel; > @@ -1227,6 +1229,10 @@ void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx) > if (ret) { > PERROR("close"); > } > + ret = close(ctx->consumer_metadata_socket); > + if (ret) { > + PERROR("close"); > + } > utils_close_pipe(ctx->consumer_thread_pipe); > utils_close_pipe(ctx->consumer_channel_pipe); > utils_close_pipe(ctx->consumer_data_pipe); > @@ -1328,6 +1334,7 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap( > goto end; > } > ret = lttng_ustctl_get_mmap_read_offset(stream, &mmap_offset); > + > break; > default: > ERR("Unknown consumer_data type"); > @@ -2707,6 +2714,33 @@ end_ht: > return NULL; > } > > +static int set_metadata_socket(struct lttng_consumer_local_data *ctx, > + struct pollfd *sockpoll, int client_socket) > +{ > + int ret; > + > + assert(ctx); > + assert(sockpoll); > + > + if (lttng_consumer_poll_socket(sockpoll) < 0) { > + ret = -1; > + goto error; > + } > + DBG("Metadata connection on client_socket"); > + > + /* Blocking call, waiting for transmission */ > + ctx->consumer_metadata_socket = lttcomm_accept_unix_sock(client_socket); > + if (ctx->consumer_metadata_socket < 0) { > + WARN("On accept metadata"); > + ret = -1; > + goto error; > + } > + ret = 0; > + > +error: > + return ret; > +} > + > /* > * This thread listens on the consumerd socket and receives the file > * descriptors from the session daemon. > @@ -2773,6 +2807,15 @@ void *consumer_thread_sessiond_poll(void *data) > goto end; > } > > + /* > + * Setup metadata socket which is the second socket connection on the > + * command unix socket. > + */ > + ret = set_metadata_socket(ctx, consumer_sockpoll, client_socket); > + if (ret < 0) { > + goto end; > + } > + > /* This socket is not useful anymore. */ > ret = close(client_socket); > if (ret < 0) { > diff --git a/src/common/consumer.h b/src/common/consumer.h > index 82b9bc6..4638752 100644 > --- a/src/common/consumer.h > +++ b/src/common/consumer.h > @@ -89,6 +89,9 @@ struct stream_list { > unsigned int count; > }; > > +/* Stub. */ > +struct consumer_metadata_cache; > + > struct lttng_consumer_channel { > /* HT node used for consumer_data.channel_ht */ > struct lttng_ht_node_u64 node; > @@ -132,16 +135,17 @@ struct lttng_consumer_channel { > * regular channel, this is always set to NULL. > */ > struct lttng_consumer_stream *metadata_stream; > - /* > - * Metadata written so far. Helps keeping track of > - * contiguousness and order. > - */ > - uint64_t contig_metadata_written; > > /* for UST */ > int wait_fd; > /* Node within channel thread ht */ > struct lttng_ht_node_u64 wait_fd_node; > + > + /* Metadata cache is metadata channel */ > + struct consumer_metadata_cache *metadata_cache; > + /* For metadata periodical flush */ > + int switch_timer_enabled; > + timer_t switch_timer; > }; > > /* > @@ -322,8 +326,11 @@ struct lttng_consumer_local_data { > * < 0 (error) > */ > int (*on_update_stream)(int sessiond_key, uint32_t state); > + enum lttng_consumer_type type; > /* socket to communicate errors with sessiond */ > int consumer_error_socket; > + /* socket to ask metadata to sessiond */ > + int consumer_metadata_socket; > /* socket to exchange commands with sessiond */ > char *consumer_command_sock_path; > /* communication with splice */ > diff --git a/src/common/defaults.h b/src/common/defaults.h > index 658e7d3..94a2a35 100644 > --- a/src/common/defaults.h > +++ b/src/common/defaults.h > @@ -76,7 +76,6 @@ > #define DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/command" > #define DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/error" > > - > /* Default lttng run directory */ > #define DEFAULT_LTTNG_RUNDIR "/var/run/lttng" > #define DEFAULT_LTTNG_HOME_RUNDIR "%s/.lttng" > @@ -124,6 +123,7 @@ > > #define DEFAULT_METADATA_SUBBUF_SIZE 4096 > #define DEFAULT_METADATA_SUBBUF_NUM 2 > +#define DEFAULT_METADATA_CACHE_SIZE 4096 > > /* Kernel has different defaults */ > > @@ -179,6 +179,12 @@ > #define DEFAULT_DATA_AVAILABILITY_WAIT_TIME 200000 /* usec */ > > /* > + * Wait period before retrying the lttng_consumer_flushed_cache when > + * the consumer receives metadata. > + */ > +#define DEFAULT_METADATA_AVAILABILITY_WAIT_TIME 200000 /* usec */ > + > +/* > * Default receiving and sending timeout for an application socket. > */ > #define DEFAULT_APP_SOCKET_RW_TIMEOUT 5 /* sec */ > diff --git a/src/common/macros.h b/src/common/macros.h > index f6f975d..fc159c0 100644 > --- a/src/common/macros.h > +++ b/src/common/macros.h > @@ -56,6 +56,10 @@ > #define max(a, b) ((a) > (b) ? (a) : (b)) > #endif > > +#ifndef max_t > +#define max_t(type, a, b) ((type) max(a, b)) > +#endif > + > #ifndef min > #define min(a, b) ((a) < (b) ? (a) : (b)) > #endif > diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h > index 6350fd1..cb5a88b 100644 > --- a/src/common/sessiond-comm/sessiond-comm.h > +++ b/src/common/sessiond-comm/sessiond-comm.h > @@ -138,6 +138,21 @@ enum lttcomm_sock_domain { > LTTCOMM_INET6 = 1, > }; > > +enum lttcomm_metadata_command { > + LTTCOMM_METADATA_REQUEST = 1, > +}; > + > +/* > + * Commands sent from the consumerd to the sessiond to request > + * if new metadata is available > + */ > +struct lttcomm_metadata_request_msg { > + unsigned int session_id; /* Tracing session id */ > + uint32_t bits_per_long; /* Consumer ABI */ > + uint32_t uid; > + uint64_t key; /* Metadata channel key. */ > +} LTTNG_PACKED; What happens for per-pid UST buffers ? This message seems to be quite specific to per-uid buffers ? Thanks, Mathieu > + > struct lttcomm_sockaddr { > enum lttcomm_sock_domain type; > union { > diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c > index 06b59c5..e56f023 100644 > --- a/src/common/ust-consumer/ust-consumer.c > +++ b/src/common/ust-consumer/ust-consumer.c > @@ -30,11 +30,14 @@ > #include > #include > #include > +#include > > #include > #include > #include > #include > +#include > +#include > > #include "ust-consumer.h" > > @@ -530,10 +533,12 @@ error: > /* > * Write metadata to the given channel using ustctl to convert the string to > * the ringbuffer. > + * Called only from consumer_metadata_cache_write. > + * The metadata cache lock MUST be acquired to write in the cache. > * > * Return 0 on success else a negative value. > */ > -static int push_metadata(struct lttng_consumer_channel *metadata, > +int lttng_ustconsumer_push_metadata(struct lttng_consumer_channel *metadata, > const char *metadata_str, uint64_t target_offset, uint64_t len) > { > int ret; > @@ -543,13 +548,13 @@ static int push_metadata(struct lttng_consumer_channel *metadata, > > DBG("UST consumer writing metadata to channel %s", metadata->name); > > - assert(target_offset == metadata->contig_metadata_written); > + assert(target_offset <= metadata->metadata_cache->max_offset); > ret = ustctl_write_metadata_to_channel(metadata->uchan, metadata_str, len); > if (ret < 0) { > ERR("ustctl write metadata fail with ret %d, len %ld", ret, len); > goto error; > } > - metadata->contig_metadata_written += len; > + metadata->metadata_cache->rb_pushed += len; > > ustctl_flush_buffer(metadata->metadata_stream->ustream, 1); > > @@ -619,6 +624,11 @@ static int close_metadata(uint64_t chan_key) > ret = LTTCOMM_CONSUMERD_ERROR_METADATA; > goto error; > } > + if (channel->switch_timer_enabled == 1) { > + DBG("Deleting timer on metadata channel"); > + consumer_timer_switch_stop(channel); > + } > + consumer_metadata_cache_destroy(channel); > > error: > return ret; > @@ -679,6 +689,51 @@ error: > } > > /* > + * Receive the metadata updates from the sessiond. > + */ > +int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset, > + uint64_t len, struct lttng_consumer_channel *channel) > +{ > + int ret, ret_code = LTTNG_OK; > + char *metadata_str; > + > + DBG("UST consumer push metadata key %lu of len %lu", key, len); > + > + metadata_str = zmalloc(len * sizeof(char)); > + if (!metadata_str) { > + PERROR("zmalloc metadata string"); > + ret_code = LTTCOMM_CONSUMERD_ENOMEM; > + goto end; > + } > + > + /* Receive metadata string. */ > + ret = lttcomm_recv_unix_sock(sock, metadata_str, len); > + if (ret < 0) { > + /* Session daemon is dead so return gracefully. */ > + ret_code = ret; > + goto end_free; > + } > + > + pthread_mutex_lock(&channel->metadata_cache->lock); > + ret = consumer_metadata_cache_write(channel, offset, len, metadata_str); > + if (ret < 0) { > + /* Unable to handle metadata. Notify session daemon. */ > + ret_code = LTTCOMM_CONSUMERD_ERROR_METADATA; > + } > + pthread_mutex_unlock(&channel->metadata_cache->lock); > + > + while (consumer_metadata_cache_flushed(channel, offset + len)) { > + DBG("Waiting for metadata to be flushed"); > + usleep(DEFAULT_METADATA_AVAILABILITY_WAIT_TIME); > + } > + > +end_free: > + free(metadata_str); > +end: > + return ret_code; > +} > + > +/* > * Receive command from session daemon and process it. > * > * Return 1 on success else a negative value or 0. > @@ -847,6 +902,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, > goto end_channel_error; > } > > + > /* > * Channel and streams are now created. Inform the session daemon that > * everything went well and should wait to receive the channel and > @@ -861,6 +917,16 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, > goto end_nosignal; > } > > + if (msg.u.ask_channel.type == LTTNG_UST_CHAN_METADATA) { > + ret = consumer_metadata_cache_allocate(channel); > + if (ret < 0) { > + ERR("Allocating metadata cache"); > + goto end_channel_error; > + } > + consumer_timer_switch_start(channel, attr.switch_timer_interval); > + attr.switch_timer_interval = 0; > + } > + > break; > } > case LTTNG_CONSUMER_GET_CHANNEL: > @@ -957,10 +1023,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, > { > int ret; > uint64_t len = msg.u.push_metadata.len; > - uint64_t target_offset = msg.u.push_metadata.target_offset; > uint64_t key = msg.u.push_metadata.key; > + uint64_t offset = msg.u.push_metadata.target_offset; > struct lttng_consumer_channel *channel; > - char *metadata_str; > > DBG("UST consumer push metadata key %lu of len %lu", key, len); > > @@ -968,14 +1033,6 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, > if (!channel) { > ERR("UST consumer push metadata %lu not found", key); > ret_code = LTTNG_ERR_UST_CHAN_NOT_FOUND; > - goto end_msg_sessiond; > - } > - > - metadata_str = zmalloc(len * sizeof(char)); > - if (!metadata_str) { > - PERROR("zmalloc metadata string"); > - ret_code = LTTCOMM_CONSUMERD_ENOMEM; > - goto end_msg_sessiond; > } > > /* Tell session daemon we are ready to receive the metadata. */ > @@ -990,22 +1047,15 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, > goto end_nosignal; > } > > - /* Receive metadata string. */ > - ret = lttcomm_recv_unix_sock(sock, metadata_str, len); > + ret = lttng_ustconsumer_recv_metadata(sock, key, offset, > + len, channel); > if (ret < 0) { > - /* Session daemon is dead so return gracefully. */ > + /* error receiving from sessiond */ > goto end_nosignal; > - } > - > - ret = push_metadata(channel, metadata_str, target_offset, len); > - free(metadata_str); > - if (ret < 0) { > - /* Unable to handle metadata. Notify session daemon. */ > - ret_code = LTTCOMM_CONSUMERD_ERROR_METADATA; > + } else { > + ret_code = ret; > goto end_msg_sessiond; > } > - > - goto end_msg_sessiond; > } > case LTTNG_CONSUMER_SETUP_METADATA: > { > @@ -1223,6 +1273,7 @@ int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream, > } > err = ustctl_put_next_subbuf(ustream); > assert(err == 0); > + > end: > return ret; > } > @@ -1343,3 +1394,96 @@ void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream) > ERR("Unable to close wakeup fd"); > } > } > + > +int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx, > + struct lttng_consumer_channel *channel) > +{ > + struct lttcomm_metadata_request_msg request; > + struct lttcomm_consumer_msg msg; > + enum lttng_error_code ret_code = LTTNG_OK; > + uint64_t len, key, offset; > + int ret; > + > + assert(channel); > + assert(channel->metadata_cache); > + > + /* send the metadata request to sessiond */ > + switch (consumer_data.type) { > + case LTTNG_CONSUMER64_UST: > + request.bits_per_long = 64; > + break; > + case LTTNG_CONSUMER32_UST: > + request.bits_per_long = 32; > + break; > + default: > + request.bits_per_long = 0; > + break; > + } > + > + request.session_id = channel->session_id; > + request.uid = channel->uid; > + request.key = channel->key; > + DBG("Sending metadata request to sessiond, session %" PRIu64, > + channel->session_id); > + > + ret = lttcomm_send_unix_sock(ctx->consumer_metadata_socket, &request, > + sizeof(request)); > + if (ret < 0) { > + ERR("Asking metadata to sessiond"); > + goto end; > + } > + > + /* Receive the metadata from sessiond */ > + ret = lttcomm_recv_unix_sock(ctx->consumer_metadata_socket, &msg, > + sizeof(msg)); > + if (ret != sizeof(msg)) { > + DBG("Consumer received unexpected message size %d (expects %lu)", > + ret, sizeof(msg)); > + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_CMD); > + /* > + * The ret value might 0 meaning an orderly shutdown but this is ok > + * since the caller handles this. > + */ > + goto end; > + } > + > + if (msg.cmd_type == LTTNG_ERR_UND) { > + /* No registry found */ > + (void) consumer_send_status_msg(ctx->consumer_metadata_socket, > + ret_code); > + ret = 0; > + goto end; > + } else if (msg.cmd_type != LTTNG_CONSUMER_PUSH_METADATA) { > + ERR("Unexpected cmd_type received %d", msg.cmd_type); > + ret = -1; > + goto end; > + } > + > + len = msg.u.push_metadata.len; > + key = msg.u.push_metadata.key; > + offset = msg.u.push_metadata.target_offset; > + > + assert(key == channel->key); > + if (len == 0) { > + DBG("No new metadata to receive for key %" PRIu64, key); > + } > + > + /* Tell session daemon we are ready to receive the metadata. */ > + ret = consumer_send_status_msg(ctx->consumer_metadata_socket, > + LTTNG_OK); > + if (ret < 0 || len == 0) { > + /* > + * Somehow, the session daemon is not responding anymore or there is > + * nothing to receive. > + */ > + goto end; > + } > + > + ret_code = lttng_ustconsumer_recv_metadata(ctx->consumer_metadata_socket, > + key, offset, len, channel); > + (void) consumer_send_status_msg(ctx->consumer_metadata_socket, ret_code); > + ret = 0; > + > +end: > + return ret; > +} > diff --git a/src/common/ust-consumer/ust-consumer.h b/src/common/ust-consumer/ust-consumer.h > index bbaff6c..d748582 100644 > --- a/src/common/ust-consumer/ust-consumer.h > +++ b/src/common/ust-consumer/ust-consumer.h > @@ -51,6 +51,12 @@ void *lttng_ustctl_get_mmap_base(struct lttng_consumer_stream *stream); > int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream); > void lttng_ustconsumer_close_metadata(struct lttng_ht *ht); > void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream); > +int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset, > + uint64_t len, struct lttng_consumer_channel *channel); > +int lttng_ustconsumer_push_metadata(struct lttng_consumer_channel *metadata, > + const char *metadata_str, uint64_t target_offset, uint64_t len); > +int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx, > + struct lttng_consumer_channel *channel); > > #else /* HAVE_LIBLTTNG_UST_CTL */ > > diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am > index a9d65ab..169ca2e 100644 > --- a/tests/unit/Makefile.am > +++ b/tests/unit/Makefile.am > @@ -47,8 +47,9 @@ UST_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-ust.c \ > $(top_srcdir)/src/bin/lttng-sessiond/ust-consumer.c \ > $(top_srcdir)/src/bin/lttng-sessiond/fd-limit.c \ > $(top_srcdir)/src/bin/lttng-sessiond/health.c \ > - $(top_srcdir)/src/common/uri.c \ > - $(top_srcdir)/src/common/utils.c > + $(top_srcdir)/src/bin/lttng-sessiond/session.c \ > + $(top_srcdir)/src/common/uri.c \ > + $(top_srcdir)/src/common/utils.c > > test_ust_data_SOURCES = test_ust_data.c $(UST_DATA_TRACE) > test_ust_data_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBSESSIOND_COMM) $(LIBHASHTABLE) \ > -- > 1.7.10.4 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From dgoulet at efficios.com Tue Mar 26 15:10:09 2013 From: dgoulet at efficios.com (David Goulet) Date: Tue, 26 Mar 2013 15:10:09 -0400 Subject: [lttng-dev] [PATCH lttng-tools] UST periodical metadata flush In-Reply-To: <20130326185938.GA18985@Krystal> References: <1364320199-30440-1-git-send-email-dgoulet@efficios.com> <20130326185938.GA18985@Krystal> Message-ID: <5151F291.50205@efficios.com> Mathieu Desnoyers: > * David Goulet (dgoulet at efficios.com) wrote: >> From: Julien Desfossez >> >> Add a socket between the sessiond and the ust-consumer to allow >> periodical flush of the metadata channel. >> >> If enabled (by specifying the --switch-timer option on the metadata >> channel), a new timer thread in the consumer asks the session daemon for >> new metadata for a specific session. >> >> All the metadata collected is written into a metadata cache in the >> consumer, this mechanism is useful for synchronisation (to avoid race >> conditions between two metadata updates) and will also be useful when we >> implement the snapshots. >> >> Signed-off-by: Julien Desfossez >> Signed-off-by: David Goulet >> --- >> src/bin/lttng-consumerd/lttng-consumerd.c | 29 ++++ >> src/bin/lttng-sessiond/consumer.c | 4 +- >> src/bin/lttng-sessiond/consumer.h | 2 + >> src/bin/lttng-sessiond/main.c | 147 +++++++++++++------- >> src/bin/lttng-sessiond/ust-app.c | 109 +++++++++------ >> src/bin/lttng-sessiond/ust-app.h | 8 ++ >> src/bin/lttng-sessiond/ust-consumer.c | 77 ++++++++++ >> src/bin/lttng-sessiond/ust-consumer.h | 1 + >> src/common/Makefile.am | 6 +- >> src/common/consumer-metadata-cache.c | 214 ++++++++++++++++++++++++++++ >> src/common/consumer-metadata-cache.h | 58 ++++++++ >> src/common/consumer-timer.c | 216 +++++++++++++++++++++++++++++ >> src/common/consumer-timer.h | 49 +++++++ >> src/common/consumer.c | 43 ++++++ >> src/common/consumer.h | 17 ++- >> src/common/defaults.h | 8 +- >> src/common/macros.h | 4 + >> src/common/sessiond-comm/sessiond-comm.h | 15 ++ >> src/common/ust-consumer/ust-consumer.c | 194 ++++++++++++++++++++++---- >> src/common/ust-consumer/ust-consumer.h | 6 + >> tests/unit/Makefile.am | 5 +- >> 21 files changed, 1082 insertions(+), 130 deletions(-) >> create mode 100644 src/common/consumer-metadata-cache.c >> create mode 100644 src/common/consumer-metadata-cache.h >> create mode 100644 src/common/consumer-timer.c >> create mode 100644 src/common/consumer-timer.h >> >> diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c >> index 8486807..7ca9688 100644 >> --- a/src/bin/lttng-consumerd/lttng-consumerd.c >> +++ b/src/bin/lttng-consumerd/lttng-consumerd.c >> @@ -44,6 +44,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> >> @@ -52,7 +53,9 @@ >> /* TODO : support UST (all direct kernel-ctl accesses). */ >> >> /* threads (channel handling, poll, metadata, sessiond) */ >> + >> static pthread_t channel_thread, data_thread, metadata_thread, sessiond_thread; >> +static pthread_t metadata_timer_thread; >> >> /* to count the number of times the user pressed ctrl+c */ >> static int sigintcount = 0; >> @@ -363,6 +366,15 @@ int main(int argc, char **argv) >> } >> lttng_consumer_set_error_sock(ctx, ret); >> >> + /* >> + * For UST consumer, we block RT signals used for periodical metadata flush >> + * in main and create a dedicated thread to handle these signals. >> + */ >> + if (opt_type != LTTNG_CONSUMER_KERNEL) { >> + consumer_signal_init(); > > for each if (opt_type != LTTNG_CONSUMER_KERNEL) > > can you instead do : > > switch (opt_type) { > case LTTNG_CONSUMER_KERNEL: > > break; > case ... > > break; > default: > assert(0); > } > > So if we add a new consumer type, it won't take the "else" for granted ? Yup > >> + } >> + ctx->type = opt_type; >> + >> /* Create thread to manage channels */ >> ret = pthread_create(&channel_thread, NULL, consumer_thread_channel_poll, >> (void *) ctx); >> @@ -395,6 +407,23 @@ int main(int argc, char **argv) >> goto sessiond_error; >> } >> >> + if (opt_type != LTTNG_CONSUMER_KERNEL) { > > same here. Yup > >> + /* Create the thread to manage the metadata periodic timers */ >> + ret = pthread_create(&metadata_timer_thread, NULL, >> + consumer_timer_metadata_thread, (void *) ctx); >> + if (ret != 0) { >> + perror("pthread_create"); >> + goto metadata_timer_error; >> + } >> + >> + ret = pthread_detach(metadata_timer_thread); >> + if (ret) { >> + errno = ret; >> + perror("pthread_detach"); >> + } > > Hrm, if pthread_detach fails, maybe we should join the > metadata_timer_thread ? > Not sure... that thread as *no* way of getting out of it's main loop so this is going to wait for a LONG time :P. >> + } >> + >> +metadata_timer_error: >> ret = pthread_join(sessiond_thread, &status); >> if (ret != 0) { >> perror("pthread_join"); >> diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c >> index 57b5b19..6719051 100644 >> --- a/src/bin/lttng-sessiond/consumer.c >> +++ b/src/bin/lttng-sessiond/consumer.c >> @@ -1072,7 +1072,7 @@ end: >> } >> >> /* >> - * Send metadata string to consumer. >> + * Send metadata string to consumer. Socket lock MUST be acquired. >> * >> * Return 0 on success else a negative value. >> */ >> @@ -1103,7 +1103,7 @@ int consumer_push_metadata(struct consumer_socket *socket, >> >> health_code_update(); >> ret = consumer_send_msg(socket, &msg); >> - if (ret < 0) { >> + if (ret < 0 || len == 0) { >> goto end; >> } >> >> diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h >> index cde2d0d..b767589 100644 >> --- a/src/bin/lttng-sessiond/consumer.h >> +++ b/src/bin/lttng-sessiond/consumer.h >> @@ -78,7 +78,9 @@ struct consumer_data { >> pid_t pid; >> >> int err_sock; >> + /* These two sockets uses the cmd_unix_sock_path. */ >> int cmd_sock; >> + struct consumer_socket metadata_sock; >> >> /* consumer error and command Unix socket path */ >> char err_unix_sock_path[PATH_MAX]; >> diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c >> index d88bafe..a98b4f2 100644 >> --- a/src/bin/lttng-sessiond/main.c >> +++ b/src/bin/lttng-sessiond/main.c >> @@ -25,6 +25,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -89,6 +90,7 @@ static struct consumer_data kconsumer_data = { >> .cmd_unix_sock_path = DEFAULT_KCONSUMERD_CMD_SOCK_PATH, >> .err_sock = -1, >> .cmd_sock = -1, >> + .metadata_sock.fd = -1, >> .pid_mutex = PTHREAD_MUTEX_INITIALIZER, >> .lock = PTHREAD_MUTEX_INITIALIZER, >> .cond = PTHREAD_COND_INITIALIZER, >> @@ -100,6 +102,7 @@ static struct consumer_data ustconsumer64_data = { >> .cmd_unix_sock_path = DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH, >> .err_sock = -1, >> .cmd_sock = -1, >> + .metadata_sock.fd = -1, >> .pid_mutex = PTHREAD_MUTEX_INITIALIZER, >> .lock = PTHREAD_MUTEX_INITIALIZER, >> .cond = PTHREAD_COND_INITIALIZER, >> @@ -111,6 +114,7 @@ static struct consumer_data ustconsumer32_data = { >> .cmd_unix_sock_path = DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH, >> .err_sock = -1, >> .cmd_sock = -1, >> + .metadata_sock.fd = -1, >> .pid_mutex = PTHREAD_MUTEX_INITIALIZER, >> .lock = PTHREAD_MUTEX_INITIALIZER, >> .cond = PTHREAD_COND_INITIALIZER, >> @@ -865,10 +869,10 @@ static void *thread_manage_consumer(void *data) >> health_code_update(); >> >> /* >> - * Pass 2 as size here for the thread quit pipe and kconsumerd_err_sock. >> - * Nothing more will be added to this poll set. >> + * Pass 3 as size here for the thread quit pipe, consumerd_err_sock and the >> + * metadata_sock. Nothing more will be added to this poll set. >> */ >> - ret = sessiond_set_thread_pollset(&events, 2); >> + ret = sessiond_set_thread_pollset(&events, 3); >> if (ret < 0) { >> goto error_poll; >> } >> @@ -885,7 +889,7 @@ static void *thread_manage_consumer(void *data) >> >> health_code_update(); >> >> - /* Inifinite blocking call, waiting for transmission */ >> + /* Infinite blocking call, waiting for transmission */ >> restart: >> health_poll_entry(); >> >> @@ -955,87 +959,126 @@ restart: >> health_code_update(); >> >> if (code == LTTCOMM_CONSUMERD_COMMAND_SOCK_READY) { >> + /* Connect both socket, command and metadata. */ >> consumer_data->cmd_sock = >> lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path); >> - if (consumer_data->cmd_sock < 0) { >> + consumer_data->metadata_sock.fd = >> + lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path); >> + if (consumer_data->cmd_sock < 0 || >> + consumer_data->metadata_sock.fd < 0) { >> + PERROR("consumer connect cmd socket"); >> /* On error, signal condition and quit. */ >> signal_consumer_condition(consumer_data, -1); >> - PERROR("consumer connect"); >> goto error; >> } >> + /* Create metadata socket lock. */ >> + consumer_data->metadata_sock.lock = zmalloc(sizeof(pthread_mutex_t)); >> + if (consumer_data->metadata_sock.lock == NULL) { >> + PERROR("zmalloc pthread mutex"); >> + ret = -1; >> + goto error; >> + } >> + pthread_mutex_init(consumer_data->metadata_sock.lock, NULL); >> + >> signal_consumer_condition(consumer_data, 1); >> - DBG("Consumer command socket ready"); >> + DBG("Consumer command socket ready (fd: %d", consumer_data->cmd_sock); >> + DBG("Consumer metadata socket ready (fd: %d)", >> + consumer_data->metadata_sock.fd); >> } else { >> ERR("consumer error when waiting for SOCK_READY : %s", >> lttcomm_get_readable_code(-code)); >> goto error; >> } >> >> - /* Remove the kconsumerd error sock since we've established a connexion */ >> + /* Remove the consumerd error sock since we've established a connexion */ >> ret = lttng_poll_del(&events, consumer_data->err_sock); >> if (ret < 0) { >> goto error; >> } >> >> + /* Add new accepted error socket. */ >> ret = lttng_poll_add(&events, sock, LPOLLIN | LPOLLRDHUP); >> if (ret < 0) { >> goto error; >> } >> >> + /* Add metadata socket that is successfully connected. */ >> + ret = lttng_poll_add(&events, consumer_data->metadata_sock.fd, >> + LPOLLIN | LPOLLRDHUP); >> + if (ret < 0) { >> + goto error; >> + } >> + >> health_code_update(); >> >> - /* Inifinite blocking call, waiting for transmission */ >> + /* Infinite blocking call, waiting for transmission */ >> restart_poll: >> - health_poll_entry(); >> - ret = lttng_poll_wait(&events, -1); >> - health_poll_exit(); >> - if (ret < 0) { >> - /* >> - * Restart interrupted system call. >> - */ >> - if (errno == EINTR) { >> - goto restart_poll; >> + while (1) { > > why are we getting this refactoring ? Is it necessary ? It is. We've added a metadata socket that receives commands from the consumer so we need to poll at vitam eternam for that. > >> + health_poll_entry(); >> + ret = lttng_poll_wait(&events, -1); >> + health_poll_exit(); >> + if (ret < 0) { >> + /* >> + * Restart interrupted system call. >> + */ >> + if (errno == EINTR) { >> + goto restart_poll; >> + } >> + goto error; >> } >> - goto error; >> - } >> >> - nb_fd = ret; >> + nb_fd = ret; >> >> - for (i = 0; i < nb_fd; i++) { >> - /* Fetch once the poll data */ >> - revents = LTTNG_POLL_GETEV(&events, i); >> - pollfd = LTTNG_POLL_GETFD(&events, i); >> + for (i = 0; i < nb_fd; i++) { >> + /* Fetch once the poll data */ >> + revents = LTTNG_POLL_GETEV(&events, i); >> + pollfd = LTTNG_POLL_GETFD(&events, i); >> >> - health_code_update(); >> + health_code_update(); >> >> - /* Thread quit pipe has been closed. Killing thread. */ >> - ret = sessiond_check_thread_quit_pipe(pollfd, revents); >> - if (ret) { >> - err = 0; >> - goto exit; >> - } >> + /* Thread quit pipe has been closed. Killing thread. */ >> + ret = sessiond_check_thread_quit_pipe(pollfd, revents); >> + if (ret) { >> + err = 0; >> + goto exit; >> + } >> >> - /* Event on the kconsumerd socket */ >> - if (pollfd == sock) { >> - if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { >> - ERR("consumer err socket second poll error"); >> + if (pollfd == sock) { >> + /* Event on the consumerd socket */ >> + if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) { >> + ERR("consumer err socket second poll error"); >> + goto error; >> + } >> + health_code_update(); >> + /* Wait for any kconsumerd error */ >> + ret = lttcomm_recv_unix_sock(sock, &code, >> + sizeof(enum lttcomm_return_code)); >> + if (ret <= 0) { >> + ERR("consumer closed the command socket"); >> + goto error; >> + } >> + >> + ERR("consumer return code : %s", >> + lttcomm_get_readable_code(-code)); >> + >> + goto exit; >> + } else if (pollfd == consumer_data->metadata_sock.fd) { >> + /* UST metadata requests */ >> + ret = ust_consumer_metadata_request( >> + &consumer_data->metadata_sock); >> + if (ret < 0) { >> + ERR("Handling metadata request"); >> + goto error; >> + } >> + break; >> + } else { >> + ERR("Unknown pollfd"); >> goto error; >> } >> } >> + health_code_update(); >> } >> >> - health_code_update(); >> - >> - /* Wait for any kconsumerd error */ >> - ret = lttcomm_recv_unix_sock(sock, &code, >> - sizeof(enum lttcomm_return_code)); >> - if (ret <= 0) { >> - ERR("consumer closed the command socket"); >> - goto error; >> - } >> - >> - ERR("consumer return code : %s", lttcomm_get_readable_code(-code)); >> - >> exit: >> error: >> /* Immediately set the consumerd state to stopped */ >> @@ -1061,6 +1104,12 @@ error: >> PERROR("close"); >> } >> } >> + if (consumer_data->metadata_sock.fd >= 0) { >> + ret = close(consumer_data->metadata_sock.fd); >> + if (ret) { >> + PERROR("close"); >> + } >> + } >> if (sock >= 0) { >> ret = close(sock); >> if (ret) { >> @@ -2011,7 +2060,7 @@ end: >> return 0; >> >> error: >> - /* Cleanup already created socket on error. */ >> + /* Cleanup already created sockets on error. */ >> if (consumer_data->err_sock >= 0) { >> int err; >> >> diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c >> index 979ae7c..2cb92e4 100644 >> --- a/src/bin/lttng-sessiond/ust-app.c >> +++ b/src/bin/lttng-sessiond/ust-app.c >> @@ -27,6 +27,7 @@ >> #include >> #include >> #include >> +#include >> >> #include >> #include >> @@ -368,17 +369,72 @@ void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan, >> } >> >> /* >> + * Push metadata to consumer socket. The socket lock MUST be acquired. >> + * >> + * On success, return the len of metadata pushed or else a negative value. >> + */ >> +ssize_t ust_app_push_metadata(struct ust_registry_session *registry, >> + struct consumer_socket *socket) >> +{ >> + int ret; >> + char *metadata_str = NULL; >> + size_t len, offset; >> + ssize_t ret_val; >> + >> + assert(registry); >> + assert(socket); >> + >> + pthread_mutex_lock(®istry->lock); >> + >> + offset = registry->metadata_len_sent; >> + len = registry->metadata_len - registry->metadata_len_sent; >> + if (len == 0) { >> + DBG3("No metadata to push for metadata key %" PRIu64, >> + registry->metadata_key); >> + goto end; >> + } >> + >> + /* Allocate only what we have to send. */ >> + metadata_str = zmalloc(len); >> + if (!metadata_str) { >> + PERROR("zmalloc ust app metadata string"); >> + ret_val = -ENOMEM; >> + goto error; >> + } >> + /* Copy what we haven't send out. */ >> + memcpy(metadata_str, registry->metadata + offset, len); >> + >> + ret = consumer_push_metadata(socket, registry->metadata_key, >> + metadata_str, len, offset); > > I think consumer_push_metadata() sends metadata to consumerd. This is > done with the registry lock held. This should _not_ be done. > > The registry lock _needs_ to be held only for short periods of time. Hmmm indeed. I'll put back the lock around the registry below to update the len. > >> + if (ret < 0) { >> + ret_val = ret; >> + goto error; >> + } >> + >> + registry->metadata_len_sent += len; >> + >> +end: >> + ret_val = len; >> +error: >> + free(metadata_str); >> + pthread_mutex_unlock(®istry->lock); >> + return ret_val; >> +} >> + >> +/* >> * For a given application and session, push metadata to consumer. The session >> * lock MUST be acquired here before calling this. >> + * Either sock or consumer is required : if sock is NULL, the default >> + * socket to send the metadata is retrieved from consumer, if sock >> + * is not NULL we use it to send the metadata. >> * >> * Return 0 on success else a negative error. >> */ >> static int push_metadata(struct ust_registry_session *registry, >> struct consumer_output *consumer) >> { >> - int ret; >> - char *metadata_str = NULL; >> - size_t len, offset; >> + int ret_val; >> + ssize_t ret; >> struct consumer_socket *socket; >> >> assert(registry); >> @@ -391,7 +447,7 @@ static int push_metadata(struct ust_registry_session *registry, >> * no start has been done previously. >> */ >> if (!registry->metadata_key) { >> - ret = 0; >> + ret_val = 0; >> goto error_rcu_unlock; >> } >> >> @@ -399,7 +455,7 @@ static int push_metadata(struct ust_registry_session *registry, >> socket = consumer_find_socket_by_bitness(registry->bits_per_long, >> consumer); >> if (!socket) { >> - ret = -1; >> + ret_val = -1; >> goto error_rcu_unlock; >> } >> >> @@ -414,54 +470,19 @@ static int push_metadata(struct ust_registry_session *registry, >> * ability to reorder the metadata it receives. >> */ >> pthread_mutex_lock(socket->lock); >> - pthread_mutex_lock(®istry->lock); >> - >> - offset = registry->metadata_len_sent; >> - len = registry->metadata_len - registry->metadata_len_sent; >> - if (len == 0) { >> - DBG3("No metadata to push for metadata key %" PRIu64, >> - registry->metadata_key); >> - ret = 0; >> - goto error_reg_unlock; >> - } >> - assert(len > 0); >> - >> - /* Allocate only what we have to send. */ >> - metadata_str = zmalloc(len); >> - if (!metadata_str) { >> - PERROR("zmalloc ust app metadata string"); >> - ret = -ENOMEM; >> - goto error_reg_unlock; >> - } >> - /* Copy what we haven't send out. */ >> - memcpy(metadata_str, registry->metadata + offset, len); >> - >> - pthread_mutex_unlock(®istry->lock); >> - >> - ret = consumer_push_metadata(socket, registry->metadata_key, >> - metadata_str, len, offset); >> + ret = ust_app_push_metadata(registry, socket); >> + pthread_mutex_unlock(socket->lock); >> if (ret < 0) { >> - pthread_mutex_unlock(socket->lock); >> + ret_val = ret; >> goto error_rcu_unlock; >> } >> >> - /* Update len sent of the registry. */ >> - pthread_mutex_lock(®istry->lock); >> - registry->metadata_len_sent += len; >> - pthread_mutex_unlock(®istry->lock); >> - pthread_mutex_unlock(socket->lock); >> - >> rcu_read_unlock(); >> - free(metadata_str); >> return 0; >> >> -error_reg_unlock: >> - pthread_mutex_unlock(®istry->lock); >> - pthread_mutex_unlock(socket->lock); >> error_rcu_unlock: >> rcu_read_unlock(); >> - free(metadata_str); >> - return ret; >> + return ret_val; >> } >> >> /* >> diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h >> index 67088a7..776dc0e 100644 >> --- a/src/bin/lttng-sessiond/ust-app.h >> +++ b/src/bin/lttng-sessiond/ust-app.h >> @@ -299,6 +299,8 @@ int ust_app_recv_notify(int sock); >> void ust_app_add(struct ust_app *app); >> struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock); >> void ust_app_notify_sock_unregister(int sock); >> +ssize_t ust_app_push_metadata(struct ust_registry_session *registry, >> + struct consumer_socket *socket); >> >> #else /* HAVE_LIBLTTNG_UST_CTL */ >> >> @@ -485,6 +487,12 @@ static inline >> void ust_app_notify_sock_unregister(int sock) >> { >> } >> +static inline >> +ssize_t ust_app_push_metadata(struct ust_registry_session *registry, >> + struct consumer_socket *socket) >> +{ >> + return 0; >> +} >> >> #endif /* HAVE_LIBLTTNG_UST_CTL */ >> >> diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c >> index ba74112..2b6f813 100644 >> --- a/src/bin/lttng-sessiond/ust-consumer.c >> +++ b/src/bin/lttng-sessiond/ust-consumer.c >> @@ -30,6 +30,8 @@ >> #include "consumer.h" >> #include "health.h" >> #include "ust-consumer.h" >> +#include "buffer-registry.h" >> +#include "session.h" >> >> /* >> * Return allocated full pathname of the session using the consumer trace path >> @@ -405,3 +407,78 @@ int ust_consumer_send_channel_to_ust(struct ust_app *app, >> error: >> return ret; >> } >> + >> +/* >> + * Handle the metadata requests from the UST consumer >> + * >> + * Return 0 on success else a negative value. >> + */ >> +int ust_consumer_metadata_request(struct consumer_socket *socket) >> +{ >> + int ret; >> + ssize_t ret_push; >> + struct lttcomm_metadata_request_msg request; >> + struct buffer_reg_uid *reg_uid; >> + struct ust_registry_session *ust_reg; >> + struct lttcomm_consumer_msg msg; >> + uint64_t len; >> + >> + assert(socket); >> + >> + rcu_read_lock(); >> + pthread_mutex_lock(socket->lock); >> + >> + health_code_update(); >> + >> + /* Wait for a metadata request */ >> + ret = lttcomm_recv_unix_sock(socket->fd, &request, sizeof(request)); >> + if (ret <= 0) { >> + ERR("Consumer closed the metadata socket"); >> + ret = -1; >> + goto end; >> + } >> + >> + DBG("Metadata request received for session %u, key %" PRIu64, >> + request.session_id, request.key); >> + >> + reg_uid = buffer_reg_uid_find(request.session_id, >> + request.bits_per_long, request.uid); >> + if (reg_uid) { >> + ust_reg = reg_uid->registry->reg.ust; >> + } else { >> + struct buffer_reg_pid *reg_pid = >> + buffer_reg_pid_find(request.session_id); >> + if (!reg_pid) { >> + DBG("PID registry not found for session id %u", >> + request.session_id); >> + >> + msg.cmd_type = LTTNG_ERR_UND; >> + (void) consumer_send_msg(socket, &msg); >> + ret = -1; >> + goto end; >> + } >> + ust_reg = reg_pid->registry->reg.ust; >> + } >> + assert(ust_reg); >> + >> + len = ust_reg->metadata_len - ust_reg->metadata_len_sent; >> + if (len == 0) { >> + DBG("No metadata to push"); >> + ret = consumer_push_metadata(socket, request.key, NULL, len, 0); >> + goto end; >> + } >> + >> + ret_push = ust_app_push_metadata(ust_reg, socket); >> + if (ret_push < 0) { >> + ERR("Pushing metadata"); >> + ret = -1; >> + goto end; >> + } >> + DBG("UST Consumer metadata pushed successfully"); >> + ret = 0; >> + >> +end: >> + pthread_mutex_unlock(socket->lock); >> + rcu_read_unlock(); >> + return ret; >> +} >> diff --git a/src/bin/lttng-sessiond/ust-consumer.h b/src/bin/lttng-sessiond/ust-consumer.h >> index f5f63d9..d378202 100644 >> --- a/src/bin/lttng-sessiond/ust-consumer.h >> +++ b/src/bin/lttng-sessiond/ust-consumer.h >> @@ -36,5 +36,6 @@ int ust_consumer_send_stream_to_ust(struct ust_app *app, >> >> int ust_consumer_send_channel_to_ust(struct ust_app *app, >> struct ust_app_session *ua_sess, struct ust_app_channel *channel); >> +int ust_consumer_metadata_request(struct consumer_socket *sock); >> >> #endif /* _UST_CONSUMER_H */ >> diff --git a/src/common/Makefile.am b/src/common/Makefile.am >> index c3a947a..f2ea40a 100644 >> --- a/src/common/Makefile.am >> +++ b/src/common/Makefile.am >> @@ -6,7 +6,8 @@ SUBDIRS = compat hashtable kernel-ctl sessiond-comm relayd \ >> AM_CFLAGS = -fno-strict-aliasing >> >> noinst_HEADERS = lttng-kernel.h defaults.h macros.h error.h futex.h \ >> - uri.h utils.h lttng-kernel-old.h >> + uri.h utils.h lttng-kernel-old.h \ >> + consumer-metadata-cache.h consumer-timer.h >> >> # Common library >> noinst_LTLIBRARIES = libcommon.la >> @@ -18,7 +19,8 @@ libcommon_la_LIBADD = -luuid >> # Consumer library >> noinst_LTLIBRARIES += libconsumer.la >> >> -libconsumer_la_SOURCES = consumer.c consumer.h >> +libconsumer_la_SOURCES = consumer.c consumer.h consumer-metadata-cache.c \ >> + consumer-timer.c >> >> libconsumer_la_LIBADD = \ >> $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \ >> diff --git a/src/common/consumer-metadata-cache.c b/src/common/consumer-metadata-cache.c >> new file mode 100644 >> index 0000000..979521f >> --- /dev/null >> +++ b/src/common/consumer-metadata-cache.c >> @@ -0,0 +1,214 @@ >> +/* >> + * Copyright (C) 2013 - Julien Desfossez >> + * David Goulet >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License, version 2 only, >> + * as published by the Free Software Foundation. >> + * >> + * This program is distributed in the hope that it will be useful, but WITHOUT >> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or >> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for >> + * more details. >> + * >> + * You should have received a copy of the GNU General Public License along >> + * with this program; if not, write to the Free Software Foundation, Inc., >> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >> + */ >> + >> +#define _GNU_SOURCE >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#include "consumer-metadata-cache.h" >> + >> +/* >> + * Extend the allocated size of the metadata cache. Called only from >> + * lttng_ustconsumer_write_metadata_cache. >> + * >> + * Return 0 on success, a negative value on error. >> + */ >> +static int extend_metadata_cache(struct lttng_consumer_channel *channel, >> + unsigned int size) >> +{ >> + int ret = 0; >> + char *tmp_data_ptr; >> + unsigned int new_size; >> + >> + assert(channel); >> + assert(channel->metadata_cache); >> + >> + new_size = max_t(unsigned int, >> + channel->metadata_cache->cache_alloc_size + size, >> + channel->metadata_cache->cache_alloc_size << 1); >> + DBG("Extending metadata cache to %u", new_size); >> + tmp_data_ptr = realloc(channel->metadata_cache->data, new_size); >> + if (!tmp_data_ptr) { >> + ERR("Reallocating metadata cache"); >> + free(channel->metadata_cache->data); >> + ret = -1; >> + goto end; >> + } >> + channel->metadata_cache->data = tmp_data_ptr; >> + channel->metadata_cache->cache_alloc_size = new_size; >> + >> +end: >> + return ret; >> +} >> + >> +/* >> + * Write metadata to the cache, extend the cache if necessary. We support >> + * non-contiguous updates but not overlapping ones. If there is contiguous >> + * metadata in the cache, we send it to the ring buffer. The metadata cache >> + * lock MUST be acquired to write in the cache. >> + * >> + * Return 0 on success, a negative value on error. >> + */ >> +int consumer_metadata_cache_write(struct lttng_consumer_channel *channel, >> + unsigned int offset, unsigned int len, char *data) >> +{ >> + int ret = 0; >> + struct consumer_metadata_cache *cache; >> + >> + assert(channel); >> + assert(channel->metadata_cache); >> + >> + cache = channel->metadata_cache; >> + DBG("Writing %u bytes from offset %u in metadata cache", >> + len, offset); >> + >> + if (offset + len > cache->cache_alloc_size) { >> + ret = extend_metadata_cache(channel, >> + len - cache->cache_alloc_size + offset); >> + if (ret < 0) { >> + ERR("Extending metadata cache"); >> + goto end; >> + } >> + } >> + >> + memcpy(cache->data + offset, data, len); >> + cache->total_bytes_written += len; >> + if (offset + len > cache->max_offset) { >> + cache->max_offset = offset + len; >> + } >> + >> + if (cache->max_offset == cache->total_bytes_written) { >> + offset = cache->rb_pushed; >> + len = cache->total_bytes_written - cache->rb_pushed; >> + ret = lttng_ustconsumer_push_metadata(channel, cache->data, offset, >> + len); >> + if (ret < 0) { >> + ERR("Pushing metadata"); >> + goto end; >> + } >> + cache->rb_pushed += len; >> + } >> + >> +end: >> + return ret; >> +} >> + >> +/* >> + * Create the metadata cache, original allocated size: max_sb_size >> + * >> + * Return 0 on success, a negative value on error. >> + */ >> +int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel) >> +{ >> + int ret; >> + >> + assert(channel); >> + >> + channel->metadata_cache = zmalloc( >> + sizeof(struct consumer_metadata_cache)); >> + if (!channel->metadata_cache) { >> + PERROR("zmalloc metadata cache struct"); >> + ret = -1; >> + goto end; >> + } >> + ret = pthread_mutex_init(&channel->metadata_cache->lock, NULL); >> + if (ret != 0) { >> + PERROR("mutex init"); >> + goto end_free_cache; >> + } >> + >> + channel->metadata_cache->cache_alloc_size = DEFAULT_METADATA_CACHE_SIZE; >> + channel->metadata_cache->data = zmalloc( >> + channel->metadata_cache->cache_alloc_size * sizeof(char)); >> + if (!channel->metadata_cache->data) { >> + PERROR("zmalloc metadata cache data"); >> + ret = -1; >> + goto end_free_mutex; >> + } >> + DBG("Allocated metadata cache of %" PRIu64 " bytes", >> + channel->metadata_cache->cache_alloc_size); >> + >> + ret = 0; >> + goto end; >> + >> +end_free_mutex: >> + pthread_mutex_destroy(&channel->metadata_cache->lock); >> +end_free_cache: >> + free(channel->metadata_cache); >> +end: >> + return ret; >> +} >> + >> +/* >> + * Destroy and free the metadata cache >> + */ >> +void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel) >> +{ >> + if (!channel || !channel->metadata_cache) { >> + return; >> + } >> + >> + DBG("Destroying metadata cache"); >> + >> + if (channel->metadata_cache->max_offset > >> + channel->metadata_cache->rb_pushed) { >> + ERR("Destroying a cache not entirely commited"); >> + } >> + >> + pthread_mutex_destroy(&channel->metadata_cache->lock); >> + free(channel->metadata_cache->data); >> + free(channel->metadata_cache); >> +} >> + >> +/* >> + * Check if the cache is flushed up to the offset passed in parameter. >> + * >> + * Return 0 if everything has been flushed, 1 if there is data not flushed. >> + */ >> +int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, >> + uint64_t offset) >> +{ >> + int ret; >> + struct consumer_metadata_cache *cache; >> + >> + assert(channel); >> + assert(channel->metadata_cache); >> + >> + cache = channel->metadata_cache; >> + >> + pthread_mutex_lock(&channel->metadata_cache->lock); >> + if (cache->rb_pushed >= offset) { >> + ret = 0; >> + } else { >> + ret = 1; >> + } >> + pthread_mutex_unlock(&channel->metadata_cache->lock); >> + >> + return ret; >> +} >> diff --git a/src/common/consumer-metadata-cache.h b/src/common/consumer-metadata-cache.h >> new file mode 100644 >> index 0000000..1d76b50 >> --- /dev/null >> +++ b/src/common/consumer-metadata-cache.h >> @@ -0,0 +1,58 @@ >> +/* >> + * Copyright (C) 2013 - Julien Desfossez >> + * David Goulet >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License, version 2 only, >> + * as published by the Free Software Foundation. >> + * >> + * This program is distributed in the hope that it will be useful, but WITHOUT >> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or >> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for >> + * more details. >> + * >> + * You should have received a copy of the GNU General Public License along >> + * with this program; if not, write to the Free Software Foundation, Inc., >> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >> + */ >> + >> +#ifndef CONSUMER_METADATA_CACHE_H >> +#define CONSUMER_METADATA_CACHE_H >> + >> +#include >> + >> +struct consumer_metadata_cache { >> + char *data; >> + uint64_t cache_alloc_size; >> + /* >> + * How many bytes from the cache were already sent to >> + * the ring buffer > > missing . at end of sentence. ;-) > >> + */ >> + uint64_t rb_pushed; >> + /* >> + * How many bytes are written in the buffer (excluding the wholes) > > same here. > >> + */ >> + uint64_t total_bytes_written; >> + /* >> + * The upper-limit of data written inside the buffer. >> + * >> + * With the total_bytes_written it allows us to keep track of when the >> + * cache contains contiguous metadata ready to be sent to the RB. >> + * The metadata cache updates must not overlap. >> + */ >> + uint64_t max_offset; >> + /* >> + * Lock to update the metadata cache and push into the >> + * ring_buffer (ustctl_write_metadata_to_channel) > > same. > >> + */ >> + pthread_mutex_t lock; >> +}; >> + >> +int consumer_metadata_cache_write(struct lttng_consumer_channel *channel, >> + unsigned int offset, unsigned int len, char *data); >> +int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel); >> +void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel); >> +int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, >> + uint64_t offset); >> + >> +#endif /* CONSUMER_METADATA_CACHE_H */ >> diff --git a/src/common/consumer-timer.c b/src/common/consumer-timer.c >> new file mode 100644 >> index 0000000..80087fd >> --- /dev/null >> +++ b/src/common/consumer-timer.c >> @@ -0,0 +1,216 @@ >> +/* >> + * Copyright (C) 2012 - Julien Desfossez >> + * David Goulet >> + * >> + * This program is free software; you can redistribute it and/or modify it >> + * under the terms of the GNU General Public License, version 2 only, as >> + * published by the Free Software Foundation. >> + * >> + * This program is distributed in the hope that it will be useful, but WITHOUT >> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or >> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for >> + * more details. >> + * >> + * You should have received a copy of the GNU General Public License along with >> + * this program; if not, write to the Free Software Foundation, Inc., 51 >> + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >> + */ >> + >> +#define _GNU_SOURCE >> +#include >> +#include >> +#include >> + >> +#include >> + >> +#include "consumer-timer.h" >> +#include "ust-consumer/ust-consumer.h" >> + >> +static struct timer_signal_data timer_signal; >> + >> +/* >> + * Set custom signal mask to current thread. >> + */ >> +static void setmask(sigset_t *mask) >> +{ >> + int ret; >> + >> + ret = sigemptyset(mask); >> + if (ret) { >> + PERROR("sigemptyset"); >> + } >> + ret = sigaddset(mask, LTTNG_CONSUMER_SIG_SWITCH); >> + if (ret) { >> + PERROR("sigaddset"); >> + } >> + ret = sigaddset(mask, LTTNG_CONSUMER_SIG_TEARDOWN); >> + if (ret) { >> + PERROR("sigaddset"); >> + } >> +} >> + >> +/* >> + * Execute action on a timer switch. >> + */ >> +static void metadata_switch_timer(struct lttng_consumer_local_data *ctx, >> + int sig, siginfo_t *si, void *uc) >> +{ >> + struct lttng_consumer_channel *channel; >> + >> + channel = si->si_value.sival_ptr; >> + assert(channel); >> + >> + DBG("Switch timer for channel %" PRIu64, channel->key); >> + switch (ctx->type) { >> + case LTTNG_CONSUMER32_UST: >> + case LTTNG_CONSUMER64_UST: >> + (void) lttng_ustconsumer_request_metadata(ctx, channel); >> + break; >> + case LTTNG_CONSUMER_KERNEL: >> + case LTTNG_CONSUMER_UNKNOWN: >> + assert(0); >> + break; >> + } >> +} >> + >> +/* >> + * Set the timer for periodical metadata flush. >> + */ >> +void consumer_timer_switch_start(struct lttng_consumer_channel *channel, >> + unsigned int switch_timer_interval) >> +{ >> + int ret; >> + struct sigevent sev; >> + struct itimerspec its; >> + >> + if (switch_timer_interval == 0) { >> + return; >> + } >> + >> + sev.sigev_notify = SIGEV_SIGNAL; >> + sev.sigev_signo = LTTNG_CONSUMER_SIG_SWITCH; >> + sev.sigev_value.sival_ptr = channel; >> + ret = timer_create(CLOCKID, &sev, &channel->switch_timer); >> + if (ret == -1) { >> + PERROR("timer_create"); >> + } >> + channel->switch_timer_enabled = 1; >> + >> + its.it_value.tv_sec = switch_timer_interval / 1000000; >> + its.it_value.tv_nsec = switch_timer_interval % 1000000; >> + its.it_interval.tv_sec = its.it_value.tv_sec; >> + its.it_interval.tv_nsec = its.it_value.tv_nsec; >> + >> + ret = timer_settime(channel->switch_timer, 0, &its, NULL); >> + if (ret == -1) { >> + PERROR("timer_settime"); >> + } >> +} >> + >> +/* >> + * Stop and delete timer. >> + */ >> +void consumer_timer_switch_stop(struct lttng_consumer_channel *channel) >> +{ >> + int ret; >> + sigset_t pending_set; >> + >> + assert(channel); >> + >> + ret = timer_delete(channel->switch_timer); >> + if (ret == -1) { >> + PERROR("timer_delete"); >> + } >> + >> + /* Ensure we don't have any signal queued for this channel. */ >> + for (;;) { >> + ret = sigemptyset(&pending_set); >> + if (ret == -1) { >> + PERROR("sigemptyset"); >> + } >> + ret = sigpending(&pending_set); >> + if (ret == -1) { >> + PERROR("sigpending"); >> + } >> + if (!sigismember(&pending_set, LTTNG_CONSUMER_SIG_SWITCH)) { >> + break; >> + } >> + caa_cpu_relax(); >> + } >> + >> + /* >> + * From this point, no new signal handler will be fired that would try to >> + * access "chan". However, we still need to wait for any currently >> + * executing handler to complete. >> + */ >> + cmm_smp_mb(); >> + CMM_STORE_SHARED(timer_signal.qs_done, 0); >> + cmm_smp_mb(); >> + >> + /* >> + * Kill with LTTNG_CONSUMER_SIG_TEARDOWN, so signal management thread wakes >> + * up. >> + */ >> + kill(getpid(), LTTNG_CONSUMER_SIG_TEARDOWN); >> + >> + while (!CMM_LOAD_SHARED(timer_signal.qs_done)) { >> + caa_cpu_relax(); >> + } >> + cmm_smp_mb(); >> +} >> + >> +/* >> + * Block the RT signals for the entire process. It must be called from the >> + * consumer main before creating the threads >> + */ >> +void consumer_signal_init(void) >> +{ >> + int ret; >> + sigset_t mask; >> + >> + /* Block signal for entire process, so only our thread processes it. */ >> + setmask(&mask); >> + ret = pthread_sigmask(SIG_BLOCK, &mask, NULL); >> + if (ret) { >> + errno = ret; >> + PERROR("pthread_sigmask"); >> + } >> +} >> + >> +/* >> + * This thread is the sighandler for signals LTTNG_CONSUMER_SIG_SWITCH and >> + * LTTNG_CONSUMER_SIG_TEARDOWN that are emitted by the periodic timer to check >> + * if new metadata is available. >> + */ >> +void *consumer_timer_metadata_thread(void *data) >> +{ >> + int signr; >> + sigset_t mask; >> + siginfo_t info; >> + struct lttng_consumer_local_data *ctx = data; >> + >> + /* Only self thread will receive signal mask. */ >> + setmask(&mask); >> + CMM_STORE_SHARED(timer_signal.tid, pthread_self()); >> + >> + while (1) { >> + signr = sigwaitinfo(&mask, &info); >> + if (signr == -1) { >> + if (errno != EINTR) { >> + PERROR("sigwaitinfo"); >> + } >> + continue; >> + } else if (signr == LTTNG_CONSUMER_SIG_SWITCH) { >> + metadata_switch_timer(ctx, info.si_signo, &info, NULL); >> + } else if (signr == LTTNG_CONSUMER_SIG_TEARDOWN) { >> + cmm_smp_mb(); >> + CMM_STORE_SHARED(timer_signal.qs_done, 1); >> + cmm_smp_mb(); >> + DBG("Signal timer metadata thread teardown"); >> + } else { >> + ERR("Unexpected signal %d\n", info.si_signo); >> + } >> + } >> + >> + return NULL; >> +} >> diff --git a/src/common/consumer-timer.h b/src/common/consumer-timer.h >> new file mode 100644 >> index 0000000..8406158 >> --- /dev/null >> +++ b/src/common/consumer-timer.h >> @@ -0,0 +1,49 @@ >> +/* >> + * Copyright (C) 2011 - Julien Desfossez >> + * Mathieu Desnoyers >> + * 2012 - David Goulet >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License, version 2 only, >> + * as published by the Free Software Foundation. >> + * >> + * This program is distributed in the hope that it will be useful, but WITHOUT >> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or >> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for >> + * more details. >> + * >> + * You should have received a copy of the GNU General Public License along >> + * with this program; if not, write to the Free Software Foundation, Inc., >> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >> + */ >> + >> +#ifndef CONSUMER_TIMER_H >> +#define CONSUMER_TIMER_H >> + >> +#include >> + >> +#include "consumer.h" >> + >> +#define LTTNG_CONSUMER_SIG_SWITCH SIGRTMIN + 10 >> +#define LTTNG_CONSUMER_SIG_TEARDOWN SIGRTMIN + 11 >> + >> +#define CLOCKID CLOCK_MONOTONIC >> + >> +/* >> + * Handle timer teardown race wrt memory free of private data by consumer >> + * signals are handled by a single thread, which permits a synchronization >> + * point between handling of each signal. >> + */ >> +struct timer_signal_data { >> + pthread_t tid; /* thread id managing signals */ >> + int setup_done; >> + int qs_done; >> +}; >> + >> +void consumer_timer_switch_start(struct lttng_consumer_channel *channel, >> + unsigned int switch_timer_interval); >> +void consumer_timer_switch_stop(struct lttng_consumer_channel *channel); >> +void *consumer_timer_metadata_thread(void *data); >> +void consumer_signal_init(void); >> + >> +#endif /* CONSUMER_TIMER_H */ >> diff --git a/src/common/consumer.c b/src/common/consumer.c >> index 29bd0c0..5f87f4b 100644 >> --- a/src/common/consumer.c >> +++ b/src/common/consumer.c >> @@ -28,6 +28,7 @@ >> #include >> #include >> #include >> +#include >> >> #include >> #include >> @@ -1141,6 +1142,7 @@ struct lttng_consumer_local_data *lttng_consumer_create( >> } >> >> ctx->consumer_error_socket = -1; >> + ctx->consumer_metadata_socket = -1; >> /* assign the callbacks */ >> ctx->on_buffer_ready = buffer_ready; >> ctx->on_recv_channel = recv_channel; >> @@ -1227,6 +1229,10 @@ void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx) >> if (ret) { >> PERROR("close"); >> } >> + ret = close(ctx->consumer_metadata_socket); >> + if (ret) { >> + PERROR("close"); >> + } >> utils_close_pipe(ctx->consumer_thread_pipe); >> utils_close_pipe(ctx->consumer_channel_pipe); >> utils_close_pipe(ctx->consumer_data_pipe); >> @@ -1328,6 +1334,7 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap( >> goto end; >> } >> ret = lttng_ustctl_get_mmap_read_offset(stream, &mmap_offset); >> + >> break; >> default: >> ERR("Unknown consumer_data type"); >> @@ -2707,6 +2714,33 @@ end_ht: >> return NULL; >> } >> >> +static int set_metadata_socket(struct lttng_consumer_local_data *ctx, >> + struct pollfd *sockpoll, int client_socket) >> +{ >> + int ret; >> + >> + assert(ctx); >> + assert(sockpoll); >> + >> + if (lttng_consumer_poll_socket(sockpoll) < 0) { >> + ret = -1; >> + goto error; >> + } >> + DBG("Metadata connection on client_socket"); >> + >> + /* Blocking call, waiting for transmission */ >> + ctx->consumer_metadata_socket = lttcomm_accept_unix_sock(client_socket); >> + if (ctx->consumer_metadata_socket < 0) { >> + WARN("On accept metadata"); >> + ret = -1; >> + goto error; >> + } >> + ret = 0; >> + >> +error: >> + return ret; >> +} >> + >> /* >> * This thread listens on the consumerd socket and receives the file >> * descriptors from the session daemon. >> @@ -2773,6 +2807,15 @@ void *consumer_thread_sessiond_poll(void *data) >> goto end; >> } >> >> + /* >> + * Setup metadata socket which is the second socket connection on the >> + * command unix socket. >> + */ >> + ret = set_metadata_socket(ctx, consumer_sockpoll, client_socket); >> + if (ret < 0) { >> + goto end; >> + } >> + >> /* This socket is not useful anymore. */ >> ret = close(client_socket); >> if (ret < 0) { >> diff --git a/src/common/consumer.h b/src/common/consumer.h >> index 82b9bc6..4638752 100644 >> --- a/src/common/consumer.h >> +++ b/src/common/consumer.h >> @@ -89,6 +89,9 @@ struct stream_list { >> unsigned int count; >> }; >> >> +/* Stub. */ >> +struct consumer_metadata_cache; >> + >> struct lttng_consumer_channel { >> /* HT node used for consumer_data.channel_ht */ >> struct lttng_ht_node_u64 node; >> @@ -132,16 +135,17 @@ struct lttng_consumer_channel { >> * regular channel, this is always set to NULL. >> */ >> struct lttng_consumer_stream *metadata_stream; >> - /* >> - * Metadata written so far. Helps keeping track of >> - * contiguousness and order. >> - */ >> - uint64_t contig_metadata_written; >> >> /* for UST */ >> int wait_fd; >> /* Node within channel thread ht */ >> struct lttng_ht_node_u64 wait_fd_node; >> + >> + /* Metadata cache is metadata channel */ >> + struct consumer_metadata_cache *metadata_cache; >> + /* For metadata periodical flush */ >> + int switch_timer_enabled; >> + timer_t switch_timer; >> }; >> >> /* >> @@ -322,8 +326,11 @@ struct lttng_consumer_local_data { >> * < 0 (error) >> */ >> int (*on_update_stream)(int sessiond_key, uint32_t state); >> + enum lttng_consumer_type type; >> /* socket to communicate errors with sessiond */ >> int consumer_error_socket; >> + /* socket to ask metadata to sessiond */ >> + int consumer_metadata_socket; >> /* socket to exchange commands with sessiond */ >> char *consumer_command_sock_path; >> /* communication with splice */ >> diff --git a/src/common/defaults.h b/src/common/defaults.h >> index 658e7d3..94a2a35 100644 >> --- a/src/common/defaults.h >> +++ b/src/common/defaults.h >> @@ -76,7 +76,6 @@ >> #define DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/command" >> #define DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/error" >> >> - >> /* Default lttng run directory */ >> #define DEFAULT_LTTNG_RUNDIR "/var/run/lttng" >> #define DEFAULT_LTTNG_HOME_RUNDIR "%s/.lttng" >> @@ -124,6 +123,7 @@ >> >> #define DEFAULT_METADATA_SUBBUF_SIZE 4096 >> #define DEFAULT_METADATA_SUBBUF_NUM 2 >> +#define DEFAULT_METADATA_CACHE_SIZE 4096 >> >> /* Kernel has different defaults */ >> >> @@ -179,6 +179,12 @@ >> #define DEFAULT_DATA_AVAILABILITY_WAIT_TIME 200000 /* usec */ >> >> /* >> + * Wait period before retrying the lttng_consumer_flushed_cache when >> + * the consumer receives metadata. >> + */ >> +#define DEFAULT_METADATA_AVAILABILITY_WAIT_TIME 200000 /* usec */ >> + >> +/* >> * Default receiving and sending timeout for an application socket. >> */ >> #define DEFAULT_APP_SOCKET_RW_TIMEOUT 5 /* sec */ >> diff --git a/src/common/macros.h b/src/common/macros.h >> index f6f975d..fc159c0 100644 >> --- a/src/common/macros.h >> +++ b/src/common/macros.h >> @@ -56,6 +56,10 @@ >> #define max(a, b) ((a) > (b) ? (a) : (b)) >> #endif >> >> +#ifndef max_t >> +#define max_t(type, a, b) ((type) max(a, b)) >> +#endif >> + >> #ifndef min >> #define min(a, b) ((a) < (b) ? (a) : (b)) >> #endif >> diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h >> index 6350fd1..cb5a88b 100644 >> --- a/src/common/sessiond-comm/sessiond-comm.h >> +++ b/src/common/sessiond-comm/sessiond-comm.h >> @@ -138,6 +138,21 @@ enum lttcomm_sock_domain { >> LTTCOMM_INET6 = 1, >> }; >> >> +enum lttcomm_metadata_command { >> + LTTCOMM_METADATA_REQUEST = 1, >> +}; >> + >> +/* >> + * Commands sent from the consumerd to the sessiond to request >> + * if new metadata is available >> + */ >> +struct lttcomm_metadata_request_msg { >> + unsigned int session_id; /* Tracing session id */ >> + uint32_t bits_per_long; /* Consumer ABI */ >> + uint32_t uid; >> + uint64_t key; /* Metadata channel key. */ >> +} LTTNG_PACKED; > > What happens for per-pid UST buffers ? This message seems to be quite > specific to per-uid buffers ? We ignore every value and use the session id only for per PID. The consumer has no idea if the metadata channel is per UID or PID on the sessiond side so we lookup per uid using all of the values, if failure, per pid with only the session id. David > > Thanks, > > Mathieu > >> + >> struct lttcomm_sockaddr { >> enum lttcomm_sock_domain type; >> union { >> diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c >> index 06b59c5..e56f023 100644 >> --- a/src/common/ust-consumer/ust-consumer.c >> +++ b/src/common/ust-consumer/ust-consumer.c >> @@ -30,11 +30,14 @@ >> #include >> #include >> #include >> +#include >> >> #include >> #include >> #include >> #include >> +#include >> +#include >> >> #include "ust-consumer.h" >> >> @@ -530,10 +533,12 @@ error: >> /* >> * Write metadata to the given channel using ustctl to convert the string to >> * the ringbuffer. >> + * Called only from consumer_metadata_cache_write. >> + * The metadata cache lock MUST be acquired to write in the cache. >> * >> * Return 0 on success else a negative value. >> */ >> -static int push_metadata(struct lttng_consumer_channel *metadata, >> +int lttng_ustconsumer_push_metadata(struct lttng_consumer_channel *metadata, >> const char *metadata_str, uint64_t target_offset, uint64_t len) >> { >> int ret; >> @@ -543,13 +548,13 @@ static int push_metadata(struct lttng_consumer_channel *metadata, >> >> DBG("UST consumer writing metadata to channel %s", metadata->name); >> >> - assert(target_offset == metadata->contig_metadata_written); >> + assert(target_offset <= metadata->metadata_cache->max_offset); >> ret = ustctl_write_metadata_to_channel(metadata->uchan, metadata_str, len); >> if (ret < 0) { >> ERR("ustctl write metadata fail with ret %d, len %ld", ret, len); >> goto error; >> } >> - metadata->contig_metadata_written += len; >> + metadata->metadata_cache->rb_pushed += len; >> >> ustctl_flush_buffer(metadata->metadata_stream->ustream, 1); >> >> @@ -619,6 +624,11 @@ static int close_metadata(uint64_t chan_key) >> ret = LTTCOMM_CONSUMERD_ERROR_METADATA; >> goto error; >> } >> + if (channel->switch_timer_enabled == 1) { >> + DBG("Deleting timer on metadata channel"); >> + consumer_timer_switch_stop(channel); >> + } >> + consumer_metadata_cache_destroy(channel); >> >> error: >> return ret; >> @@ -679,6 +689,51 @@ error: >> } >> >> /* >> + * Receive the metadata updates from the sessiond. >> + */ >> +int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset, >> + uint64_t len, struct lttng_consumer_channel *channel) >> +{ >> + int ret, ret_code = LTTNG_OK; >> + char *metadata_str; >> + >> + DBG("UST consumer push metadata key %lu of len %lu", key, len); >> + >> + metadata_str = zmalloc(len * sizeof(char)); >> + if (!metadata_str) { >> + PERROR("zmalloc metadata string"); >> + ret_code = LTTCOMM_CONSUMERD_ENOMEM; >> + goto end; >> + } >> + >> + /* Receive metadata string. */ >> + ret = lttcomm_recv_unix_sock(sock, metadata_str, len); >> + if (ret < 0) { >> + /* Session daemon is dead so return gracefully. */ >> + ret_code = ret; >> + goto end_free; >> + } >> + >> + pthread_mutex_lock(&channel->metadata_cache->lock); >> + ret = consumer_metadata_cache_write(channel, offset, len, metadata_str); >> + if (ret < 0) { >> + /* Unable to handle metadata. Notify session daemon. */ >> + ret_code = LTTCOMM_CONSUMERD_ERROR_METADATA; >> + } >> + pthread_mutex_unlock(&channel->metadata_cache->lock); >> + >> + while (consumer_metadata_cache_flushed(channel, offset + len)) { >> + DBG("Waiting for metadata to be flushed"); >> + usleep(DEFAULT_METADATA_AVAILABILITY_WAIT_TIME); >> + } >> + >> +end_free: >> + free(metadata_str); >> +end: >> + return ret_code; >> +} >> + >> +/* >> * Receive command from session daemon and process it. >> * >> * Return 1 on success else a negative value or 0. >> @@ -847,6 +902,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, >> goto end_channel_error; >> } >> >> + >> /* >> * Channel and streams are now created. Inform the session daemon that >> * everything went well and should wait to receive the channel and >> @@ -861,6 +917,16 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, >> goto end_nosignal; >> } >> >> + if (msg.u.ask_channel.type == LTTNG_UST_CHAN_METADATA) { >> + ret = consumer_metadata_cache_allocate(channel); >> + if (ret < 0) { >> + ERR("Allocating metadata cache"); >> + goto end_channel_error; >> + } >> + consumer_timer_switch_start(channel, attr.switch_timer_interval); >> + attr.switch_timer_interval = 0; >> + } >> + >> break; >> } >> case LTTNG_CONSUMER_GET_CHANNEL: >> @@ -957,10 +1023,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, >> { >> int ret; >> uint64_t len = msg.u.push_metadata.len; >> - uint64_t target_offset = msg.u.push_metadata.target_offset; >> uint64_t key = msg.u.push_metadata.key; >> + uint64_t offset = msg.u.push_metadata.target_offset; >> struct lttng_consumer_channel *channel; >> - char *metadata_str; >> >> DBG("UST consumer push metadata key %lu of len %lu", key, len); >> >> @@ -968,14 +1033,6 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, >> if (!channel) { >> ERR("UST consumer push metadata %lu not found", key); >> ret_code = LTTNG_ERR_UST_CHAN_NOT_FOUND; >> - goto end_msg_sessiond; >> - } >> - >> - metadata_str = zmalloc(len * sizeof(char)); >> - if (!metadata_str) { >> - PERROR("zmalloc metadata string"); >> - ret_code = LTTCOMM_CONSUMERD_ENOMEM; >> - goto end_msg_sessiond; >> } >> >> /* Tell session daemon we are ready to receive the metadata. */ >> @@ -990,22 +1047,15 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, >> goto end_nosignal; >> } >> >> - /* Receive metadata string. */ >> - ret = lttcomm_recv_unix_sock(sock, metadata_str, len); >> + ret = lttng_ustconsumer_recv_metadata(sock, key, offset, >> + len, channel); >> if (ret < 0) { >> - /* Session daemon is dead so return gracefully. */ >> + /* error receiving from sessiond */ >> goto end_nosignal; >> - } >> - >> - ret = push_metadata(channel, metadata_str, target_offset, len); >> - free(metadata_str); >> - if (ret < 0) { >> - /* Unable to handle metadata. Notify session daemon. */ >> - ret_code = LTTCOMM_CONSUMERD_ERROR_METADATA; >> + } else { >> + ret_code = ret; >> goto end_msg_sessiond; >> } >> - >> - goto end_msg_sessiond; >> } >> case LTTNG_CONSUMER_SETUP_METADATA: >> { >> @@ -1223,6 +1273,7 @@ int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream, >> } >> err = ustctl_put_next_subbuf(ustream); >> assert(err == 0); >> + >> end: >> return ret; >> } >> @@ -1343,3 +1394,96 @@ void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream) >> ERR("Unable to close wakeup fd"); >> } >> } >> + >> +int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx, >> + struct lttng_consumer_channel *channel) >> +{ >> + struct lttcomm_metadata_request_msg request; >> + struct lttcomm_consumer_msg msg; >> + enum lttng_error_code ret_code = LTTNG_OK; >> + uint64_t len, key, offset; >> + int ret; >> + >> + assert(channel); >> + assert(channel->metadata_cache); >> + >> + /* send the metadata request to sessiond */ >> + switch (consumer_data.type) { >> + case LTTNG_CONSUMER64_UST: >> + request.bits_per_long = 64; >> + break; >> + case LTTNG_CONSUMER32_UST: >> + request.bits_per_long = 32; >> + break; >> + default: >> + request.bits_per_long = 0; >> + break; >> + } >> + >> + request.session_id = channel->session_id; >> + request.uid = channel->uid; >> + request.key = channel->key; >> + DBG("Sending metadata request to sessiond, session %" PRIu64, >> + channel->session_id); >> + >> + ret = lttcomm_send_unix_sock(ctx->consumer_metadata_socket, &request, >> + sizeof(request)); >> + if (ret < 0) { >> + ERR("Asking metadata to sessiond"); >> + goto end; >> + } >> + >> + /* Receive the metadata from sessiond */ >> + ret = lttcomm_recv_unix_sock(ctx->consumer_metadata_socket, &msg, >> + sizeof(msg)); >> + if (ret != sizeof(msg)) { >> + DBG("Consumer received unexpected message size %d (expects %lu)", >> + ret, sizeof(msg)); >> + lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_CMD); >> + /* >> + * The ret value might 0 meaning an orderly shutdown but this is ok >> + * since the caller handles this. >> + */ >> + goto end; >> + } >> + >> + if (msg.cmd_type == LTTNG_ERR_UND) { >> + /* No registry found */ >> + (void) consumer_send_status_msg(ctx->consumer_metadata_socket, >> + ret_code); >> + ret = 0; >> + goto end; >> + } else if (msg.cmd_type != LTTNG_CONSUMER_PUSH_METADATA) { >> + ERR("Unexpected cmd_type received %d", msg.cmd_type); >> + ret = -1; >> + goto end; >> + } >> + >> + len = msg.u.push_metadata.len; >> + key = msg.u.push_metadata.key; >> + offset = msg.u.push_metadata.target_offset; >> + >> + assert(key == channel->key); >> + if (len == 0) { >> + DBG("No new metadata to receive for key %" PRIu64, key); >> + } >> + >> + /* Tell session daemon we are ready to receive the metadata. */ >> + ret = consumer_send_status_msg(ctx->consumer_metadata_socket, >> + LTTNG_OK); >> + if (ret < 0 || len == 0) { >> + /* >> + * Somehow, the session daemon is not responding anymore or there is >> + * nothing to receive. >> + */ >> + goto end; >> + } >> + >> + ret_code = lttng_ustconsumer_recv_metadata(ctx->consumer_metadata_socket, >> + key, offset, len, channel); >> + (void) consumer_send_status_msg(ctx->consumer_metadata_socket, ret_code); >> + ret = 0; >> + >> +end: >> + return ret; >> +} >> diff --git a/src/common/ust-consumer/ust-consumer.h b/src/common/ust-consumer/ust-consumer.h >> index bbaff6c..d748582 100644 >> --- a/src/common/ust-consumer/ust-consumer.h >> +++ b/src/common/ust-consumer/ust-consumer.h >> @@ -51,6 +51,12 @@ void *lttng_ustctl_get_mmap_base(struct lttng_consumer_stream *stream); >> int lttng_ustconsumer_data_pending(struct lttng_consumer_stream *stream); >> void lttng_ustconsumer_close_metadata(struct lttng_ht *ht); >> void lttng_ustconsumer_close_stream_wakeup(struct lttng_consumer_stream *stream); >> +int lttng_ustconsumer_recv_metadata(int sock, uint64_t key, uint64_t offset, >> + uint64_t len, struct lttng_consumer_channel *channel); >> +int lttng_ustconsumer_push_metadata(struct lttng_consumer_channel *metadata, >> + const char *metadata_str, uint64_t target_offset, uint64_t len); >> +int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx, >> + struct lttng_consumer_channel *channel); >> >> #else /* HAVE_LIBLTTNG_UST_CTL */ >> >> diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am >> index a9d65ab..169ca2e 100644 >> --- a/tests/unit/Makefile.am >> +++ b/tests/unit/Makefile.am >> @@ -47,8 +47,9 @@ UST_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-ust.c \ >> $(top_srcdir)/src/bin/lttng-sessiond/ust-consumer.c \ >> $(top_srcdir)/src/bin/lttng-sessiond/fd-limit.c \ >> $(top_srcdir)/src/bin/lttng-sessiond/health.c \ >> - $(top_srcdir)/src/common/uri.c \ >> - $(top_srcdir)/src/common/utils.c >> + $(top_srcdir)/src/bin/lttng-sessiond/session.c \ >> + $(top_srcdir)/src/common/uri.c \ >> + $(top_srcdir)/src/common/utils.c >> >> test_ust_data_SOURCES = test_ust_data.c $(UST_DATA_TRACE) >> test_ust_data_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBSESSIOND_COMM) $(LIBHASHTABLE) \ >> -- >> 1.7.10.4 >> >> >> _______________________________________________ >> lttng-dev mailing list >> lttng-dev at lists.lttng.org >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > From mathieu.desnoyers at efficios.com Tue Mar 26 15:18:25 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Tue, 26 Mar 2013 15:18:25 -0400 Subject: [lttng-dev] [PATCH lttng-tools] UST periodical metadata flush In-Reply-To: <5151F291.50205@efficios.com> References: <1364320199-30440-1-git-send-email-dgoulet@efficios.com> <20130326185938.GA18985@Krystal> <5151F291.50205@efficios.com> Message-ID: <20130326191825.GA19325@Krystal> * David Goulet (dgoulet at efficios.com) wrote: > > > Mathieu Desnoyers: > > * David Goulet (dgoulet at efficios.com) wrote: [...] > >> + /* Create the thread to manage the metadata periodic timers */ > >> + ret = pthread_create(&metadata_timer_thread, NULL, > >> + consumer_timer_metadata_thread, (void *) ctx); > >> + if (ret != 0) { > >> + perror("pthread_create"); > >> + goto metadata_timer_error; > >> + } > >> + > >> + ret = pthread_detach(metadata_timer_thread); > >> + if (ret) { > >> + errno = ret; > >> + perror("pthread_detach"); > >> + } > > > > Hrm, if pthread_detach fails, maybe we should join the > > metadata_timer_thread ? > > > > Not sure... that thread as *no* way of getting out of it's main loop so > this is going to wait for a LONG time :P. OK, good enough. [...] > >> > >> - /* Inifinite blocking call, waiting for transmission */ > >> + /* Infinite blocking call, waiting for transmission */ > >> restart_poll: > >> - health_poll_entry(); > >> - ret = lttng_poll_wait(&events, -1); > >> - health_poll_exit(); > >> - if (ret < 0) { > >> - /* > >> - * Restart interrupted system call. > >> - */ > >> - if (errno == EINTR) { > >> - goto restart_poll; > >> + while (1) { > > > > why are we getting this refactoring ? Is it necessary ? > > It is. We've added a metadata socket that receives commands from the > consumer so we need to poll at vitam eternam for that. OK. we just need to review this code very carefully. I see it's mainly an indentation change, so hopefully the change is not too intrusive. [...] > >> /* > >> + * Push metadata to consumer socket. The socket lock MUST be acquired. > >> + * > >> + * On success, return the len of metadata pushed or else a negative value. > >> + */ > >> +ssize_t ust_app_push_metadata(struct ust_registry_session *registry, > >> + struct consumer_socket *socket) > >> +{ > >> + int ret; > >> + char *metadata_str = NULL; > >> + size_t len, offset; > >> + ssize_t ret_val; > >> + > >> + assert(registry); > >> + assert(socket); > >> + > >> + pthread_mutex_lock(®istry->lock); > >> + > >> + offset = registry->metadata_len_sent; > >> + len = registry->metadata_len - registry->metadata_len_sent; > >> + if (len == 0) { > >> + DBG3("No metadata to push for metadata key %" PRIu64, > >> + registry->metadata_key); > >> + goto end; > >> + } > >> + > >> + /* Allocate only what we have to send. */ > >> + metadata_str = zmalloc(len); > >> + if (!metadata_str) { > >> + PERROR("zmalloc ust app metadata string"); > >> + ret_val = -ENOMEM; > >> + goto error; > >> + } > >> + /* Copy what we haven't send out. */ > >> + memcpy(metadata_str, registry->metadata + offset, len); > >> + > >> + ret = consumer_push_metadata(socket, registry->metadata_key, > >> + metadata_str, len, offset); > > > > I think consumer_push_metadata() sends metadata to consumerd. This is > > done with the registry lock held. This should _not_ be done. > > > > The registry lock _needs_ to be held only for short periods of time. > > Hmmm indeed. I'll put back the lock around the registry below to update > the len. Yep, the lock is really only needed to "grab" the range to update from the registry. All the reordering the might be needed on the consumer side when it receives the data into its cache is done at reception. > > > > >> + if (ret < 0) { > >> + ret_val = ret; > >> + goto error; > >> + } > >> + > >> + registry->metadata_len_sent += len; > >> + > >> +end: > >> + ret_val = len; > >> +error: > >> + free(metadata_str); > >> + pthread_mutex_unlock(®istry->lock); > >> + return ret_val; > >> +} > >> + > >> +/* > >> * For a given application and session, push metadata to consumer. The session > >> * lock MUST be acquired here before calling this. > >> + * Either sock or consumer is required : if sock is NULL, the default > >> + * socket to send the metadata is retrieved from consumer, if sock > >> + * is not NULL we use it to send the metadata. > >> * > >> * Return 0 on success else a negative error. > >> */ > >> static int push_metadata(struct ust_registry_session *registry, > >> struct consumer_output *consumer) > >> { > >> - int ret; > >> - char *metadata_str = NULL; > >> - size_t len, offset; > >> + int ret_val; > >> + ssize_t ret; > >> struct consumer_socket *socket; > >> > >> assert(registry); > >> @@ -391,7 +447,7 @@ static int push_metadata(struct ust_registry_session *registry, > >> * no start has been done previously. > >> */ > >> if (!registry->metadata_key) { > >> - ret = 0; > >> + ret_val = 0; > >> goto error_rcu_unlock; > >> } > >> > >> @@ -399,7 +455,7 @@ static int push_metadata(struct ust_registry_session *registry, > >> socket = consumer_find_socket_by_bitness(registry->bits_per_long, > >> consumer); > >> if (!socket) { > >> - ret = -1; > >> + ret_val = -1; > >> goto error_rcu_unlock; > >> } > >> > >> @@ -414,54 +470,19 @@ static int push_metadata(struct ust_registry_session *registry, > >> * ability to reorder the metadata it receives. > >> */ > >> pthread_mutex_lock(socket->lock); > >> - pthread_mutex_lock(®istry->lock); another question: We don't seem to need nesting of the registry lock inside the socket lock anymore on the sessiond side. We probably have some comments to update around those locks elsewhere ? [...] > >> +/* > >> + * Commands sent from the consumerd to the sessiond to request > >> + * if new metadata is available > >> + */ > >> +struct lttcomm_metadata_request_msg { > >> + unsigned int session_id; /* Tracing session id */ > >> + uint32_t bits_per_long; /* Consumer ABI */ > >> + uint32_t uid; > >> + uint64_t key; /* Metadata channel key. */ > >> +} LTTNG_PACKED; > > > > What happens for per-pid UST buffers ? This message seems to be quite > > specific to per-uid buffers ? > > We ignore every value and use the session id only for per PID. The > consumer has no idea if the metadata channel is per UID or PID on the > sessiond side so we lookup per uid using all of the values, if failure, > per pid with only the session id. OK, this should be clearly documented in the code. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From dgoulet at efficios.com Tue Mar 26 15:23:46 2013 From: dgoulet at efficios.com (David Goulet) Date: Tue, 26 Mar 2013 15:23:46 -0400 Subject: [lttng-dev] [PATCH lttng-tools] UST periodical metadata flush In-Reply-To: <20130326191825.GA19325@Krystal> References: <1364320199-30440-1-git-send-email-dgoulet@efficios.com> <20130326185938.GA18985@Krystal> <5151F291.50205@efficios.com> <20130326191825.GA19325@Krystal> Message-ID: <5151F5C2.1090807@efficios.com> Mathieu Desnoyers: >>>> >>>> - /* Inifinite blocking call, waiting for transmission */ >>>> + /* Infinite blocking call, waiting for transmission */ >>>> restart_poll: >>>> - health_poll_entry(); >>>> - ret = lttng_poll_wait(&events, -1); >>>> - health_poll_exit(); >>>> - if (ret < 0) { >>>> - /* >>>> - * Restart interrupted system call. >>>> - */ >>>> - if (errno == EINTR) { >>>> - goto restart_poll; >>>> + while (1) { >>> >>> why are we getting this refactoring ? Is it necessary ? >> >> It is. We've added a metadata socket that receives commands from the >> consumer so we need to poll at vitam eternam for that. > > OK. we just need to review this code very carefully. I see it's mainly > an indentation change, so hopefully the change is not too intrusive. It is. The main part was simply the else if on the pollfd to check for event on the metadata socket. [...] >>>> * For a given application and session, push metadata to consumer. The session >>>> * lock MUST be acquired here before calling this. >>>> + * Either sock or consumer is required : if sock is NULL, the default >>>> + * socket to send the metadata is retrieved from consumer, if sock >>>> + * is not NULL we use it to send the metadata. >>>> * >>>> * Return 0 on success else a negative error. >>>> */ >>>> static int push_metadata(struct ust_registry_session *registry, >>>> struct consumer_output *consumer) >>>> { >>>> - int ret; >>>> - char *metadata_str = NULL; >>>> - size_t len, offset; >>>> + int ret_val; >>>> + ssize_t ret; >>>> struct consumer_socket *socket; >>>> >>>> assert(registry); >>>> @@ -391,7 +447,7 @@ static int push_metadata(struct ust_registry_session *registry, >>>> * no start has been done previously. >>>> */ >>>> if (!registry->metadata_key) { >>>> - ret = 0; >>>> + ret_val = 0; >>>> goto error_rcu_unlock; >>>> } >>>> >>>> @@ -399,7 +455,7 @@ static int push_metadata(struct ust_registry_session *registry, >>>> socket = consumer_find_socket_by_bitness(registry->bits_per_long, >>>> consumer); >>>> if (!socket) { >>>> - ret = -1; >>>> + ret_val = -1; >>>> goto error_rcu_unlock; >>>> } >>>> >>>> @@ -414,54 +470,19 @@ static int push_metadata(struct ust_registry_session *registry, >>>> * ability to reorder the metadata it receives. >>>> */ >>>> pthread_mutex_lock(socket->lock); >>>> - pthread_mutex_lock(®istry->lock); > > another question: We don't seem to need nesting of the registry lock > inside the socket lock anymore on the sessiond side. We probably have > some comments to update around those locks elsewhere ? Well not sure here. This function has been split in two where this one finds the socket and lock it then calls ust_app_push_metadata that *locks* the registry. So there is still nesting needed. ust_app_push_metadata() *MUST* be called with the socket lock (it is documented). So to that extent, the registry lock still nest in the socket lock. > > [...] >>>> +/* >>>> + * Commands sent from the consumerd to the sessiond to request >>>> + * if new metadata is available >>>> + */ >>>> +struct lttcomm_metadata_request_msg { >>>> + unsigned int session_id; /* Tracing session id */ >>>> + uint32_t bits_per_long; /* Consumer ABI */ >>>> + uint32_t uid; >>>> + uint64_t key; /* Metadata channel key. */ >>>> +} LTTNG_PACKED; >>> >>> What happens for per-pid UST buffers ? This message seems to be quite >>> specific to per-uid buffers ? >> >> We ignore every value and use the session id only for per PID. The >> consumer has no idea if the metadata channel is per UID or PID on the >> sessiond side so we lookup per uid using all of the values, if failure, >> per pid with only the session id. > > OK, this should be clearly documented in the code. I'll make sure of that. David > > Thanks, > > Mathieu > From mathieu.desnoyers at efficios.com Tue Mar 26 15:29:26 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Tue, 26 Mar 2013 15:29:26 -0400 Subject: [lttng-dev] [PATCH lttng-tools] UST periodical metadata flush In-Reply-To: <5151F5C2.1090807@efficios.com> References: <1364320199-30440-1-git-send-email-dgoulet@efficios.com> <20130326185938.GA18985@Krystal> <5151F291.50205@efficios.com> <20130326191825.GA19325@Krystal> <5151F5C2.1090807@efficios.com> Message-ID: <20130326192925.GA19560@Krystal> * David Goulet (dgoulet at efficios.com) wrote: > > > Mathieu Desnoyers: > >>>> > >>>> - /* Inifinite blocking call, waiting for transmission */ > >>>> + /* Infinite blocking call, waiting for transmission */ > >>>> restart_poll: > >>>> - health_poll_entry(); > >>>> - ret = lttng_poll_wait(&events, -1); > >>>> - health_poll_exit(); > >>>> - if (ret < 0) { > >>>> - /* > >>>> - * Restart interrupted system call. > >>>> - */ > >>>> - if (errno == EINTR) { > >>>> - goto restart_poll; > >>>> + while (1) { > >>> > >>> why are we getting this refactoring ? Is it necessary ? > >> > >> It is. We've added a metadata socket that receives commands from the > >> consumer so we need to poll at vitam eternam for that. > > > > OK. we just need to review this code very carefully. I see it's mainly > > an indentation change, so hopefully the change is not too intrusive. > > It is. The main part was simply the else if on the pollfd to check for > event on the metadata socket. > > [...] > >>>> * For a given application and session, push metadata to consumer. The session > >>>> * lock MUST be acquired here before calling this. > >>>> + * Either sock or consumer is required : if sock is NULL, the default > >>>> + * socket to send the metadata is retrieved from consumer, if sock > >>>> + * is not NULL we use it to send the metadata. > >>>> * > >>>> * Return 0 on success else a negative error. > >>>> */ > >>>> static int push_metadata(struct ust_registry_session *registry, > >>>> struct consumer_output *consumer) > >>>> { > >>>> - int ret; > >>>> - char *metadata_str = NULL; > >>>> - size_t len, offset; > >>>> + int ret_val; > >>>> + ssize_t ret; > >>>> struct consumer_socket *socket; > >>>> > >>>> assert(registry); > >>>> @@ -391,7 +447,7 @@ static int push_metadata(struct ust_registry_session *registry, > >>>> * no start has been done previously. > >>>> */ > >>>> if (!registry->metadata_key) { > >>>> - ret = 0; > >>>> + ret_val = 0; > >>>> goto error_rcu_unlock; > >>>> } > >>>> > >>>> @@ -399,7 +455,7 @@ static int push_metadata(struct ust_registry_session *registry, > >>>> socket = consumer_find_socket_by_bitness(registry->bits_per_long, > >>>> consumer); > >>>> if (!socket) { > >>>> - ret = -1; > >>>> + ret_val = -1; > >>>> goto error_rcu_unlock; > >>>> } > >>>> > >>>> @@ -414,54 +470,19 @@ static int push_metadata(struct ust_registry_session *registry, > >>>> * ability to reorder the metadata it receives. > >>>> */ > >>>> pthread_mutex_lock(socket->lock); > >>>> - pthread_mutex_lock(®istry->lock); > > > > another question: We don't seem to need nesting of the registry lock > > inside the socket lock anymore on the sessiond side. We probably have > > some comments to update around those locks elsewhere ? > > Well not sure here. This function has been split in two where this one > finds the socket and lock it then calls ust_app_push_metadata that > *locks* the registry. So there is still nesting needed. > ust_app_push_metadata() *MUST* be called with the socket lock (it is > documented). So to that extent, the registry lock still nest in the > socket lock. Why do we need to lock the socket lock insite push_metadata() ? We could probably take both locks one after the other (not nested) within ust_app_push_metadata(), given that we now allow out-of-order metadata segments ? Thanks, Mathieu > > > > > [...] > >>>> +/* > >>>> + * Commands sent from the consumerd to the sessiond to request > >>>> + * if new metadata is available > >>>> + */ > >>>> +struct lttcomm_metadata_request_msg { > >>>> + unsigned int session_id; /* Tracing session id */ > >>>> + uint32_t bits_per_long; /* Consumer ABI */ > >>>> + uint32_t uid; > >>>> + uint64_t key; /* Metadata channel key. */ > >>>> +} LTTNG_PACKED; > >>> > >>> What happens for per-pid UST buffers ? This message seems to be quite > >>> specific to per-uid buffers ? > >> > >> We ignore every value and use the session id only for per PID. The > >> consumer has no idea if the metadata channel is per UID or PID on the > >> sessiond side so we lookup per uid using all of the values, if failure, > >> per pid with only the session id. > > > > OK, this should be clearly documented in the code. > > I'll make sure of that. > > David > > > > > Thanks, > > > > Mathieu > > -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From dgoulet at efficios.com Tue Mar 26 15:36:03 2013 From: dgoulet at efficios.com (David Goulet) Date: Tue, 26 Mar 2013 15:36:03 -0400 Subject: [lttng-dev] [PATCH lttng-tools] UST periodical metadata flush In-Reply-To: <20130326192925.GA19560@Krystal> References: <1364320199-30440-1-git-send-email-dgoulet@efficios.com> <20130326185938.GA18985@Krystal> <5151F291.50205@efficios.com> <20130326191825.GA19325@Krystal> <5151F5C2.1090807@efficios.com> <20130326192925.GA19560@Krystal> Message-ID: <5151F8A3.7010006@efficios.com> Mathieu Desnoyers: >>>>>> * For a given application and session, push metadata to consumer. The session >>>>>> * lock MUST be acquired here before calling this. >>>>>> + * Either sock or consumer is required : if sock is NULL, the default >>>>>> + * socket to send the metadata is retrieved from consumer, if sock >>>>>> + * is not NULL we use it to send the metadata. >>>>>> * >>>>>> * Return 0 on success else a negative error. >>>>>> */ >>>>>> static int push_metadata(struct ust_registry_session *registry, >>>>>> struct consumer_output *consumer) >>>>>> { >>>>>> - int ret; >>>>>> - char *metadata_str = NULL; >>>>>> - size_t len, offset; >>>>>> + int ret_val; >>>>>> + ssize_t ret; >>>>>> struct consumer_socket *socket; >>>>>> >>>>>> assert(registry); >>>>>> @@ -391,7 +447,7 @@ static int push_metadata(struct ust_registry_session *registry, >>>>>> * no start has been done previously. >>>>>> */ >>>>>> if (!registry->metadata_key) { >>>>>> - ret = 0; >>>>>> + ret_val = 0; >>>>>> goto error_rcu_unlock; >>>>>> } >>>>>> >>>>>> @@ -399,7 +455,7 @@ static int push_metadata(struct ust_registry_session *registry, >>>>>> socket = consumer_find_socket_by_bitness(registry->bits_per_long, >>>>>> consumer); >>>>>> if (!socket) { >>>>>> - ret = -1; >>>>>> + ret_val = -1; >>>>>> goto error_rcu_unlock; >>>>>> } >>>>>> >>>>>> @@ -414,54 +470,19 @@ static int push_metadata(struct ust_registry_session *registry, >>>>>> * ability to reorder the metadata it receives. >>>>>> */ >>>>>> pthread_mutex_lock(socket->lock); >>>>>> - pthread_mutex_lock(®istry->lock); >>> >>> another question: We don't seem to need nesting of the registry lock >>> inside the socket lock anymore on the sessiond side. We probably have >>> some comments to update around those locks elsewhere ? >> >> Well not sure here. This function has been split in two where this one >> finds the socket and lock it then calls ust_app_push_metadata that >> *locks* the registry. So there is still nesting needed. >> ust_app_push_metadata() *MUST* be called with the socket lock (it is >> documented). So to that extent, the registry lock still nest in the >> socket lock. > > Why do we need to lock the socket lock insite push_metadata() ? > > We could probably take both locks one after the other (not nested) > within ust_app_push_metadata(), given that we now allow out-of-order > metadata segments ? The problem is with the new way we request metadata coming from the consumer. We need to lock the socket through the receive command up to the push metadata call (ust_app_push_metadata). We have now two call sites that use this function so the split was needed where one function finds the socket object, lock it and calls the push metadata. (see ust_consumer_metadata_request() in sessiond/ust-consumer.c for the second call site). You see a better way of doing it ? David > > Thanks, > > Mathieu > From mathieu.desnoyers at efficios.com Tue Mar 26 16:34:41 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Tue, 26 Mar 2013 16:34:41 -0400 Subject: [lttng-dev] [PATCH lttng-tools] UST periodical metadata flush In-Reply-To: <5151F8A3.7010006@efficios.com> References: <1364320199-30440-1-git-send-email-dgoulet@efficios.com> <20130326185938.GA18985@Krystal> <5151F291.50205@efficios.com> <20130326191825.GA19325@Krystal> <5151F5C2.1090807@efficios.com> <20130326192925.GA19560@Krystal> <5151F8A3.7010006@efficios.com> Message-ID: <20130326203441.GA19637@Krystal> * David Goulet (dgoulet at efficios.com) wrote: > > > Mathieu Desnoyers: > >>>>>> * For a given application and session, push metadata to consumer. The session > >>>>>> * lock MUST be acquired here before calling this. > >>>>>> + * Either sock or consumer is required : if sock is NULL, the default > >>>>>> + * socket to send the metadata is retrieved from consumer, if sock > >>>>>> + * is not NULL we use it to send the metadata. > >>>>>> * > >>>>>> * Return 0 on success else a negative error. > >>>>>> */ > >>>>>> static int push_metadata(struct ust_registry_session *registry, > >>>>>> struct consumer_output *consumer) > >>>>>> { > >>>>>> - int ret; > >>>>>> - char *metadata_str = NULL; > >>>>>> - size_t len, offset; > >>>>>> + int ret_val; > >>>>>> + ssize_t ret; > >>>>>> struct consumer_socket *socket; > >>>>>> > >>>>>> assert(registry); > >>>>>> @@ -391,7 +447,7 @@ static int push_metadata(struct ust_registry_session *registry, > >>>>>> * no start has been done previously. > >>>>>> */ > >>>>>> if (!registry->metadata_key) { > >>>>>> - ret = 0; > >>>>>> + ret_val = 0; > >>>>>> goto error_rcu_unlock; > >>>>>> } > >>>>>> > >>>>>> @@ -399,7 +455,7 @@ static int push_metadata(struct ust_registry_session *registry, > >>>>>> socket = consumer_find_socket_by_bitness(registry->bits_per_long, > >>>>>> consumer); > >>>>>> if (!socket) { > >>>>>> - ret = -1; > >>>>>> + ret_val = -1; > >>>>>> goto error_rcu_unlock; > >>>>>> } > >>>>>> > >>>>>> @@ -414,54 +470,19 @@ static int push_metadata(struct ust_registry_session *registry, > >>>>>> * ability to reorder the metadata it receives. > >>>>>> */ > >>>>>> pthread_mutex_lock(socket->lock); > >>>>>> - pthread_mutex_lock(®istry->lock); > >>> > >>> another question: We don't seem to need nesting of the registry lock > >>> inside the socket lock anymore on the sessiond side. We probably have > >>> some comments to update around those locks elsewhere ? > >> > >> Well not sure here. This function has been split in two where this one > >> finds the socket and lock it then calls ust_app_push_metadata that > >> *locks* the registry. So there is still nesting needed. > >> ust_app_push_metadata() *MUST* be called with the socket lock (it is > >> documented). So to that extent, the registry lock still nest in the > >> socket lock. > > > > Why do we need to lock the socket lock insite push_metadata() ? > > > > We could probably take both locks one after the other (not nested) > > within ust_app_push_metadata(), given that we now allow out-of-order > > metadata segments ? > > The problem is with the new way we request metadata coming from the > consumer. We need to lock the socket through the receive command up to > the push metadata call (ust_app_push_metadata). We have now two call > sites that use this function so the split was needed where one function > finds the socket object, lock it and calls the push metadata. (see > ust_consumer_metadata_request() in sessiond/ust-consumer.c for the > second call site). > > You see a better way of doing it ? After discussing over phone, we will nest the registry lock inside the socket lock. Thanks, Mathieu > > David > > > > > Thanks, > > > > Mathieu > > -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From jeremie.galarneau at efficios.com Tue Mar 26 23:23:03 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Tue, 26 Mar 2013 23:23:03 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Fix: Run tests requiring the python bindings only when they are enabled In-Reply-To: References: Message-ID: <1364354583-27701-1-git-send-email-jeremie.galarneau@efficios.com> Signed-off-by: J?r?mie Galarneau --- tests/Makefile.am | 7 +++++++ tests/fast_regression | 5 ----- tests/long_regression | 5 ----- tests/with_bindings_regression | 5 +++++ 4 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 tests/with_bindings_regression diff --git a/tests/Makefile.am b/tests/Makefile.am index a95afa7..5feaca2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,12 @@ SUBDIRS = utils regression unit +if USE_PYTHON check-am: ./run.sh unit_tests ./run.sh fast_regression + ./run.sh with_bindings_regression +else +check-am: + ./run.sh unit_tests + ./run.sh fast_regression +endif diff --git a/tests/fast_regression b/tests/fast_regression index 175bb03..fb4ac60 100644 --- a/tests/fast_regression +++ b/tests/fast_regression @@ -12,8 +12,3 @@ regression/ust/nprocesses/test_nprocesses regression/ust/overlap/test_overlap regression/ust/test_event_basic regression/ust/test_event_wildcard -regression/ust/linking/test_linking -regression/ust/daemon/test_daemon -regression/ust/exit-fast/test_exit-fast -regression/ust/fork/test_fork -regression/ust/libc-wrapper/test_libc-wrapper diff --git a/tests/long_regression b/tests/long_regression index 8b1cbfc..c198178 100644 --- a/tests/long_regression +++ b/tests/long_regression @@ -14,8 +14,3 @@ regression/ust/nprocesses/test_nprocesses regression/ust/overlap/test_overlap regression/ust/test_event_basic regression/ust/test_event_wildcard -regression/ust/linking/test_linking -regression/ust/daemon/test_daemon -regression/ust/exit-fast/test_exit-fast -regression/ust/fork/test_fork -regression/ust/libc-wrapper/test_libc-wrapper diff --git a/tests/with_bindings_regression b/tests/with_bindings_regression new file mode 100644 index 0000000..5cb1903 --- /dev/null +++ b/tests/with_bindings_regression @@ -0,0 +1,5 @@ +regression/ust/linking/test_linking +regression/ust/daemon/test_daemon +regression/ust/exit-fast/test_exit-fast +regression/ust/fork/test_fork +regression/ust/libc-wrapper/test_libc-wrapper -- 1.8.2 From jeremie.galarneau at efficios.com Wed Mar 27 00:37:39 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Wed, 27 Mar 2013 00:37:39 -0400 Subject: [lttng-dev] [PATCH lttng-ust] Fix: Remove test runner script In-Reply-To: References: Message-ID: <1364359059-15307-1-git-send-email-jeremie.galarneau@efficios.com> Deprecated by the use of Perl prove and test lists. Signed-off-by: J?r?mie Galarneau --- tests/Makefile.am | 2 +- tests/README | 4 ++-- tests/runtests | 36 ------------------------------------ tests/test_loop | 2 +- 4 files changed, 4 insertions(+), 40 deletions(-) delete mode 100755 tests/runtests diff --git a/tests/Makefile.am b/tests/Makefile.am index 6f9b969..425440a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,7 +4,7 @@ if CXX_WORKS SUBDIRS += hello.cxx endif -dist_noinst_SCRIPTS = test_loop runtests trace_matches +dist_noinst_SCRIPTS = test_loop run.sh trace_matches unit_tests noinst_LIBRARIES = libtap.a diff --git a/tests/README b/tests/README index 1c920eb..5f1da32 100644 --- a/tests/README +++ b/tests/README @@ -1,8 +1,8 @@ Using the ust test suite. Running - ./runtests -runs all the tests once. The output is in TAP format. + ./run.sh unit_tests +runs all the tests once. Running ./test_loop diff --git a/tests/runtests b/tests/runtests deleted file mode 100755 index 8f5c874..0000000 --- a/tests/runtests +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Copyright 2010 Ericsson AB -# -# This file is part of LTTng-UST. -# -# LTTng-UST is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# LTTng-UST is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with LTTng-UST. If not, see . - - -tests_failed=0 - -TESTDIR=$(dirname $0) - -function simple_harness_run() { - if ! "$TESTDIR/$@"; then - let tests_failed=$tests_failed+1 - fi -} - -./${TEST_DIR}/snprintf/run - -# This testcase is currently broken, do not run. -# simple_harness_run tracepoint/run - -exit 0 diff --git a/tests/test_loop b/tests/test_loop index 619b1e3..be3e16c 100755 --- a/tests/test_loop +++ b/tests/test_loop @@ -3,7 +3,7 @@ DIR=$(dirname $0) while [ 0 ]; do - $DIR/runtests + $DIR/run.sh $DIR/unit_tests if [ "$?" != "0" ]; then break; fi -- 1.8.2 From jeremie.galarneau at efficios.com Wed Mar 27 01:38:35 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Wed, 27 Mar 2013 01:38:35 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Fix: Add test scripts and lists to the distribution package Message-ID: <1364362715-14459-1-git-send-email-jeremie.galarneau@efficios.com> Signed-off-by: J?r?mie Galarneau --- tests/Makefile.am | 3 +++ tests/regression/tools/health/Makefile.am | 3 +++ tests/utils/Makefile.am | 3 ++- tests/utils/tap/Makefile.am | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 5feaca2..c8a85e0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,3 +10,6 @@ check-am: ./run.sh unit_tests ./run.sh fast_regression endif + +dist_noinst_SCRIPTS = run.sh unit_tests fast_regression long_regression root_regression with_bindings_regression +EXTRA_DIST = run.sh unit_tests fast_regression long_regression root_regression with_bindings_regression diff --git a/tests/regression/tools/health/Makefile.am b/tests/regression/tools/health/Makefile.am index 94e54df..098fbf4 100644 --- a/tests/regression/tools/health/Makefile.am +++ b/tests/regression/tools/health/Makefile.am @@ -36,3 +36,6 @@ health_check_SOURCES = health_check.c $(UTILS) health_check_LDADD = $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la \ $(top_builddir)/src/common/libcommon.la endif + +dist_noinst_SCRIPTS = test_thread_exit test_thread_stall test_tp_fail +EXTRA_DIST = test_thread_exit test_thread_stall test_tp_fail diff --git a/tests/utils/Makefile.am b/tests/utils/Makefile.am index 4325846..1b362fc 100644 --- a/tests/utils/Makefile.am +++ b/tests/utils/Makefile.am @@ -1,3 +1,4 @@ SUBDIRS = tap -EXTRA_DIST = utils.sh utils.h +EXTRA_DIST = utils.sh utils.h test_utils.py +dist_noinst_SCRIPTS = utils.sh utils.h test_utils.py diff --git a/tests/utils/tap/Makefile.am b/tests/utils/tap/Makefile.am index 366f4c4..14cd234 100644 --- a/tests/utils/tap/Makefile.am +++ b/tests/utils/tap/Makefile.am @@ -1,2 +1,4 @@ lib_LTLIBRARIES = libtap.la libtap_la_SOURCES = tap.c tap.h +dist_noinst_SCRIPTS = tap.sh +EXTRA_DIST = tap.sh -- 1.8.2 From David.OShea at quantum.com Wed Mar 27 06:02:52 2013 From: David.OShea at quantum.com (David OShea) Date: Wed, 27 Mar 2013 10:02:52 +0000 Subject: [lttng-dev] LTTng-UST memory requirements Message-ID: <20998D40D9A2B7499CA5A3A2666CB1EB23FCE56C@ZURMSG1.QUANTUM.com> Hi all, Are any details available of the memory requirements for LTTng? I'm particularly interested in UST, and not only the case where tracing is being performed, but also when no session is started. For example.: - Session daemon memory requirements: I assume this would be a function of the number of tracepoints, trace providers, attached processes, sessions, etc. - Consumer daemon memory requirements: how many of these would there be, how much memory does each use - In-application memory requirements: I assume this would also be a function of the number of trace providers, trace points, etc. Thanks in advance, David ---------------------------------------------------------------------- The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt. From Paul_Woegerer at mentor.com Wed Mar 27 09:53:17 2013 From: Paul_Woegerer at mentor.com (Woegerer, Paul) Date: Wed, 27 Mar 2013 14:53:17 +0100 Subject: [lttng-dev] [lttng-ust PATCH] Fix: forwarding of call_site argument to field Message-ID: <5152F9CD.5040809@mentor.com> I ran some tests with the new function entry/exit instrumentations. The tracepoint provider for lttng_ust_cyg_profile:func_entry and func_exit does not properly forward the call_site argument to the call_site field. The patch below fixes the problem. >From c2891f8d78922170175d05a03253dcd418182868 Mon Sep 17 00:00:00 2001 From: Paul Woegerer Date: Wed, 27 Mar 2013 14:34:35 +0100 Subject: [PATCH] Fix forwarding of call_site argument to field --- liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h index 7629fb9..2e6dda8 100644 --- a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h +++ b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h @@ -36,7 +36,7 @@ TRACEPOINT_EVENT(lttng_ust_cyg_profile, func_entry, TP_ARGS(void *, func_addr, void *, call_site), TP_FIELDS( ctf_integer_hex(void *, addr, func_addr) - ctf_integer_hex(void *, call_site, func_addr) + ctf_integer_hex(void *, call_site, call_site) ) ) @@ -47,7 +47,7 @@ TRACEPOINT_EVENT(lttng_ust_cyg_profile, func_exit, TP_ARGS(void *, func_addr, void *, call_site), TP_FIELDS( ctf_integer_hex(void *, addr, func_addr) - ctf_integer_hex(void *, call_site, func_addr) + ctf_integer_hex(void *, call_site, call_site) ) ) -- 1.7.10.4 -- Paul Woegerer | SW Development Engineer http://go.mentor.com/sourceryanalyzer Mentor Embedded(tm) | Prinz Eugen Stra?e 72/2/4, Vienna, 1040 Austria Nucleus? | Linux? | Android(tm) | Services | UI | Multi-OS Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. From mathieu.desnoyers at efficios.com Wed Mar 27 10:17:48 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 27 Mar 2013 10:17:48 -0400 Subject: [lttng-dev] [lttng-ust PATCH] Fix: forwarding of call_site argument to field In-Reply-To: <5152F9CD.5040809@mentor.com> References: <5152F9CD.5040809@mentor.com> Message-ID: <20130327141748.GE6283@Krystal> merged, thanks! Mathieu * Woegerer, Paul (Paul_Woegerer at mentor.com) wrote: > I ran some tests with the new function entry/exit instrumentations. > > The tracepoint provider for lttng_ust_cyg_profile:func_entry and > func_exit does not properly forward the call_site argument to the > call_site field. The patch below fixes the problem. > > > From c2891f8d78922170175d05a03253dcd418182868 Mon Sep 17 00:00:00 2001 > From: Paul Woegerer > Date: Wed, 27 Mar 2013 14:34:35 +0100 > Subject: [PATCH] Fix forwarding of call_site argument to field > > --- > liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h > index 7629fb9..2e6dda8 100644 > --- a/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h > +++ b/liblttng-ust-cyg-profile/lttng-ust-cyg-profile.h > @@ -36,7 +36,7 @@ TRACEPOINT_EVENT(lttng_ust_cyg_profile, func_entry, > TP_ARGS(void *, func_addr, void *, call_site), > TP_FIELDS( > ctf_integer_hex(void *, addr, func_addr) > - ctf_integer_hex(void *, call_site, func_addr) > + ctf_integer_hex(void *, call_site, call_site) > ) > ) > > @@ -47,7 +47,7 @@ TRACEPOINT_EVENT(lttng_ust_cyg_profile, func_exit, > TP_ARGS(void *, func_addr, void *, call_site), > TP_FIELDS( > ctf_integer_hex(void *, addr, func_addr) > - ctf_integer_hex(void *, call_site, func_addr) > + ctf_integer_hex(void *, call_site, call_site) > ) > ) > > -- > 1.7.10.4 > > -- > Paul Woegerer | SW Development Engineer > http://go.mentor.com/sourceryanalyzer > > Mentor Embedded(tm) | Prinz Eugen Stra?e 72/2/4, Vienna, 1040 Austria > Nucleus? | Linux? | Android(tm) | Services | UI | Multi-OS > > Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions. > Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From mathieu.desnoyers at efficios.com Wed Mar 27 10:19:29 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 27 Mar 2013 10:19:29 -0400 Subject: [lttng-dev] [PATCH lttng-ust] Fix: Remove test runner script In-Reply-To: <1364359059-15307-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364359059-15307-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <20130327141929.GF6283@Krystal> * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: > Deprecated by the use of Perl prove and test lists. merged, thanks! Mathieu > > Signed-off-by: J?r?mie Galarneau > --- > tests/Makefile.am | 2 +- > tests/README | 4 ++-- > tests/runtests | 36 ------------------------------------ > tests/test_loop | 2 +- > 4 files changed, 4 insertions(+), 40 deletions(-) > delete mode 100755 tests/runtests > > diff --git a/tests/Makefile.am b/tests/Makefile.am > index 6f9b969..425440a 100644 > --- a/tests/Makefile.am > +++ b/tests/Makefile.am > @@ -4,7 +4,7 @@ if CXX_WORKS > SUBDIRS += hello.cxx > endif > > -dist_noinst_SCRIPTS = test_loop runtests trace_matches > +dist_noinst_SCRIPTS = test_loop run.sh trace_matches unit_tests > > noinst_LIBRARIES = libtap.a > > diff --git a/tests/README b/tests/README > index 1c920eb..5f1da32 100644 > --- a/tests/README > +++ b/tests/README > @@ -1,8 +1,8 @@ > Using the ust test suite. > > Running > - ./runtests > -runs all the tests once. The output is in TAP format. > + ./run.sh unit_tests > +runs all the tests once. > > Running > ./test_loop > diff --git a/tests/runtests b/tests/runtests > deleted file mode 100755 > index 8f5c874..0000000 > --- a/tests/runtests > +++ /dev/null > @@ -1,36 +0,0 @@ > -#!/bin/bash > -# > -# Copyright 2010 Ericsson AB > -# > -# This file is part of LTTng-UST. > -# > -# LTTng-UST is free software: you can redistribute it and/or modify > -# it under the terms of the GNU General Public License as published by > -# the Free Software Foundation, either version 2 of the License, or > -# (at your option) any later version. > -# > -# LTTng-UST is distributed in the hope that it will be useful, > -# but WITHOUT ANY WARRANTY; without even the implied warranty of > -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > -# GNU General Public License for more details. > -# > -# You should have received a copy of the GNU General Public License > -# along with LTTng-UST. If not, see . > - > - > -tests_failed=0 > - > -TESTDIR=$(dirname $0) > - > -function simple_harness_run() { > - if ! "$TESTDIR/$@"; then > - let tests_failed=$tests_failed+1 > - fi > -} > - > -./${TEST_DIR}/snprintf/run > - > -# This testcase is currently broken, do not run. > -# simple_harness_run tracepoint/run > - > -exit 0 > diff --git a/tests/test_loop b/tests/test_loop > index 619b1e3..be3e16c 100755 > --- a/tests/test_loop > +++ b/tests/test_loop > @@ -3,7 +3,7 @@ > DIR=$(dirname $0) > > while [ 0 ]; do > - $DIR/runtests > + $DIR/run.sh $DIR/unit_tests > if [ "$?" != "0" ]; then > break; > fi > -- > 1.8.2 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From dgoulet at efficios.com Wed Mar 27 10:38:47 2013 From: dgoulet at efficios.com (David Goulet) Date: Wed, 27 Mar 2013 10:38:47 -0400 Subject: [lttng-dev] [PATCH lttng-tools 1/7] Tests: Add Python test_utils module In-Reply-To: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364257716-5739-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <51530477.4060309@efficios.com> Merged! Thanks! J?r?mie Galarneau: > Basic Python test framework based on the lttng-tools Python bindings > that facilitates the creation of a tracing session saving its trace in > a temporary location, the activation of events in the UST domain and > clean teardown of the test session. > > Also provides basic TAP output facilities. > > Signed-off-by: J?r?mie Galarneau > --- > tests/utils/test_utils.py | 111 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 111 insertions(+) > create mode 100644 tests/utils/test_utils.py > > diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py > new file mode 100644 > index 0000000..5e00de4 > --- /dev/null > +++ b/tests/utils/test_utils.py > @@ -0,0 +1,111 @@ > +#!/usr/bin/env python3 > +# > +# Copyright (C) - 2013 J?r?mie Galarneau > +# > +# This program is free software; you can redistribute it and/or modify it > +# under the terms of the GNU General Public License, version 2 only, as > +# published by the Free Software Foundation. > +# > +# This program is distributed in the hope that it will be useful, but WITHOUT > +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for > +# more details. > +# > +# You should have received a copy of the GNU General Public License along with > +# this program; if not, write to the Free Software Foundation, Inc., 51 > +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > + > +import uuid > +import os > +import subprocess > +import shutil > +import sys > +import tempfile > + > +# Import lttng bindings generated in the current tree > +lttng_bindings_path = os.path.dirname(os.path.abspath(__file__)) + "/" > +for i in range(3): > + lttng_bindings_path = os.path.dirname(lttng_bindings_path) > +lttng_bindings_path = lttng_bindings_path + "/extras/bindings/swig/python" > +lttng_bindings_libs_path = lttng_bindings_path + "/.libs" > +sys.path.append(lttng_bindings_path) > +sys.path.append(lttng_bindings_libs_path) > +from lttng import * > + > + > +class SessionInfo: > + def __init__(self, handle, session_name, tmp_directory, channel_name): > + self.handle = handle > + self.name = session_name > + self.tmp_directory = tmp_directory > + self.trace_path = tmp_directory + "/" + session_name > + self.channel_name = channel_name > + > +def bail(diag, session_info = None): > + print("Bail out!") > + print("#", diag) > + > + if session_info is not None: > + stop_session(session_info, True) > + > + if os.path.exists(session_info.trace_path): > + shutil.rmtree(session_info.trace_path) > + exit(-1) > + > +def print_test_result(result, number, description): > + result_string = None > + if result is True: > + result_string = "ok" > + else: > + result_string = "not ok" > + > + result_string += " {0} - {1}".format(number, description) > + print(result_string) > + > +def enable_ust_tracepoint_event(session_info, event_name): > + event = Event() > + event.name = event_name > + event.type = EVENT_TRACEPOINT > + event.loglevel = EVENT_LOGLEVEL_ALL > + res = enable_event(session_info.handle, event, session_info.channel_name) > + if res < 0: > + bail("Failed to enable userspace event " + event_name, session_info) > + > +def create_session(): > + dom = Domain() > + dom.type = DOMAIN_UST > + > + session_name = str(uuid.uuid1()) > + tmp_directory = tempfile.mkdtemp() > + trace_path = tmp_directory + "/" + session_name > + > + res = create(session_name, trace_path) > + if res < 0: > + bail("Failed to create tracing session.") > + > + channel = Channel() > + channel.name = "channel0" > + channel_set_default_attr(dom, channel.attr) > + > + han = Handle(session_name, dom) > + res = enable_channel(han, channel) > + > + session_info = SessionInfo(han, session_name, tmp_directory, channel.name) > + if res < 0: > + bail("Failed to enable channel " + channel.name, session_info) > + return session_info > + > +def start_session(session_info): > + start(session_info.name) > + > +def stop_session(session_info, bailing = False): > + # Workaround lttng-ctl outputing directly to stdout by spawning a subprocess. > + lttng_binary_path = os.path.dirname(os.path.abspath(__file__)) + "/" > + for i in range(3): > + lttng_binary_path = os.path.dirname(lttng_binary_path) > + lttng_binary_path = lttng_binary_path + "/src/bin/lttng/lttng" > + > + retcode = subprocess.call([lttng_binary_path, "stop", session_info.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) > + if retcode != 0 and not bailing: > + bail("Unable to stop session " + session_info.name, session_info) > + destroy(session_info.name) From dgoulet at efficios.com Wed Mar 27 10:38:53 2013 From: dgoulet at efficios.com (David Goulet) Date: Wed, 27 Mar 2013 10:38:53 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Fix: Run tests requiring the python bindings only when they are enabled In-Reply-To: <1364354583-27701-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364354583-27701-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <5153047D.3000307@efficios.com> Merged! J?r?mie Galarneau: > Signed-off-by: J?r?mie Galarneau > --- > tests/Makefile.am | 7 +++++++ > tests/fast_regression | 5 ----- > tests/long_regression | 5 ----- > tests/with_bindings_regression | 5 +++++ > 4 files changed, 12 insertions(+), 10 deletions(-) > create mode 100644 tests/with_bindings_regression > > diff --git a/tests/Makefile.am b/tests/Makefile.am > index a95afa7..5feaca2 100644 > --- a/tests/Makefile.am > +++ b/tests/Makefile.am > @@ -1,5 +1,12 @@ > SUBDIRS = utils regression unit > > +if USE_PYTHON > check-am: > ./run.sh unit_tests > ./run.sh fast_regression > + ./run.sh with_bindings_regression > +else > +check-am: > + ./run.sh unit_tests > + ./run.sh fast_regression > +endif > diff --git a/tests/fast_regression b/tests/fast_regression > index 175bb03..fb4ac60 100644 > --- a/tests/fast_regression > +++ b/tests/fast_regression > @@ -12,8 +12,3 @@ regression/ust/nprocesses/test_nprocesses > regression/ust/overlap/test_overlap > regression/ust/test_event_basic > regression/ust/test_event_wildcard > -regression/ust/linking/test_linking > -regression/ust/daemon/test_daemon > -regression/ust/exit-fast/test_exit-fast > -regression/ust/fork/test_fork > -regression/ust/libc-wrapper/test_libc-wrapper > diff --git a/tests/long_regression b/tests/long_regression > index 8b1cbfc..c198178 100644 > --- a/tests/long_regression > +++ b/tests/long_regression > @@ -14,8 +14,3 @@ regression/ust/nprocesses/test_nprocesses > regression/ust/overlap/test_overlap > regression/ust/test_event_basic > regression/ust/test_event_wildcard > -regression/ust/linking/test_linking > -regression/ust/daemon/test_daemon > -regression/ust/exit-fast/test_exit-fast > -regression/ust/fork/test_fork > -regression/ust/libc-wrapper/test_libc-wrapper > diff --git a/tests/with_bindings_regression b/tests/with_bindings_regression > new file mode 100644 > index 0000000..5cb1903 > --- /dev/null > +++ b/tests/with_bindings_regression > @@ -0,0 +1,5 @@ > +regression/ust/linking/test_linking > +regression/ust/daemon/test_daemon > +regression/ust/exit-fast/test_exit-fast > +regression/ust/fork/test_fork > +regression/ust/libc-wrapper/test_libc-wrapper From dgoulet at efficios.com Wed Mar 27 10:39:00 2013 From: dgoulet at efficios.com (David Goulet) Date: Wed, 27 Mar 2013 10:39:00 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Fix: Add test scripts and lists to the distribution package In-Reply-To: <1364362715-14459-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364362715-14459-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <51530484.20700@efficios.com> Merged! J?r?mie Galarneau: > Signed-off-by: J?r?mie Galarneau > --- > tests/Makefile.am | 3 +++ > tests/regression/tools/health/Makefile.am | 3 +++ > tests/utils/Makefile.am | 3 ++- > tests/utils/tap/Makefile.am | 2 ++ > 4 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/tests/Makefile.am b/tests/Makefile.am > index 5feaca2..c8a85e0 100644 > --- a/tests/Makefile.am > +++ b/tests/Makefile.am > @@ -10,3 +10,6 @@ check-am: > ./run.sh unit_tests > ./run.sh fast_regression > endif > + > +dist_noinst_SCRIPTS = run.sh unit_tests fast_regression long_regression root_regression with_bindings_regression > +EXTRA_DIST = run.sh unit_tests fast_regression long_regression root_regression with_bindings_regression > diff --git a/tests/regression/tools/health/Makefile.am b/tests/regression/tools/health/Makefile.am > index 94e54df..098fbf4 100644 > --- a/tests/regression/tools/health/Makefile.am > +++ b/tests/regression/tools/health/Makefile.am > @@ -36,3 +36,6 @@ health_check_SOURCES = health_check.c $(UTILS) > health_check_LDADD = $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la \ > $(top_builddir)/src/common/libcommon.la > endif > + > +dist_noinst_SCRIPTS = test_thread_exit test_thread_stall test_tp_fail > +EXTRA_DIST = test_thread_exit test_thread_stall test_tp_fail > diff --git a/tests/utils/Makefile.am b/tests/utils/Makefile.am > index 4325846..1b362fc 100644 > --- a/tests/utils/Makefile.am > +++ b/tests/utils/Makefile.am > @@ -1,3 +1,4 @@ > SUBDIRS = tap > > -EXTRA_DIST = utils.sh utils.h > +EXTRA_DIST = utils.sh utils.h test_utils.py > +dist_noinst_SCRIPTS = utils.sh utils.h test_utils.py > diff --git a/tests/utils/tap/Makefile.am b/tests/utils/tap/Makefile.am > index 366f4c4..14cd234 100644 > --- a/tests/utils/tap/Makefile.am > +++ b/tests/utils/tap/Makefile.am > @@ -1,2 +1,4 @@ > lib_LTLIBRARIES = libtap.la > libtap_la_SOURCES = tap.c tap.h > +dist_noinst_SCRIPTS = tap.sh > +EXTRA_DIST = tap.sh From Paul_Woegerer at mentor.com Wed Mar 27 12:14:56 2013 From: Paul_Woegerer at mentor.com (Woegerer, Paul) Date: Wed, 27 Mar 2013 17:14:56 +0100 Subject: [lttng-dev] [lttng-ust PATCH] Add man page for lttng-ust-cyg-profile Message-ID: <51531B00.1030302@mentor.com> As promised... >From acba8cd14abc7e61cf1346b5649972bac3ea0d53 Mon Sep 17 00:00:00 2001 From: Paul Woegerer Date: Wed, 27 Mar 2013 17:02:27 +0100 Subject: [PATCH] Add man page for lttng-ust-cyg-profile --- doc/Makefile.am | 3 +- doc/man/lttng-ust-cyg-profile.3 | 79 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 doc/man/lttng-ust-cyg-profile.3 diff --git a/doc/Makefile.am b/doc/Makefile.am index 66c22fa..ccd6d18 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,4 +1,5 @@ SUBDIRS = . examples dist_man_MANS = man/lttng-gen-tp.1 \ - man/lttng-ust.3 + man/lttng-ust.3 \ + man/lttng-ust-cyg-profile.3 diff --git a/doc/man/lttng-ust-cyg-profile.3 b/doc/man/lttng-ust-cyg-profile.3 new file mode 100644 index 0000000..58dbce8 --- /dev/null +++ b/doc/man/lttng-ust-cyg-profile.3 @@ -0,0 +1,79 @@ +.TH "LTTNG-UST-CYG-PROFILE" "1" "March 26, 2013" "" "" +.SH "NAME" +lttng-ust-cyg-profile \(em LTTng UST 2.0 Function Tracing +.SH "SYNOPSIS" +Compile the application source code with option \fB-finstrument-functions\fP +and launch your application either with: +.TP +\fBLD_PRELOAD=liblttng-ust-cyg-profile-fast.so\fP appname +.PP +or (to use verbose function tracing) +.TP +\fBLD_PRELOAD=liblttng-ust-cyg-profile.so\fP appname +.PP +All events emitted for function tracing are provided on loglevel +TRACE_DEBUG_FUNCTION. The following command can be used to add +function tracing events in your trace session: +.TP +.B lttng enable-event -u -a --loglevel-only TRACE_DEBUG_FUNCTION +.SH "DESCRIPTION" +For compilers that provide code generation option +\fB-finstrument-functions\fP (e.g. GCC and LLVM/Clang) LTTng-UST provides +shared libraries that allow users to trace the function flow of their +applications. + +Function tracing comes in two flavors (each providing different trade-offs): +.IP liblttng-ust-cyg-profile-fast.so +This is a lightweight variant that should only be used where it can be +guaranteed that the complete event stream is recorded without any missing +events. Any kind of duplicate information is left out. + +At each function entry the address of the called function is recored as +lttng_ust_cyg_profile_fast:func_entry. Function exit is recorded as +lttng_ust_cyg_profile_fast:func_exit (without any field data). + +.IP liblttng-ust-cyg-profile.so +This is a more robust variant which also works for use-cases where events +might get discarded or not recorded from application startup. In these cases +the trace analyzer needs extra information to be able to reconstruct the +program flow. + +For each function entry and exit the address of the called function and the +call site address are recorded as lttng_ust_cyg_profile:func_entry and +lttng_ust_cyg_profile:func_exit. +.SH "USAGE" +To use function tracing you need to make sure the sources of your application +are compiled with -finstrument-functions. It might be necessary to limit +the number of source files where this option is used to prevent excessive +amount of trace data to be generated during run time. Usually there are +additional compiler flags that allow you to specify more fine grained selection +of function instrumentation. + +For each instrumented function the executable will contain calls to profiling +function hooks (after function entry and just before function exit). + +By preloading (LD_PRELOAD) one of the provided shared libraries, these +profiling hooks get defined to emit LTTng events (as described above). + +Using this feature can result in massive amount trace data to be generated +by the instrumented application. Application runtime is also considerably +affected. Be careful on systems with limited resources. +.SH "SEE ALSO" +lttng-ust(3), lttng(1), gcc(1), ld.so(8) +.SH "BUGS" +If you encounter any issues or usability problem, please report it on +our mailing list to help improve this +project. +.SH "CREDITS" +liblttng-ust is distributed under the GNU Lesser General Public License +version 2.1. The headers are distributed under the MIT license. + +See http://lttng.org for more information on the LTTng project. + +Mailing list for support and development: . + +You can find us on IRC server irc.oftc.net (OFTC) in #lttng. +.SH "AUTHORS" +liblttng-ust was originally written by Mathieu Desnoyers, with additional +contributions from various other people. It is currently maintained by +Mathieu Desnoyers . -- 1.7.10.4 -- Paul Woegerer | SW Development Engineer http://go.mentor.com/sourceryanalyzer Mentor Embedded(tm) | Prinz Eugen Stra?e 72/2/4, Vienna, 1040 Austria Nucleus? | Linux? | Android(tm) | Services | UI | Multi-OS Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. From mathieu.desnoyers at efficios.com Wed Mar 27 12:26:19 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 27 Mar 2013 12:26:19 -0400 Subject: [lttng-dev] [lttng-ust PATCH] Add man page for lttng-ust-cyg-profile In-Reply-To: <51531B00.1030302@mentor.com> References: <51531B00.1030302@mentor.com> Message-ID: <20130327162619.GA8823@Krystal> * Woegerer, Paul (Paul_Woegerer at mentor.com) wrote: > As promised... merged, with minor edits, thanks! Mathieu > > From acba8cd14abc7e61cf1346b5649972bac3ea0d53 Mon Sep 17 00:00:00 2001 > From: Paul Woegerer > Date: Wed, 27 Mar 2013 17:02:27 +0100 > Subject: [PATCH] Add man page for lttng-ust-cyg-profile > > --- > doc/Makefile.am | 3 +- > doc/man/lttng-ust-cyg-profile.3 | 79 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 81 insertions(+), 1 deletion(-) > create mode 100644 doc/man/lttng-ust-cyg-profile.3 > > diff --git a/doc/Makefile.am b/doc/Makefile.am > index 66c22fa..ccd6d18 100644 > --- a/doc/Makefile.am > +++ b/doc/Makefile.am > @@ -1,4 +1,5 @@ > SUBDIRS = . examples > > dist_man_MANS = man/lttng-gen-tp.1 \ > - man/lttng-ust.3 > + man/lttng-ust.3 \ > + man/lttng-ust-cyg-profile.3 > diff --git a/doc/man/lttng-ust-cyg-profile.3 b/doc/man/lttng-ust-cyg-profile.3 > new file mode 100644 > index 0000000..58dbce8 > --- /dev/null > +++ b/doc/man/lttng-ust-cyg-profile.3 > @@ -0,0 +1,79 @@ > +.TH "LTTNG-UST-CYG-PROFILE" "1" "March 26, 2013" "" "" > +.SH "NAME" > +lttng-ust-cyg-profile \(em LTTng UST 2.0 Function Tracing > +.SH "SYNOPSIS" > +Compile the application source code with option \fB-finstrument-functions\fP > +and launch your application either with: > +.TP > +\fBLD_PRELOAD=liblttng-ust-cyg-profile-fast.so\fP appname > +.PP > +or (to use verbose function tracing) > +.TP > +\fBLD_PRELOAD=liblttng-ust-cyg-profile.so\fP appname > +.PP > +All events emitted for function tracing are provided on loglevel > +TRACE_DEBUG_FUNCTION. The following command can be used to add > +function tracing events in your trace session: > +.TP > +.B lttng enable-event -u -a --loglevel-only TRACE_DEBUG_FUNCTION > +.SH "DESCRIPTION" > +For compilers that provide code generation option > +\fB-finstrument-functions\fP (e.g. GCC and LLVM/Clang) LTTng-UST provides > +shared libraries that allow users to trace the function flow of their > +applications. > + > +Function tracing comes in two flavors (each providing different trade-offs): > +.IP liblttng-ust-cyg-profile-fast.so > +This is a lightweight variant that should only be used where it can be > +guaranteed that the complete event stream is recorded without any missing > +events. Any kind of duplicate information is left out. > + > +At each function entry the address of the called function is recored as > +lttng_ust_cyg_profile_fast:func_entry. Function exit is recorded as > +lttng_ust_cyg_profile_fast:func_exit (without any field data). > + > +.IP liblttng-ust-cyg-profile.so > +This is a more robust variant which also works for use-cases where events > +might get discarded or not recorded from application startup. In these cases > +the trace analyzer needs extra information to be able to reconstruct the > +program flow. > + > +For each function entry and exit the address of the called function and the > +call site address are recorded as lttng_ust_cyg_profile:func_entry and > +lttng_ust_cyg_profile:func_exit. > +.SH "USAGE" > +To use function tracing you need to make sure the sources of your application > +are compiled with -finstrument-functions. It might be necessary to limit > +the number of source files where this option is used to prevent excessive > +amount of trace data to be generated during run time. Usually there are > +additional compiler flags that allow you to specify more fine grained selection > +of function instrumentation. > + > +For each instrumented function the executable will contain calls to profiling > +function hooks (after function entry and just before function exit). > + > +By preloading (LD_PRELOAD) one of the provided shared libraries, these > +profiling hooks get defined to emit LTTng events (as described above). > + > +Using this feature can result in massive amount trace data to be generated > +by the instrumented application. Application runtime is also considerably > +affected. Be careful on systems with limited resources. > +.SH "SEE ALSO" > +lttng-ust(3), lttng(1), gcc(1), ld.so(8) > +.SH "BUGS" > +If you encounter any issues or usability problem, please report it on > +our mailing list to help improve this > +project. > +.SH "CREDITS" > +liblttng-ust is distributed under the GNU Lesser General Public License > +version 2.1. The headers are distributed under the MIT license. > + > +See http://lttng.org for more information on the LTTng project. > + > +Mailing list for support and development: . > + > +You can find us on IRC server irc.oftc.net (OFTC) in #lttng. > +.SH "AUTHORS" > +liblttng-ust was originally written by Mathieu Desnoyers, with additional > +contributions from various other people. It is currently maintained by > +Mathieu Desnoyers . > -- > 1.7.10.4 > > > -- > Paul Woegerer | SW Development Engineer > http://go.mentor.com/sourceryanalyzer > > Mentor Embedded(tm) | Prinz Eugen Stra?e 72/2/4, Vienna, 1040 Austria > Nucleus? | Linux? | Android(tm) | Services | UI | Multi-OS > > Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions. > Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From dgoulet at efficios.com Wed Mar 27 14:45:38 2013 From: dgoulet at efficios.com (David Goulet) Date: Wed, 27 Mar 2013 14:45:38 -0400 Subject: [lttng-dev] [PATCH lttng-tools] On-disk multiple tracefiles circular buffer Message-ID: <1364409938-26174-1-git-send-email-dgoulet@efficios.com> From: Julien Desfossez This patch introduces the tracefile_size and tracefile_count parameters to the enable-channel command and the API. This allows to split a stream into multiple tracefiles and limit the amount of trace data to keep on disk. The tracefiles are readable independently or with the others as long as the metadata file is present. For now only local traces are handled, relayd modifications coming soon. Signed-off-by: Julien Desfossez Signed-off-by: David Goulet --- doc/man/lttng.1 | 5 ++ include/lttng/lttng.h | 5 +- src/bin/lttng-sessiond/channel.c | 10 +++ src/bin/lttng-sessiond/consumer.c | 12 ++- src/bin/lttng-sessiond/consumer.h | 8 +- src/bin/lttng-sessiond/kernel-consumer.c | 9 +- src/bin/lttng-sessiond/kernel.c | 3 + src/bin/lttng-sessiond/trace-kernel.h | 2 + src/bin/lttng-sessiond/trace-ust.c | 4 + src/bin/lttng-sessiond/trace-ust.h | 2 + src/bin/lttng-sessiond/ust-app.c | 3 + src/bin/lttng-sessiond/ust-app.h | 2 + src/bin/lttng-sessiond/ust-consumer.c | 4 +- src/bin/lttng/commands/enable_channels.c | 33 +++++++ src/common/consumer.c | 123 +++++++++++++++++++++++++- src/common/consumer.h | 11 ++- src/common/defaults.h | 8 ++ src/common/kernel-consumer/kernel-consumer.c | 21 ++--- src/common/sessiond-comm/sessiond-comm.h | 4 + src/common/ust-consumer/ust-consumer.c | 39 ++------ src/lib/lttng-ctl/lttng-ctl.c | 4 + 21 files changed, 253 insertions(+), 59 deletions(-) diff --git a/doc/man/lttng.1 b/doc/man/lttng.1 index 0a548f8..891e106 100644 --- a/doc/man/lttng.1 +++ b/doc/man/lttng.1 @@ -345,6 +345,11 @@ same type. Use per PID buffer (\-u only). Each application has its own buffers. \-\-buffers-global Use shared buffer for the whole system (\-k only) +\-C, \-\-tracefile-size SIZE + Maximum size of tracefiles per stream (in bytes) +\-W, \-\-tracefile-count COUNT + Number of tracefiles per stream + .fi .IP diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index 8566dea..9fa5844 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -277,7 +277,7 @@ struct lttng_event_field { * * The structures should be initialized to zero before use. */ -#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 +#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 20 struct lttng_channel_attr { int overwrite; /* 1: overwrite, 0: discard */ uint64_t subbuf_size; /* bytes */ @@ -285,6 +285,9 @@ struct lttng_channel_attr { unsigned int switch_timer_interval; /* usec */ unsigned int read_timer_interval; /* usec */ enum lttng_event_output output; /* splice, mmap */ + /* LTTng 2.1 padding limit */ + uint64_t tracefile_size; /* bytes */ + uint32_t tracefile_count; /* number of tracefiles */ char padding[LTTNG_CHANNEL_ATTR_PADDING1]; }; diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index 6c7422b..1621bc6 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -272,6 +272,16 @@ int channel_ust_create(struct ltt_ust_session *usess, goto error; } + /* + * The tracefile_size should not be < to the subbuf_size, otherwise + * we won't be able to write the packets on disk + */ + if ((attr->attr.tracefile_size > 0) && + (attr->attr.tracefile_size < attr->attr.subbuf_size)) { + ret = LTTNG_ERR_INVALID; + goto error; + } + /* Create UST channel */ uchan = trace_ust_create_channel(attr, usess->pathname); if (uchan == NULL) { diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index f0fb2dc..c3f53be 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -663,7 +663,9 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, uint64_t relayd_id, uint64_t key, unsigned char *uuid, - uint32_t chan_id) + uint32_t chan_id, + uint64_t tracefile_size, + uint32_t tracefile_count) { assert(msg); @@ -684,6 +686,8 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.ask_channel.relayd_id = relayd_id; msg->u.ask_channel.key = key; msg->u.ask_channel.chan_id = chan_id; + msg->u.ask_channel.tracefile_size = tracefile_size; + msg->u.ask_channel.tracefile_count = tracefile_count; memcpy(msg->u.ask_channel.uuid, uuid, sizeof(msg->u.ask_channel.uuid)); @@ -709,7 +713,9 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, const char *name, unsigned int nb_init_streams, enum lttng_event_output output, - int type) + int type, + uint64_t tracefile_size, + uint32_t tracefile_count) { assert(msg); @@ -726,6 +732,8 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.channel.nb_init_streams = nb_init_streams; msg->u.channel.output = output; msg->u.channel.type = type; + msg->u.channel.tracefile_size = tracefile_size; + msg->u.channel.tracefile_count = tracefile_count; strncpy(msg->u.channel.pathname, pathname, sizeof(msg->u.channel.pathname)); diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index b767589..c2631ba 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -200,7 +200,9 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, uint64_t relayd_id, uint64_t key, unsigned char *uuid, - uint32_t chan_id); + uint32_t chan_id, + uint64_t tracefile_size, + uint32_t tracefile_count); void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg, enum lttng_consumer_command cmd, uint64_t channel_key, @@ -217,7 +219,9 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, const char *name, unsigned int nb_init_streams, enum lttng_event_output output, - int type); + int type, + uint64_t tracefile_size, + uint32_t tracefile_count); int consumer_is_data_pending(uint64_t session_id, struct consumer_output *consumer); int consumer_close_metadata(struct consumer_socket *socket, diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 3368da6..05e30e4 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -94,7 +94,9 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, channel->channel->name, channel->stream_count, channel->channel->attr.output, - CONSUMER_CHANNEL_TYPE_DATA); + CONSUMER_CHANNEL_TYPE_DATA, + channel->channel->attr.tracefile_size, + channel->channel->attr.tracefile_count); health_code_update(); @@ -174,7 +176,8 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, DEFAULT_METADATA_NAME, 1, DEFAULT_KERNEL_CHANNEL_OUTPUT, - CONSUMER_CHANNEL_TYPE_METADATA); + CONSUMER_CHANNEL_TYPE_METADATA, + 0, 0); health_code_update(); @@ -190,7 +193,7 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, LTTNG_CONSUMER_ADD_STREAM, session->metadata->fd, session->metadata_stream_fd, - 0); /* CPU: 0 for metadata. */ + 0); /* CPU: 0 for metadata. */ health_code_update(); diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index d3a6453..9519411 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -536,6 +536,9 @@ int kernel_open_channel_stream(struct ltt_kernel_channel *channel) PERROR("fcntl session fd"); } + lks->tracefile_size = channel->channel->attr.tracefile_size; + lks->tracefile_count = channel->channel->attr.tracefile_count; + /* Add stream to channe stream list */ cds_list_add(&lks->list, &channel->stream_list.head); channel->stream_count++; diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index 66ca8db..ea30827 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -82,6 +82,8 @@ struct ltt_kernel_stream { int cpu; /* Format is %s_%d respectively channel name and CPU number. */ char name[DEFAULT_STREAM_NAME_LEN]; + uint64_t tracefile_size; + uint32_t tracefile_count; struct cds_list_head list; }; diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 8f15a15..cd8ff10 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -293,6 +293,10 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, luc->events = lttng_ht_new(0, LTTNG_HT_TYPE_STRING); luc->ctx = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); + /* On-disk circular buffer parameters */ + luc->tracefile_size = chan->attr.tracefile_size; + luc->tracefile_count = chan->attr.tracefile_count; + DBG2("Trace UST channel %s created", luc->name); error: diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index 87fe412..588905a 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -59,6 +59,8 @@ struct ltt_ust_channel { struct lttng_ht *ctx; struct lttng_ht *events; struct lttng_ht_node_str node; + uint64_t tracefile_size; + uint32_t tracefile_count; }; /* UST Metadata */ diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index fdcad1c..4c9d227 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1298,6 +1298,9 @@ static void shadow_copy_channel(struct ust_app_channel *ua_chan, strncpy(ua_chan->name, uchan->name, sizeof(ua_chan->name)); ua_chan->name[sizeof(ua_chan->name) - 1] = '\0'; + ua_chan->tracefile_size = uchan->tracefile_size; + ua_chan->tracefile_count = uchan->tracefile_count; + /* Copy event attributes since the layout is different. */ ua_chan->attr.subbuf_size = uchan->attr.subbuf_size; ua_chan->attr.num_subbuf = uchan->attr.num_subbuf; diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 82694a7..b94603f 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -143,6 +143,8 @@ struct ust_app_channel { struct ust_app_session *session; struct lttng_ht *ctx; struct lttng_ht *events; + uint64_t tracefile_size; + uint32_t tracefile_count; /* * Node indexed by channel name in the channels' hash table of a session. */ diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 7f01de9..93c1f71 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -155,7 +155,9 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, consumer->net_seq_index, ua_chan->key, registry->uuid, - chan_id); + chan_id, + ua_chan->tracefile_size, + ua_chan->tracefile_count); health_code_update(); diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c index 02a3180..d303bbd 100644 --- a/src/bin/lttng/commands/enable_channels.c +++ b/src/bin/lttng/commands/enable_channels.c @@ -49,6 +49,8 @@ enum { OPT_READ_TIMER, OPT_USERSPACE, OPT_LIST_OPTIONS, + OPT_TRACEFILE_SIZE, + OPT_TRACEFILE_COUNT, }; static struct lttng_handle *handle; @@ -73,6 +75,8 @@ static struct poptOption long_options[] = { {"buffers-uid", 0, POPT_ARG_VAL, &opt_buffer_uid, 1, 0, 0}, {"buffers-pid", 0, POPT_ARG_VAL, &opt_buffer_pid, 1, 0, 0}, {"buffers-global", 0, POPT_ARG_VAL, &opt_buffer_global, 1, 0, 0}, + {"tracefile_size", 'C', POPT_ARG_INT, 0, OPT_TRACEFILE_SIZE, 0, 0}, + {"tracefile_count", 'W', POPT_ARG_INT, 0, OPT_TRACEFILE_COUNT, 0, 0}, {0, 0, 0, 0, 0, 0, 0} }; @@ -115,6 +119,10 @@ static void usage(FILE *ofp) fprintf(ofp, " --buffers-uid Use per UID buffer (-u only)\n"); fprintf(ofp, " --buffers-pid Use per PID buffer (-u only)\n"); fprintf(ofp, " --buffers-global Use shared buffer for the whole system (-k only)\n"); + fprintf(ofp, " -C, --tracefile-size SIZE\n"); + fprintf(ofp, " Maximum size of tracefiles per stream (in bytes)\n"); + fprintf(ofp, " -W, --tracefile-count COUNT\n"); + fprintf(ofp, " Number of tracefiles per stream to keep\n"); fprintf(ofp, "\n"); } @@ -147,6 +155,12 @@ static void set_default_attr(struct lttng_domain *dom) if (chan.attr.output == -1) { chan.attr.output = default_attr.output; } + if (chan.attr.tracefile_count == -1) { + chan.attr.tracefile_count = default_attr.tracefile_count; + } + if (chan.attr.tracefile_size == -1) { + chan.attr.tracefile_size = default_attr.tracefile_size; + } } /* @@ -179,6 +193,15 @@ static int enable_channel(char *session_name) set_default_attr(&dom); + if ((chan.attr.tracefile_size > 0) && + (chan.attr.tracefile_size < chan.attr.subbuf_size)) { + ERR("Tracefile_size must be superior or equal to subbuf_size " + "(%" PRIu64 " < %" PRIu64 ")", + chan.attr.tracefile_size, chan.attr.subbuf_size); + ret = CMD_ERROR; + goto error; + } + /* Setting channel output */ if (opt_output) { if (!strncmp(output_mmap, opt_output, strlen(output_mmap))) { @@ -307,6 +330,16 @@ int cmd_enable_channels(int argc, const char **argv) case OPT_USERSPACE: opt_userspace = 1; break; + case OPT_TRACEFILE_SIZE: + chan.attr.tracefile_size = atoll(poptGetOptArg(pc)); + DBG("Maximum tracefile size set to %" PRIu64, + chan.attr.tracefile_size); + break; + case OPT_TRACEFILE_COUNT: + chan.attr.tracefile_count = atoll(poptGetOptArg(pc)); + DBG("Maximum tracefile count set to %" PRIu32, + chan.attr.tracefile_count); + break; case OPT_LIST_OPTIONS: list_cmd_options(stdout, long_options); goto end; diff --git a/src/common/consumer.c b/src/common/consumer.c index 5f87f4b..0c59846 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -828,7 +828,9 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, uid_t uid, gid_t gid, int relayd_id, - enum lttng_event_output output) + enum lttng_event_output output, + uint64_t tracefile_size, + uint32_t tracefile_count) { struct lttng_consumer_channel *channel; @@ -845,6 +847,8 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, channel->gid = gid; channel->relayd_id = relayd_id; channel->output = output; + channel->tracefile_size = tracefile_size; + channel->tracefile_count = tracefile_count; strncpy(channel->pathname, pathname, sizeof(channel->pathname)); channel->pathname[sizeof(channel->pathname) - 1] = '\0'; @@ -1284,6 +1288,93 @@ end: } /* + * Create the tracefile on disk. + * + * Return 0 on success or else a negative value. + */ +int lttng_create_output_file(struct lttng_consumer_stream *stream) +{ + int ret; + char full_path[PATH_MAX]; + char *path_name_id = NULL; + char *path; + + assert(stream); + assert(stream->net_seq_idx == (uint64_t) -1ULL); + + ret = snprintf(full_path, sizeof(full_path), "%s/%s", + stream->chan->pathname, stream->name); + if (ret < 0) { + PERROR("snprintf create output file"); + goto error; + } + + /* + * If we split the trace in multiple files, we have to add the tracefile + * current count at the end of the tracefile name + */ + if (stream->chan->tracefile_size > 0) { + ret = asprintf(&path_name_id, "%s_%" PRIu32, full_path, + stream->tracefile_count_current); + if (ret < 0) { + PERROR("Allocating path name ID"); + goto error; + } + path = path_name_id; + } else { + path = full_path; + } + + ret = run_as_open(path, O_WRONLY | O_CREAT | O_TRUNC, + S_IRWXU | S_IRWXG | S_IRWXO, stream->uid, stream->gid); + if (ret < 0) { + PERROR("open stream path %s", path); + goto error_open; + } + stream->out_fd = ret; + stream->tracefile_size_current = 0; + +error_open: + free(path_name_id); +error: + return ret; +} + +/* + * Change the output tracefile according to the tracefile_size and + * tracefile_count parameters. The stream lock MUST be held before calling this + * function because we are modifying the stream status. + * + * Return 0 on success or else a negative value. + */ +static int rotate_output_file(struct lttng_consumer_stream *stream) +{ + int ret; + + assert(stream); + assert(stream->tracefile_size_current); + + ret = close(stream->out_fd); + if (ret < 0) { + PERROR("Closing tracefile"); + goto end; + } + + if (stream->chan->tracefile_count > 0) { + stream->tracefile_count_current = + (stream->tracefile_count_current + 1) % + stream->chan->tracefile_count; + } else { + stream->tracefile_count_current++; + } + + return lttng_create_output_file(stream); + +end: + return ret; +} + +/* * Mmap the ring buffer, read it and write the data to the tracefile. This is a * core function for writing trace buffers to either the local filesystem or * the network. @@ -1390,6 +1481,21 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap( } else { /* No streaming, we have to set the len with the full padding */ len += padding; + + /* + * Check if we need to change the tracefile before writing the packet. + */ + if (stream->chan->tracefile_size > 0 && + (stream->tracefile_size_current + len) > + stream->chan->tracefile_size) { + ret = rotate_output_file(stream); + if (ret < 0) { + ERR("Rotating output file"); + goto end; + } + outfd = stream->out_fd; + } + stream->tracefile_size_current += len; } while (len > 0) { @@ -1552,6 +1658,21 @@ ssize_t lttng_consumer_on_read_subbuffer_splice( } else { /* No streaming, we have to set the len with the full padding */ len += padding; + + /* + * Check if we need to change the tracefile before writing the packet. + */ + if (stream->chan->tracefile_size > 0 && + (stream->tracefile_size_current + len) > + stream->chan->tracefile_size) { + ret = rotate_output_file(stream); + if (ret < 0) { + ERR("Rotating output file"); + goto end; + } + outfd = stream->out_fd; + } + stream->tracefile_size_current += len; } while (len > 0) { diff --git a/src/common/consumer.h b/src/common/consumer.h index 4638752..6a15b0c 100644 --- a/src/common/consumer.h +++ b/src/common/consumer.h @@ -146,6 +146,9 @@ struct lttng_consumer_channel { /* For metadata periodical flush */ int switch_timer_enabled; timer_t switch_timer; + /* On-disk circular buffer */ + uint64_t tracefile_size; + uint32_t tracefile_count; }; /* @@ -233,6 +236,9 @@ struct lttng_consumer_stream { /* Internal state of libustctl. */ struct ustctl_consumer_stream *ustream; struct cds_list_head send_node; + /* On-disk circular buffer */ + uint64_t tracefile_size_current; + uint32_t tracefile_count_current; }; /* @@ -460,7 +466,9 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, uid_t uid, gid_t gid, int relayd_id, - enum lttng_event_output output); + enum lttng_event_output output, + uint64_t tracefile_size, + uint32_t tracefile_count); void consumer_del_stream(struct lttng_consumer_stream *stream, struct lttng_ht *ht); void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, @@ -486,6 +494,7 @@ struct lttng_consumer_local_data *lttng_consumer_create( int (*recv_stream)(struct lttng_consumer_stream *stream), int (*update_stream)(int sessiond_key, uint32_t state)); void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx); +int lttng_create_output_file(struct lttng_consumer_stream *stream); ssize_t lttng_consumer_on_read_subbuffer_mmap( struct lttng_consumer_local_data *ctx, struct lttng_consumer_stream *stream, unsigned long len, diff --git a/src/common/defaults.h b/src/common/defaults.h index 94a2a35..fb6a975 100644 --- a/src/common/defaults.h +++ b/src/common/defaults.h @@ -136,6 +136,10 @@ #define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM DEFAULT_CHANNEL_SUBBUF_NUM /* See lttng-kernel.h enum lttng_kernel_output for channel output */ #define DEFAULT_KERNEL_CHANNEL_OUTPUT LTTNG_EVENT_SPLICE +/* By default, unlimited tracefile size */ +#define DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE 0 +/* By default, unlimited tracefile count */ +#define DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT 0 #define DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER \ DEFAULT_CHANNEL_SWITCH_TIMER @@ -149,6 +153,10 @@ #define DEFAULT_UST_CHANNEL_SUBBUF_NUM DEFAULT_CHANNEL_SUBBUF_NUM /* See lttng-ust.h enum lttng_ust_output */ #define DEFAULT_UST_CHANNEL_OUTPUT LTTNG_EVENT_MMAP +/* By default, unlimited tracefile size */ +#define DEFAULT_UST_CHANNEL_TRACEFILE_SIZE 0 +/* By default, unlimited tracefile count */ +#define DEFAULT_UST_CHANNEL_TRACEFILE_COUNT 0 #define DEFAULT_UST_CHANNEL_SWITCH_TIMER \ DEFAULT_CHANNEL_SWITCH_TIMER diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 0de7344..385af87 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -132,7 +132,9 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, new_channel = consumer_allocate_channel(msg.u.channel.channel_key, msg.u.channel.session_id, msg.u.channel.pathname, msg.u.channel.name, msg.u.channel.uid, msg.u.channel.gid, - msg.u.channel.relayd_id, msg.u.channel.output); + msg.u.channel.relayd_id, msg.u.channel.output, + msg.u.channel.tracefile_size, + msg.u.channel.tracefile_count); if (new_channel == NULL) { lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); goto end_nosignal; @@ -501,28 +503,15 @@ end: int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream) { int ret; - char full_path[PATH_MAX]; assert(stream); - ret = snprintf(full_path, sizeof(full_path), "%s/%s", - stream->chan->pathname, stream->name); + ret = lttng_create_output_file(stream); if (ret < 0) { - PERROR("snprintf on_recv_stream"); + ERR("Creating output file"); goto error; } - /* Opening the tracefile in write mode */ - if (stream->net_seq_idx == (uint64_t) -1ULL) { - ret = run_as_open(full_path, O_WRONLY | O_CREAT | O_TRUNC, - S_IRWXU|S_IRWXG|S_IRWXO, stream->uid, stream->gid); - if (ret < 0) { - PERROR("open kernel stream path %s", full_path); - goto error; - } - stream->out_fd = ret; - } - if (stream->output == LTTNG_EVENT_MMAP) { /* get the len of the mmap region */ unsigned long mmap_len; diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 63d4eda..5980ddf 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -291,6 +291,8 @@ struct lttcomm_consumer_msg { /* Use splice or mmap to consume this fd */ enum lttng_event_output output; int type; /* Per cpu or metadata. */ + uint64_t tracefile_size; /* bytes */ + uint32_t tracefile_count; /* number of tracefiles */ } LTTNG_PACKED channel; /* Only used by Kernel. */ struct { uint64_t stream_key; @@ -328,6 +330,8 @@ struct lttcomm_consumer_msg { uint64_t key; /* Unique channel key. */ unsigned char uuid[UUID_STR_LEN]; /* uuid for ust tracer. */ uint32_t chan_id; /* Channel ID on the tracer side. */ + uint64_t tracefile_size; /* bytes */ + uint32_t tracefile_count; /* number of tracefiles */ } LTTNG_PACKED ask_channel; struct { uint64_t key; diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 431b946..95b0f62 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -112,13 +112,14 @@ error: */ static struct lttng_consumer_channel *allocate_channel(uint64_t session_id, const char *pathname, const char *name, uid_t uid, gid_t gid, - int relayd_id, uint64_t key, enum lttng_event_output output) + int relayd_id, uint64_t key, enum lttng_event_output output, + uint64_t tracefile_size, uint32_t tracefile_count) { assert(pathname); assert(name); return consumer_allocate_channel(key, session_id, pathname, name, uid, gid, - relayd_id, output); + relayd_id, output, tracefile_size, tracefile_count); } /* @@ -848,7 +849,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, msg.u.ask_channel.pathname, msg.u.ask_channel.name, msg.u.ask_channel.uid, msg.u.ask_channel.gid, msg.u.ask_channel.relayd_id, msg.u.ask_channel.key, - (enum lttng_event_output) msg.u.ask_channel.output); + (enum lttng_event_output) msg.u.ask_channel.output, + msg.u.ask_channel.tracefile_size, + msg.u.ask_channel.tracefile_count); if (!channel) { goto end_channel_error; } @@ -1283,35 +1286,7 @@ end: */ int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream) { - int ret; - char full_path[PATH_MAX]; - - /* Opening the tracefile in write mode */ - if (stream->net_seq_idx != (uint64_t) -1ULL) { - goto end; - } - - ret = snprintf(full_path, sizeof(full_path), "%s/%s", - stream->chan->pathname, stream->name); - if (ret < 0) { - PERROR("snprintf on_recv_stream"); - goto error; - } - - ret = run_as_open(full_path, O_WRONLY | O_CREAT | O_TRUNC, - S_IRWXU | S_IRWXG | S_IRWXO, stream->uid, stream->gid); - if (ret < 0) { - PERROR("open stream path %s", full_path); - goto error; - } - stream->out_fd = ret; - -end: - /* we return 0 to let the library handle the FD internally */ - return 0; - -error: - return ret; + return lttng_create_output_file(stream); } /* diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 8f63bf3..f2a6107 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -1360,6 +1360,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, attr->subbuf_size = default_get_kernel_channel_subbuf_size(); attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM; attr->output = DEFAULT_KERNEL_CHANNEL_OUTPUT; + attr->tracefile_size = DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE; + attr->tracefile_count = DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT; break; case LTTNG_DOMAIN_UST: #if 0 @@ -1374,6 +1376,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, attr->subbuf_size = default_get_ust_channel_subbuf_size(); attr->num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM; attr->output = DEFAULT_UST_CHANNEL_OUTPUT; + attr->tracefile_size = DEFAULT_UST_CHANNEL_TRACEFILE_SIZE; + attr->tracefile_count = DEFAULT_UST_CHANNEL_TRACEFILE_COUNT; break; default: /* Default behavior: leave set to 0. */ -- 1.7.10.4 From mathieu.desnoyers at efficios.com Wed Mar 27 15:38:51 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Wed, 27 Mar 2013 15:38:51 -0400 Subject: [lttng-dev] [PATCH lttng-tools] On-disk multiple tracefiles circular buffer In-Reply-To: <1364409938-26174-1-git-send-email-dgoulet@efficios.com> References: <1364409938-26174-1-git-send-email-dgoulet@efficios.com> Message-ID: <20130327193851.GA13993@Krystal> * David Goulet (dgoulet at efficios.com) wrote: > From: Julien Desfossez > > This patch introduces the tracefile_size and tracefile_count parameters > to the enable-channel command and the API. > > This allows to split a stream into multiple tracefiles and limit the > amount of trace data to keep on disk. The tracefiles are readable > independently or with the others as long as the metadata file is > present. > > For now only local traces are handled, relayd modifications coming soon. > > Signed-off-by: Julien Desfossez > Signed-off-by: David Goulet > --- > doc/man/lttng.1 | 5 ++ > include/lttng/lttng.h | 5 +- > src/bin/lttng-sessiond/channel.c | 10 +++ > src/bin/lttng-sessiond/consumer.c | 12 ++- > src/bin/lttng-sessiond/consumer.h | 8 +- > src/bin/lttng-sessiond/kernel-consumer.c | 9 +- > src/bin/lttng-sessiond/kernel.c | 3 + > src/bin/lttng-sessiond/trace-kernel.h | 2 + > src/bin/lttng-sessiond/trace-ust.c | 4 + > src/bin/lttng-sessiond/trace-ust.h | 2 + > src/bin/lttng-sessiond/ust-app.c | 3 + > src/bin/lttng-sessiond/ust-app.h | 2 + > src/bin/lttng-sessiond/ust-consumer.c | 4 +- > src/bin/lttng/commands/enable_channels.c | 33 +++++++ > src/common/consumer.c | 123 +++++++++++++++++++++++++- > src/common/consumer.h | 11 ++- > src/common/defaults.h | 8 ++ > src/common/kernel-consumer/kernel-consumer.c | 21 ++--- > src/common/sessiond-comm/sessiond-comm.h | 4 + > src/common/ust-consumer/ust-consumer.c | 39 ++------ > src/lib/lttng-ctl/lttng-ctl.c | 4 + > 21 files changed, 253 insertions(+), 59 deletions(-) > > diff --git a/doc/man/lttng.1 b/doc/man/lttng.1 > index 0a548f8..891e106 100644 > --- a/doc/man/lttng.1 > +++ b/doc/man/lttng.1 > @@ -345,6 +345,11 @@ same type. > Use per PID buffer (\-u only). Each application has its own buffers. > \-\-buffers-global > Use shared buffer for the whole system (\-k only) > +\-C, \-\-tracefile-size SIZE > + Maximum size of tracefiles per stream (in bytes) of each tracefile within a stream > +\-W, \-\-tracefile-count COUNT > + Number of tracefiles per stream Can we beef up these descriptions so users can have a clue what this is supposed to be used for ? An example would be good. > + > .fi > > .IP > diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h > index 8566dea..9fa5844 100644 > --- a/include/lttng/lttng.h > +++ b/include/lttng/lttng.h > @@ -277,7 +277,7 @@ struct lttng_event_field { > * > * The structures should be initialized to zero before use. > */ > -#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 > +#define LTTNG_CHANNEL_ATTR_PADDING1 LTTNG_SYMBOL_NAME_LEN + 20 > struct lttng_channel_attr { > int overwrite; /* 1: overwrite, 0: discard */ > uint64_t subbuf_size; /* bytes */ > @@ -285,6 +285,9 @@ struct lttng_channel_attr { > unsigned int switch_timer_interval; /* usec */ > unsigned int read_timer_interval; /* usec */ > enum lttng_event_output output; /* splice, mmap */ > + /* LTTng 2.1 padding limit */ > + uint64_t tracefile_size; /* bytes */ > + uint32_t tracefile_count; /* number of tracefiles */ why not uint64_t (same comment for all type use below) ? > > char padding[LTTNG_CHANNEL_ATTR_PADDING1]; > }; > diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c > index 6c7422b..1621bc6 100644 > --- a/src/bin/lttng-sessiond/channel.c > +++ b/src/bin/lttng-sessiond/channel.c > @@ -272,6 +272,16 @@ int channel_ust_create(struct ltt_ust_session *usess, > goto error; > } > > + /* > + * The tracefile_size should not be < to the subbuf_size, otherwise > + * we won't be able to write the packets on disk > + */ > + if ((attr->attr.tracefile_size > 0) && > + (attr->attr.tracefile_size < attr->attr.subbuf_size)) { > + ret = LTTNG_ERR_INVALID; > + goto error; > + } > + > /* Create UST channel */ > uchan = trace_ust_create_channel(attr, usess->pathname); > if (uchan == NULL) { > diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c > index f0fb2dc..c3f53be 100644 > --- a/src/bin/lttng-sessiond/consumer.c > +++ b/src/bin/lttng-sessiond/consumer.c > @@ -663,7 +663,9 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, > uint64_t relayd_id, > uint64_t key, > unsigned char *uuid, > - uint32_t chan_id) > + uint32_t chan_id, > + uint64_t tracefile_size, > + uint32_t tracefile_count) > { > assert(msg); > > @@ -684,6 +686,8 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, > msg->u.ask_channel.relayd_id = relayd_id; > msg->u.ask_channel.key = key; > msg->u.ask_channel.chan_id = chan_id; > + msg->u.ask_channel.tracefile_size = tracefile_size; > + msg->u.ask_channel.tracefile_count = tracefile_count; > > memcpy(msg->u.ask_channel.uuid, uuid, sizeof(msg->u.ask_channel.uuid)); > > @@ -709,7 +713,9 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, > const char *name, > unsigned int nb_init_streams, > enum lttng_event_output output, > - int type) > + int type, > + uint64_t tracefile_size, > + uint32_t tracefile_count) > { > assert(msg); > > @@ -726,6 +732,8 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, > msg->u.channel.nb_init_streams = nb_init_streams; > msg->u.channel.output = output; > msg->u.channel.type = type; > + msg->u.channel.tracefile_size = tracefile_size; > + msg->u.channel.tracefile_count = tracefile_count; > > strncpy(msg->u.channel.pathname, pathname, > sizeof(msg->u.channel.pathname)); > diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h > index b767589..c2631ba 100644 > --- a/src/bin/lttng-sessiond/consumer.h > +++ b/src/bin/lttng-sessiond/consumer.h > @@ -200,7 +200,9 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, > uint64_t relayd_id, > uint64_t key, > unsigned char *uuid, > - uint32_t chan_id); > + uint32_t chan_id, > + uint64_t tracefile_size, > + uint32_t tracefile_count); > void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg, > enum lttng_consumer_command cmd, > uint64_t channel_key, > @@ -217,7 +219,9 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, > const char *name, > unsigned int nb_init_streams, > enum lttng_event_output output, > - int type); > + int type, > + uint64_t tracefile_size, > + uint32_t tracefile_count); > int consumer_is_data_pending(uint64_t session_id, > struct consumer_output *consumer); > int consumer_close_metadata(struct consumer_socket *socket, > diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c > index 3368da6..05e30e4 100644 > --- a/src/bin/lttng-sessiond/kernel-consumer.c > +++ b/src/bin/lttng-sessiond/kernel-consumer.c > @@ -94,7 +94,9 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, > channel->channel->name, > channel->stream_count, > channel->channel->attr.output, > - CONSUMER_CHANNEL_TYPE_DATA); > + CONSUMER_CHANNEL_TYPE_DATA, > + channel->channel->attr.tracefile_size, > + channel->channel->attr.tracefile_count); > > health_code_update(); > > @@ -174,7 +176,8 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, > DEFAULT_METADATA_NAME, > 1, > DEFAULT_KERNEL_CHANNEL_OUTPUT, > - CONSUMER_CHANNEL_TYPE_METADATA); > + CONSUMER_CHANNEL_TYPE_METADATA, > + 0, 0); > > health_code_update(); > > @@ -190,7 +193,7 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, > LTTNG_CONSUMER_ADD_STREAM, > session->metadata->fd, > session->metadata_stream_fd, > - 0); /* CPU: 0 for metadata. */ > + 0); /* CPU: 0 for metadata. */ > > health_code_update(); > > diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c > index d3a6453..9519411 100644 > --- a/src/bin/lttng-sessiond/kernel.c > +++ b/src/bin/lttng-sessiond/kernel.c > @@ -536,6 +536,9 @@ int kernel_open_channel_stream(struct ltt_kernel_channel *channel) > PERROR("fcntl session fd"); > } > > + lks->tracefile_size = channel->channel->attr.tracefile_size; > + lks->tracefile_count = channel->channel->attr.tracefile_count; > + > /* Add stream to channe stream list */ > cds_list_add(&lks->list, &channel->stream_list.head); > channel->stream_count++; > diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h > index 66ca8db..ea30827 100644 > --- a/src/bin/lttng-sessiond/trace-kernel.h > +++ b/src/bin/lttng-sessiond/trace-kernel.h > @@ -82,6 +82,8 @@ struct ltt_kernel_stream { > int cpu; > /* Format is %s_%d respectively channel name and CPU number. */ > char name[DEFAULT_STREAM_NAME_LEN]; > + uint64_t tracefile_size; > + uint32_t tracefile_count; > struct cds_list_head list; > }; > > diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c > index 8f15a15..cd8ff10 100644 > --- a/src/bin/lttng-sessiond/trace-ust.c > +++ b/src/bin/lttng-sessiond/trace-ust.c > @@ -293,6 +293,10 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, > luc->events = lttng_ht_new(0, LTTNG_HT_TYPE_STRING); > luc->ctx = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); > > + /* On-disk circular buffer parameters */ > + luc->tracefile_size = chan->attr.tracefile_size; > + luc->tracefile_count = chan->attr.tracefile_count; > + > DBG2("Trace UST channel %s created", luc->name); > > error: > diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h > index 87fe412..588905a 100644 > --- a/src/bin/lttng-sessiond/trace-ust.h > +++ b/src/bin/lttng-sessiond/trace-ust.h > @@ -59,6 +59,8 @@ struct ltt_ust_channel { > struct lttng_ht *ctx; > struct lttng_ht *events; > struct lttng_ht_node_str node; > + uint64_t tracefile_size; > + uint32_t tracefile_count; > }; > > /* UST Metadata */ > diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c > index fdcad1c..4c9d227 100644 > --- a/src/bin/lttng-sessiond/ust-app.c > +++ b/src/bin/lttng-sessiond/ust-app.c > @@ -1298,6 +1298,9 @@ static void shadow_copy_channel(struct ust_app_channel *ua_chan, > strncpy(ua_chan->name, uchan->name, sizeof(ua_chan->name)); > ua_chan->name[sizeof(ua_chan->name) - 1] = '\0'; > > + ua_chan->tracefile_size = uchan->tracefile_size; > + ua_chan->tracefile_count = uchan->tracefile_count; > + > /* Copy event attributes since the layout is different. */ > ua_chan->attr.subbuf_size = uchan->attr.subbuf_size; > ua_chan->attr.num_subbuf = uchan->attr.num_subbuf; > diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h > index 82694a7..b94603f 100644 > --- a/src/bin/lttng-sessiond/ust-app.h > +++ b/src/bin/lttng-sessiond/ust-app.h > @@ -143,6 +143,8 @@ struct ust_app_channel { > struct ust_app_session *session; > struct lttng_ht *ctx; > struct lttng_ht *events; > + uint64_t tracefile_size; > + uint32_t tracefile_count; > /* > * Node indexed by channel name in the channels' hash table of a session. > */ > diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c > index 7f01de9..93c1f71 100644 > --- a/src/bin/lttng-sessiond/ust-consumer.c > +++ b/src/bin/lttng-sessiond/ust-consumer.c > @@ -155,7 +155,9 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, > consumer->net_seq_index, > ua_chan->key, > registry->uuid, > - chan_id); > + chan_id, > + ua_chan->tracefile_size, > + ua_chan->tracefile_count); > > health_code_update(); > > diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c > index 02a3180..d303bbd 100644 > --- a/src/bin/lttng/commands/enable_channels.c > +++ b/src/bin/lttng/commands/enable_channels.c > @@ -49,6 +49,8 @@ enum { > OPT_READ_TIMER, > OPT_USERSPACE, > OPT_LIST_OPTIONS, > + OPT_TRACEFILE_SIZE, > + OPT_TRACEFILE_COUNT, > }; > > static struct lttng_handle *handle; > @@ -73,6 +75,8 @@ static struct poptOption long_options[] = { > {"buffers-uid", 0, POPT_ARG_VAL, &opt_buffer_uid, 1, 0, 0}, > {"buffers-pid", 0, POPT_ARG_VAL, &opt_buffer_pid, 1, 0, 0}, > {"buffers-global", 0, POPT_ARG_VAL, &opt_buffer_global, 1, 0, 0}, > + {"tracefile_size", 'C', POPT_ARG_INT, 0, OPT_TRACEFILE_SIZE, 0, 0}, > + {"tracefile_count", 'W', POPT_ARG_INT, 0, OPT_TRACEFILE_COUNT, 0, 0}, > {0, 0, 0, 0, 0, 0, 0} > }; > > @@ -115,6 +119,10 @@ static void usage(FILE *ofp) > fprintf(ofp, " --buffers-uid Use per UID buffer (-u only)\n"); > fprintf(ofp, " --buffers-pid Use per PID buffer (-u only)\n"); > fprintf(ofp, " --buffers-global Use shared buffer for the whole system (-k only)\n"); > + fprintf(ofp, " -C, --tracefile-size SIZE\n"); > + fprintf(ofp, " Maximum size of tracefiles per stream (in bytes)\n"); > + fprintf(ofp, " -W, --tracefile-count COUNT\n"); > + fprintf(ofp, " Number of tracefiles per stream to keep\n"); more info would be welcome, like the manpage. > fprintf(ofp, "\n"); > } > > @@ -147,6 +155,12 @@ static void set_default_attr(struct lttng_domain *dom) > if (chan.attr.output == -1) { > chan.attr.output = default_attr.output; > } > + if (chan.attr.tracefile_count == -1) { > + chan.attr.tracefile_count = default_attr.tracefile_count; > + } > + if (chan.attr.tracefile_size == -1) { > + chan.attr.tracefile_size = default_attr.tracefile_size; > + } > } > > /* > @@ -179,6 +193,15 @@ static int enable_channel(char *session_name) > > set_default_attr(&dom); > > + if ((chan.attr.tracefile_size > 0) && > + (chan.attr.tracefile_size < chan.attr.subbuf_size)) { > + ERR("Tracefile_size must be superior or equal to subbuf_size " superior -> higher Thanks, Mathieu > + "(%" PRIu64 " < %" PRIu64 ")", > + chan.attr.tracefile_size, chan.attr.subbuf_size); > + ret = CMD_ERROR; > + goto error; > + } > + > /* Setting channel output */ > if (opt_output) { > if (!strncmp(output_mmap, opt_output, strlen(output_mmap))) { > @@ -307,6 +330,16 @@ int cmd_enable_channels(int argc, const char **argv) > case OPT_USERSPACE: > opt_userspace = 1; > break; > + case OPT_TRACEFILE_SIZE: > + chan.attr.tracefile_size = atoll(poptGetOptArg(pc)); > + DBG("Maximum tracefile size set to %" PRIu64, > + chan.attr.tracefile_size); > + break; > + case OPT_TRACEFILE_COUNT: > + chan.attr.tracefile_count = atoll(poptGetOptArg(pc)); > + DBG("Maximum tracefile count set to %" PRIu32, > + chan.attr.tracefile_count); > + break; > case OPT_LIST_OPTIONS: > list_cmd_options(stdout, long_options); > goto end; > diff --git a/src/common/consumer.c b/src/common/consumer.c > index 5f87f4b..0c59846 100644 > --- a/src/common/consumer.c > +++ b/src/common/consumer.c > @@ -828,7 +828,9 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, > uid_t uid, > gid_t gid, > int relayd_id, > - enum lttng_event_output output) > + enum lttng_event_output output, > + uint64_t tracefile_size, > + uint32_t tracefile_count) > { > struct lttng_consumer_channel *channel; > > @@ -845,6 +847,8 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, > channel->gid = gid; > channel->relayd_id = relayd_id; > channel->output = output; > + channel->tracefile_size = tracefile_size; > + channel->tracefile_count = tracefile_count; > > strncpy(channel->pathname, pathname, sizeof(channel->pathname)); > channel->pathname[sizeof(channel->pathname) - 1] = '\0'; > @@ -1284,6 +1288,93 @@ end: > } > > /* > + * Create the tracefile on disk. > + * > + * Return 0 on success or else a negative value. > + */ > +int lttng_create_output_file(struct lttng_consumer_stream *stream) > +{ > + int ret; > + char full_path[PATH_MAX]; > + char *path_name_id = NULL; > + char *path; > + > + assert(stream); > + assert(stream->net_seq_idx == (uint64_t) -1ULL); > + > + ret = snprintf(full_path, sizeof(full_path), "%s/%s", > + stream->chan->pathname, stream->name); > + if (ret < 0) { > + PERROR("snprintf create output file"); > + goto error; > + } > + > + /* > + * If we split the trace in multiple files, we have to add the tracefile > + * current count at the end of the tracefile name > + */ > + if (stream->chan->tracefile_size > 0) { > + ret = asprintf(&path_name_id, "%s_%" PRIu32, full_path, > + stream->tracefile_count_current); > + if (ret < 0) { > + PERROR("Allocating path name ID"); > + goto error; > + } > + path = path_name_id; > + } else { > + path = full_path; > + } > + > + ret = run_as_open(path, O_WRONLY | O_CREAT | O_TRUNC, > + S_IRWXU | S_IRWXG | S_IRWXO, stream->uid, stream->gid); > + if (ret < 0) { > + PERROR("open stream path %s", path); > + goto error_open; > + } > + stream->out_fd = ret; > + stream->tracefile_size_current = 0; > + > +error_open: > + free(path_name_id); > +error: > + return ret; > +} > + > +/* > + * Change the output tracefile according to the tracefile_size and > + * tracefile_count parameters. The stream lock MUST be held before calling this > + * function because we are modifying the stream status. > + * > + * Return 0 on success or else a negative value. > + */ > +static int rotate_output_file(struct lttng_consumer_stream *stream) > +{ > + int ret; > + > + assert(stream); > + assert(stream->tracefile_size_current); > + > + ret = close(stream->out_fd); > + if (ret < 0) { > + PERROR("Closing tracefile"); > + goto end; > + } > + > + if (stream->chan->tracefile_count > 0) { > + stream->tracefile_count_current = > + (stream->tracefile_count_current + 1) % > + stream->chan->tracefile_count; > + } else { > + stream->tracefile_count_current++; > + } > + > + return lttng_create_output_file(stream); > + > +end: > + return ret; > +} > + > +/* > * Mmap the ring buffer, read it and write the data to the tracefile. This is a > * core function for writing trace buffers to either the local filesystem or > * the network. > @@ -1390,6 +1481,21 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap( > } else { > /* No streaming, we have to set the len with the full padding */ > len += padding; > + > + /* > + * Check if we need to change the tracefile before writing the packet. > + */ > + if (stream->chan->tracefile_size > 0 && > + (stream->tracefile_size_current + len) > > + stream->chan->tracefile_size) { > + ret = rotate_output_file(stream); > + if (ret < 0) { > + ERR("Rotating output file"); > + goto end; > + } > + outfd = stream->out_fd; > + } > + stream->tracefile_size_current += len; > } > > while (len > 0) { > @@ -1552,6 +1658,21 @@ ssize_t lttng_consumer_on_read_subbuffer_splice( > } else { > /* No streaming, we have to set the len with the full padding */ > len += padding; > + > + /* > + * Check if we need to change the tracefile before writing the packet. > + */ > + if (stream->chan->tracefile_size > 0 && > + (stream->tracefile_size_current + len) > > + stream->chan->tracefile_size) { > + ret = rotate_output_file(stream); > + if (ret < 0) { > + ERR("Rotating output file"); > + goto end; > + } > + outfd = stream->out_fd; > + } > + stream->tracefile_size_current += len; > } > > while (len > 0) { > diff --git a/src/common/consumer.h b/src/common/consumer.h > index 4638752..6a15b0c 100644 > --- a/src/common/consumer.h > +++ b/src/common/consumer.h > @@ -146,6 +146,9 @@ struct lttng_consumer_channel { > /* For metadata periodical flush */ > int switch_timer_enabled; > timer_t switch_timer; > + /* On-disk circular buffer */ > + uint64_t tracefile_size; > + uint32_t tracefile_count; > }; > > /* > @@ -233,6 +236,9 @@ struct lttng_consumer_stream { > /* Internal state of libustctl. */ > struct ustctl_consumer_stream *ustream; > struct cds_list_head send_node; > + /* On-disk circular buffer */ > + uint64_t tracefile_size_current; > + uint32_t tracefile_count_current; > }; > > /* > @@ -460,7 +466,9 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, > uid_t uid, > gid_t gid, > int relayd_id, > - enum lttng_event_output output); > + enum lttng_event_output output, > + uint64_t tracefile_size, > + uint32_t tracefile_count); > void consumer_del_stream(struct lttng_consumer_stream *stream, > struct lttng_ht *ht); > void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, > @@ -486,6 +494,7 @@ struct lttng_consumer_local_data *lttng_consumer_create( > int (*recv_stream)(struct lttng_consumer_stream *stream), > int (*update_stream)(int sessiond_key, uint32_t state)); > void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx); > +int lttng_create_output_file(struct lttng_consumer_stream *stream); > ssize_t lttng_consumer_on_read_subbuffer_mmap( > struct lttng_consumer_local_data *ctx, > struct lttng_consumer_stream *stream, unsigned long len, > diff --git a/src/common/defaults.h b/src/common/defaults.h > index 94a2a35..fb6a975 100644 > --- a/src/common/defaults.h > +++ b/src/common/defaults.h > @@ -136,6 +136,10 @@ > #define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM DEFAULT_CHANNEL_SUBBUF_NUM > /* See lttng-kernel.h enum lttng_kernel_output for channel output */ > #define DEFAULT_KERNEL_CHANNEL_OUTPUT LTTNG_EVENT_SPLICE > +/* By default, unlimited tracefile size */ > +#define DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE 0 > +/* By default, unlimited tracefile count */ > +#define DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT 0 > > #define DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER \ > DEFAULT_CHANNEL_SWITCH_TIMER > @@ -149,6 +153,10 @@ > #define DEFAULT_UST_CHANNEL_SUBBUF_NUM DEFAULT_CHANNEL_SUBBUF_NUM > /* See lttng-ust.h enum lttng_ust_output */ > #define DEFAULT_UST_CHANNEL_OUTPUT LTTNG_EVENT_MMAP > +/* By default, unlimited tracefile size */ > +#define DEFAULT_UST_CHANNEL_TRACEFILE_SIZE 0 > +/* By default, unlimited tracefile count */ > +#define DEFAULT_UST_CHANNEL_TRACEFILE_COUNT 0 > > #define DEFAULT_UST_CHANNEL_SWITCH_TIMER \ > DEFAULT_CHANNEL_SWITCH_TIMER > diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c > index 0de7344..385af87 100644 > --- a/src/common/kernel-consumer/kernel-consumer.c > +++ b/src/common/kernel-consumer/kernel-consumer.c > @@ -132,7 +132,9 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, > new_channel = consumer_allocate_channel(msg.u.channel.channel_key, > msg.u.channel.session_id, msg.u.channel.pathname, > msg.u.channel.name, msg.u.channel.uid, msg.u.channel.gid, > - msg.u.channel.relayd_id, msg.u.channel.output); > + msg.u.channel.relayd_id, msg.u.channel.output, > + msg.u.channel.tracefile_size, > + msg.u.channel.tracefile_count); > if (new_channel == NULL) { > lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); > goto end_nosignal; > @@ -501,28 +503,15 @@ end: > int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream) > { > int ret; > - char full_path[PATH_MAX]; > > assert(stream); > > - ret = snprintf(full_path, sizeof(full_path), "%s/%s", > - stream->chan->pathname, stream->name); > + ret = lttng_create_output_file(stream); > if (ret < 0) { > - PERROR("snprintf on_recv_stream"); > + ERR("Creating output file"); > goto error; > } > > - /* Opening the tracefile in write mode */ > - if (stream->net_seq_idx == (uint64_t) -1ULL) { > - ret = run_as_open(full_path, O_WRONLY | O_CREAT | O_TRUNC, > - S_IRWXU|S_IRWXG|S_IRWXO, stream->uid, stream->gid); > - if (ret < 0) { > - PERROR("open kernel stream path %s", full_path); > - goto error; > - } > - stream->out_fd = ret; > - } > - > if (stream->output == LTTNG_EVENT_MMAP) { > /* get the len of the mmap region */ > unsigned long mmap_len; > diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h > index 63d4eda..5980ddf 100644 > --- a/src/common/sessiond-comm/sessiond-comm.h > +++ b/src/common/sessiond-comm/sessiond-comm.h > @@ -291,6 +291,8 @@ struct lttcomm_consumer_msg { > /* Use splice or mmap to consume this fd */ > enum lttng_event_output output; > int type; /* Per cpu or metadata. */ > + uint64_t tracefile_size; /* bytes */ > + uint32_t tracefile_count; /* number of tracefiles */ > } LTTNG_PACKED channel; /* Only used by Kernel. */ > struct { > uint64_t stream_key; > @@ -328,6 +330,8 @@ struct lttcomm_consumer_msg { > uint64_t key; /* Unique channel key. */ > unsigned char uuid[UUID_STR_LEN]; /* uuid for ust tracer. */ > uint32_t chan_id; /* Channel ID on the tracer side. */ > + uint64_t tracefile_size; /* bytes */ > + uint32_t tracefile_count; /* number of tracefiles */ > } LTTNG_PACKED ask_channel; > struct { > uint64_t key; > diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c > index 431b946..95b0f62 100644 > --- a/src/common/ust-consumer/ust-consumer.c > +++ b/src/common/ust-consumer/ust-consumer.c > @@ -112,13 +112,14 @@ error: > */ > static struct lttng_consumer_channel *allocate_channel(uint64_t session_id, > const char *pathname, const char *name, uid_t uid, gid_t gid, > - int relayd_id, uint64_t key, enum lttng_event_output output) > + int relayd_id, uint64_t key, enum lttng_event_output output, > + uint64_t tracefile_size, uint32_t tracefile_count) > { > assert(pathname); > assert(name); > > return consumer_allocate_channel(key, session_id, pathname, name, uid, gid, > - relayd_id, output); > + relayd_id, output, tracefile_size, tracefile_count); > } > > /* > @@ -848,7 +849,9 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, > msg.u.ask_channel.pathname, msg.u.ask_channel.name, > msg.u.ask_channel.uid, msg.u.ask_channel.gid, > msg.u.ask_channel.relayd_id, msg.u.ask_channel.key, > - (enum lttng_event_output) msg.u.ask_channel.output); > + (enum lttng_event_output) msg.u.ask_channel.output, > + msg.u.ask_channel.tracefile_size, > + msg.u.ask_channel.tracefile_count); > if (!channel) { > goto end_channel_error; > } > @@ -1283,35 +1286,7 @@ end: > */ > int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream) > { > - int ret; > - char full_path[PATH_MAX]; > - > - /* Opening the tracefile in write mode */ > - if (stream->net_seq_idx != (uint64_t) -1ULL) { > - goto end; > - } > - > - ret = snprintf(full_path, sizeof(full_path), "%s/%s", > - stream->chan->pathname, stream->name); > - if (ret < 0) { > - PERROR("snprintf on_recv_stream"); > - goto error; > - } > - > - ret = run_as_open(full_path, O_WRONLY | O_CREAT | O_TRUNC, > - S_IRWXU | S_IRWXG | S_IRWXO, stream->uid, stream->gid); > - if (ret < 0) { > - PERROR("open stream path %s", full_path); > - goto error; > - } > - stream->out_fd = ret; > - > -end: > - /* we return 0 to let the library handle the FD internally */ > - return 0; > - > -error: > - return ret; > + return lttng_create_output_file(stream); > } > > /* > diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c > index 8f63bf3..f2a6107 100644 > --- a/src/lib/lttng-ctl/lttng-ctl.c > +++ b/src/lib/lttng-ctl/lttng-ctl.c > @@ -1360,6 +1360,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, > attr->subbuf_size = default_get_kernel_channel_subbuf_size(); > attr->num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM; > attr->output = DEFAULT_KERNEL_CHANNEL_OUTPUT; > + attr->tracefile_size = DEFAULT_KERNEL_CHANNEL_TRACEFILE_SIZE; > + attr->tracefile_count = DEFAULT_KERNEL_CHANNEL_TRACEFILE_COUNT; > break; > case LTTNG_DOMAIN_UST: > #if 0 > @@ -1374,6 +1376,8 @@ void lttng_channel_set_default_attr(struct lttng_domain *domain, > attr->subbuf_size = default_get_ust_channel_subbuf_size(); > attr->num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM; > attr->output = DEFAULT_UST_CHANNEL_OUTPUT; > + attr->tracefile_size = DEFAULT_UST_CHANNEL_TRACEFILE_SIZE; > + attr->tracefile_count = DEFAULT_UST_CHANNEL_TRACEFILE_COUNT; > break; > default: > /* Default behavior: leave set to 0. */ > -- > 1.7.10.4 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From Daniel.Thibault at drdc-rddc.gc.ca Wed Mar 27 16:06:53 2013 From: Daniel.Thibault at drdc-rddc.gc.ca (Thibault, Daniel) Date: Wed, 27 Mar 2013 20:06:53 +0000 Subject: [lttng-dev] [PATCH lttng-tools] On-disk multiple tracefiles circular buffer Message-ID: <48CF5AC71E61DB46B70D0F388054EFFD029AA8@VAL-E-01.valcartier.drdc-rddc.gc.ca> > > @@ -179,6 +193,15 @@ static int enable_channel(char *session_name) > > > > set_default_attr(&dom); > > > > + if ((chan.attr.tracefile_size > 0) && > > + (chan.attr.tracefile_size < chan.attr.subbuf_size)) { > > + ERR("Tracefile_size must be superior or equal to subbuf_size " > > superior -> higher > > Mathieu Actually, the proper expression is "Tracefile_size must be greater than or equal to subbuf_size". Daniel U. Thibault R & D pour la d?fense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier) Cyber s?curit? pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS) Protection des syst?mes et contremesures (PSC) / Systems Protection & Countermeasures (SPC) 2459 route de la Bravoure Qu?bec, QC G3J 1X5 CANADA Vox : (418) 844-4000 x4245 Fax : (418) 844-4538 NAC : 918V QSDJ Gouvernement du Canada / Government of Canada From jeremie.galarneau at efficios.com Thu Mar 28 00:05:11 2013 From: jeremie.galarneau at efficios.com (=?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?=) Date: Thu, 28 Mar 2013 00:05:11 -0400 Subject: [lttng-dev] [PATCH lttng-ust] Add demo test back as an example Message-ID: <1364443511-5091-1-git-send-email-jeremie.galarneau@efficios.com> Updated the lttng-ust man page to point to doc/examples/demo instead of the now moved /tests/demo. Minor typo fix. Signed-off-by: J?r?mie Galarneau --- doc/examples/demo/Makefile | 42 ++++++++++++++++++++++ doc/examples/demo/README | 27 ++++++++++++++ doc/examples/demo/demo-trace | 6 ++++ doc/examples/demo/demo.c | 65 +++++++++++++++++++++++++++++++++ doc/examples/demo/tp.c | 26 ++++++++++++++ doc/examples/demo/tp2.c | 26 ++++++++++++++ doc/examples/demo/tp3.c | 26 ++++++++++++++ doc/examples/demo/ust_tests_demo.h | 71 +++++++++++++++++++++++++++++++++++++ doc/examples/demo/ust_tests_demo2.h | 68 +++++++++++++++++++++++++++++++++++ doc/examples/demo/ust_tests_demo3.h | 53 +++++++++++++++++++++++++++ doc/man/lttng-ust.3 | 4 +-- 11 files changed, 412 insertions(+), 2 deletions(-) create mode 100644 doc/examples/demo/Makefile create mode 100644 doc/examples/demo/README create mode 100755 doc/examples/demo/demo-trace create mode 100644 doc/examples/demo/demo.c create mode 100644 doc/examples/demo/tp.c create mode 100644 doc/examples/demo/tp2.c create mode 100644 doc/examples/demo/tp3.c create mode 100644 doc/examples/demo/ust_tests_demo.h create mode 100644 doc/examples/demo/ust_tests_demo2.h create mode 100644 doc/examples/demo/ust_tests_demo3.h diff --git a/doc/examples/demo/Makefile b/doc/examples/demo/Makefile new file mode 100644 index 0000000..41f4321 --- /dev/null +++ b/doc/examples/demo/Makefile @@ -0,0 +1,42 @@ +# Copyright (C) 2013 J?r?mie Galarneau +# +# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. +# +# Permission is hereby granted to use or copy this program for any +# purpose, provided the above notices are retained on all copies. +# Permission to modify the code and to distribute modified code is +# granted, provided the above notices are retained, and a notice that +# the code was modified is included with the above copyright notice. + +# This Makefile is not using automake so that people may see how to build +# a program and tracepoint provider probes as stand-alone shared objects. + +CC = gcc +LIBS = -ldl # On Linux +#LIBS = -lc # On BSD +CFLAGS = -I. + +all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so + +lttng-ust-provider-ust-tests-demo.o: tp.c tp2.c ust_tests_demo.h ust_tests_demo2.h + $(CC) $(CFLAGS) -fpic -c -o $@ $< + +lttng-ust-provider-ust-tests-demo.so: lttng-ust-provider-ust-tests-demo.o + $(CC) -shared -o $@ -llttng-ust $< + +lttng-ust-provider-ust-tests-demo3.o: tp3.c ust_tests_demo3.h + $(CC) $(CFLAGS) -fpic -c -o $@ $< + +lttng-ust-provider-ust-tests-demo3.so: lttng-ust-provider-ust-tests-demo3.o + $(CC) -shared -o $@ -llttng-ust $< + +demo.o: demo.c + $(CC) $(CFLAGS) -c -o $@ $< + +demo: demo.o + $(CC) demo.o -o $@ $(LIBS) + +.PHONY: clean +clean: + rm -f *.o *.so demo diff --git a/doc/examples/demo/README b/doc/examples/demo/README new file mode 100644 index 0000000..03ee4ee --- /dev/null +++ b/doc/examples/demo/README @@ -0,0 +1,27 @@ +This is a demo application used to test the LTTng userspace tracer. + +demo-trace shell script preloads the provider shared objects before +executing the demo. Executing "demo" without the shell wrapper will not +provide any tracing support. This ensures the demo binary can be +distributed on distros without depending on having liblttng-ust.so in +place. Note: the "demo" program must be compiled with "-ldl" on Linux, +with "-lc" on BSD. + +The simplest command to trace the demo program are: +lttng create +lttng enable-event -u -a +lttng start +./demo-trace +lttng destroy + +That will create a trace in your $HOME/lttng-traces directory. + +The resulting babeltrace output should look like this: +[554297567999315] ust_tests_demo:starting: { 1 }, { value = 123 } +[554297568020834] ust_tests_demo2:loop: { 1 }, { intfield = 0, intfield2 = 0x0, longfield = 0, netintfield = 0, netintfieldhex = 0x0, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } +[554297568024780] ust_tests_demo2:loop: { 1 }, { intfield = 1, intfield2 = 0x1, longfield = 1, netintfield = 1, netintfieldhex = 0x1, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } +[554297568027050] ust_tests_demo2:loop: { 1 }, { intfield = 2, intfield2 = 0x2, longfield = 2, netintfield = 2, netintfieldhex = 0x2, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } +[554297568029014] ust_tests_demo2:loop: { 1 }, { intfield = 3, intfield2 = 0x3, longfield = 3, netintfield = 3, netintfieldhex = 0x3, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } +[554297568030861] ust_tests_demo2:loop: { 1 }, { intfield = 4, intfield2 = 0x4, longfield = 4, netintfield = 4, netintfieldhex = 0x4, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } +[554297568033138] ust_tests_demo:done: { 1 }, { value = 456 } +[554297568034533] ust_tests_demo3:done: { 1 }, { value = 42 } diff --git a/doc/examples/demo/demo-trace b/doc/examples/demo/demo-trace new file mode 100755 index 0000000..dd67727 --- /dev/null +++ b/doc/examples/demo/demo-trace @@ -0,0 +1,6 @@ +#!/bin/sh + +DIR=$(dirname $0) +DIR=$(readlink -f $DIR) + +LD_PRELOAD=$DIR/lttng-ust-provider-ust-tests-demo.so:$DIR/lttng-ust-provider-ust-tests-demo3.so $DIR/demo ${*} diff --git a/doc/examples/demo/demo.c b/doc/examples/demo/demo.c new file mode 100644 index 0000000..e2b61c2 --- /dev/null +++ b/doc/examples/demo/demo.c @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2009 Pierre-Marc Fournier + * Copyright (C) 2011 Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 of + * the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TRACEPOINT_DEFINE +#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE +#include "ust_tests_demo.h" +#include "ust_tests_demo2.h" +#include "ust_tests_demo3.h" + +int main(int argc, char **argv) +{ + int i, netint; + long values[] = { 1, 2, 3 }; + char text[10] = "test"; + double dbl = 2.0; + float flt = 2222.0; + int delay = 0; + + if (argc == 2) + delay = atoi(argv[1]); + + fprintf(stderr, "Demo program starting.\n"); + + sleep(delay); + + fprintf(stderr, "Tracing... "); + tracepoint(ust_tests_demo, starting, 123); + for (i = 0; i < 5; i++) { + netint = htonl(i); + tracepoint(ust_tests_demo2, loop, i, netint, values, + text, strlen(text), dbl, flt); + } + tracepoint(ust_tests_demo, done, 456); + tracepoint(ust_tests_demo3, done, 42); + fprintf(stderr, " done.\n"); + return 0; +} diff --git a/doc/examples/demo/tp.c b/doc/examples/demo/tp.c new file mode 100644 index 0000000..8e44db4 --- /dev/null +++ b/doc/examples/demo/tp.c @@ -0,0 +1,26 @@ +/* + * tp.c + * + * Copyright (c) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_demo.h" diff --git a/doc/examples/demo/tp2.c b/doc/examples/demo/tp2.c new file mode 100644 index 0000000..ba45c23 --- /dev/null +++ b/doc/examples/demo/tp2.c @@ -0,0 +1,26 @@ +/* + * tp2.c + * + * Copyright (c) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_demo2.h" diff --git a/doc/examples/demo/tp3.c b/doc/examples/demo/tp3.c new file mode 100644 index 0000000..5f97651 --- /dev/null +++ b/doc/examples/demo/tp3.c @@ -0,0 +1,26 @@ +/* + * tp3.c + * + * Copyright (c) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_demo3.h" diff --git a/doc/examples/demo/ust_tests_demo.h b/doc/examples/demo/ust_tests_demo.h new file mode 100644 index 0000000..b27d539 --- /dev/null +++ b/doc/examples/demo/ust_tests_demo.h @@ -0,0 +1,71 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +TRACEPOINT_EVENT(ust_tests_demo, starting, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo, starting, TRACE_CRIT) + +/* + * Dummy model information, just for example. TODO: we should check if + * EMF model URI have some standard format we should follow. + */ +TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, starting, + "http://example.com/path_to_model?q=ust_tests_demo:starting") + +TRACEPOINT_EVENT(ust_tests_demo, done, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo, done, TRACE_CRIT) + +TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, done, + "http://example.com/path_to_model?q=ust_tests_demo:done") + +#endif /* _TRACEPOINT_UST_TESTS_DEMO_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_demo.h" + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/doc/examples/demo/ust_tests_demo2.h b/doc/examples/demo/ust_tests_demo2.h new file mode 100644 index 0000000..25d42ad --- /dev/null +++ b/doc/examples/demo/ust_tests_demo2.h @@ -0,0 +1,68 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo2 + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO2_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +TRACEPOINT_EVENT(ust_tests_demo2, loop, + TP_ARGS(int, anint, int, netint, long *, values, + char *, text, size_t, textlen, + double, doublearg, float, floatarg), + TP_FIELDS( + ctf_integer(int, intfield, anint) + ctf_integer_hex(int, intfield2, anint) + ctf_integer(long, longfield, anint) + ctf_integer_network(int, netintfield, netint) + ctf_integer_network_hex(int, netintfieldhex, netint) + ctf_array(long, arrfield1, values, 3) + ctf_array_text(char, arrfield2, text, 10) + ctf_sequence(char, seqfield1, text, + size_t, textlen) + ctf_sequence_text(char, seqfield2, text, + size_t, textlen) + ctf_string(stringfield, text) + ctf_float(float, floatfield, floatarg) + ctf_float(double, doublefield, doublearg) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo2, loop, TRACE_WARNING) + +#endif /* _TRACEPOINT_UST_TESTS_DEMO2_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_demo2.h" + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/doc/examples/demo/ust_tests_demo3.h b/doc/examples/demo/ust_tests_demo3.h new file mode 100644 index 0000000..c7b63dd --- /dev/null +++ b/doc/examples/demo/ust_tests_demo3.h @@ -0,0 +1,53 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo3 + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO3_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO3_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +TRACEPOINT_EVENT(ust_tests_demo3, done, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo3, done, TRACE_WARNING) + +#endif /* _TRACEPOINT_UST_TESTS_DEMO3_H */ + +#undef TRACEPOINT_INCLUDE +#define TRACEPOINT_INCLUDE "./ust_tests_demo3.h" + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/doc/man/lttng-ust.3 b/doc/man/lttng-ust.3 index 7cc3bfd..da3976d 100644 --- a/doc/man/lttng-ust.3 +++ b/doc/man/lttng-ust.3 @@ -283,7 +283,7 @@ carefully: needed. Another way is to dlopen the tracepoint probe when needed by the application. - Example: - - tests/demo/ demo.c tp*.c ust_tests_demo*.h demo-trace + - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace - Note about dlclose() usage: it is not safe to use dlclose on a provider shared object that is being actively used for tracing due @@ -365,7 +365,7 @@ lttng-gen-tp(1), lttng(1), babeltrace(1), lttng-sessiond(8) .SH "BUGS" .PP -No knows bugs at this point. +No known bugs at this point. If you encounter any issues or usability problem, please report it on our mailing list to help improve this -- 1.8.2 From mathieu.desnoyers at efficios.com Thu Mar 28 09:50:40 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Thu, 28 Mar 2013 09:50:40 -0400 Subject: [lttng-dev] [PATCH lttng-ust] Add demo test back as an example In-Reply-To: <1364443511-5091-1-git-send-email-jeremie.galarneau@efficios.com> References: <1364443511-5091-1-git-send-email-jeremie.galarneau@efficios.com> Message-ID: <20130328135040.GA29485@Krystal> * J?r?mie Galarneau (jeremie.galarneau at efficios.com) wrote: > Updated the lttng-ust man page to point to doc/examples/demo instead > of the now moved /tests/demo. Merged, thanks! I added demo to doc/examples/Makefile.am too. Moreover, do we need "hello" under tests ? Why not move it under doc/examples ? Also, we'd need to add capability to build examples within the tree from automake. e.g. make examples from lttng-ust root. (or with just a simple "make" or "make check" maybe ?) Thanks, Mathieu > > Minor typo fix. > > Signed-off-by: J?r?mie Galarneau > --- > doc/examples/demo/Makefile | 42 ++++++++++++++++++++++ > doc/examples/demo/README | 27 ++++++++++++++ > doc/examples/demo/demo-trace | 6 ++++ > doc/examples/demo/demo.c | 65 +++++++++++++++++++++++++++++++++ > doc/examples/demo/tp.c | 26 ++++++++++++++ > doc/examples/demo/tp2.c | 26 ++++++++++++++ > doc/examples/demo/tp3.c | 26 ++++++++++++++ > doc/examples/demo/ust_tests_demo.h | 71 +++++++++++++++++++++++++++++++++++++ > doc/examples/demo/ust_tests_demo2.h | 68 +++++++++++++++++++++++++++++++++++ > doc/examples/demo/ust_tests_demo3.h | 53 +++++++++++++++++++++++++++ > doc/man/lttng-ust.3 | 4 +-- > 11 files changed, 412 insertions(+), 2 deletions(-) > create mode 100644 doc/examples/demo/Makefile > create mode 100644 doc/examples/demo/README > create mode 100755 doc/examples/demo/demo-trace > create mode 100644 doc/examples/demo/demo.c > create mode 100644 doc/examples/demo/tp.c > create mode 100644 doc/examples/demo/tp2.c > create mode 100644 doc/examples/demo/tp3.c > create mode 100644 doc/examples/demo/ust_tests_demo.h > create mode 100644 doc/examples/demo/ust_tests_demo2.h > create mode 100644 doc/examples/demo/ust_tests_demo3.h > > diff --git a/doc/examples/demo/Makefile b/doc/examples/demo/Makefile > new file mode 100644 > index 0000000..41f4321 > --- /dev/null > +++ b/doc/examples/demo/Makefile > @@ -0,0 +1,42 @@ > +# Copyright (C) 2013 J?r?mie Galarneau > +# > +# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED > +# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. > +# > +# Permission is hereby granted to use or copy this program for any > +# purpose, provided the above notices are retained on all copies. > +# Permission to modify the code and to distribute modified code is > +# granted, provided the above notices are retained, and a notice that > +# the code was modified is included with the above copyright notice. > + > +# This Makefile is not using automake so that people may see how to build > +# a program and tracepoint provider probes as stand-alone shared objects. > + > +CC = gcc > +LIBS = -ldl # On Linux > +#LIBS = -lc # On BSD > +CFLAGS = -I. > + > +all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so > + > +lttng-ust-provider-ust-tests-demo.o: tp.c tp2.c ust_tests_demo.h ust_tests_demo2.h > + $(CC) $(CFLAGS) -fpic -c -o $@ $< > + > +lttng-ust-provider-ust-tests-demo.so: lttng-ust-provider-ust-tests-demo.o > + $(CC) -shared -o $@ -llttng-ust $< > + > +lttng-ust-provider-ust-tests-demo3.o: tp3.c ust_tests_demo3.h > + $(CC) $(CFLAGS) -fpic -c -o $@ $< > + > +lttng-ust-provider-ust-tests-demo3.so: lttng-ust-provider-ust-tests-demo3.o > + $(CC) -shared -o $@ -llttng-ust $< > + > +demo.o: demo.c > + $(CC) $(CFLAGS) -c -o $@ $< > + > +demo: demo.o > + $(CC) demo.o -o $@ $(LIBS) > + > +.PHONY: clean > +clean: > + rm -f *.o *.so demo > diff --git a/doc/examples/demo/README b/doc/examples/demo/README > new file mode 100644 > index 0000000..03ee4ee > --- /dev/null > +++ b/doc/examples/demo/README > @@ -0,0 +1,27 @@ > +This is a demo application used to test the LTTng userspace tracer. > + > +demo-trace shell script preloads the provider shared objects before > +executing the demo. Executing "demo" without the shell wrapper will not > +provide any tracing support. This ensures the demo binary can be > +distributed on distros without depending on having liblttng-ust.so in > +place. Note: the "demo" program must be compiled with "-ldl" on Linux, > +with "-lc" on BSD. > + > +The simplest command to trace the demo program are: > +lttng create > +lttng enable-event -u -a > +lttng start > +./demo-trace > +lttng destroy > + > +That will create a trace in your $HOME/lttng-traces directory. > + > +The resulting babeltrace output should look like this: > +[554297567999315] ust_tests_demo:starting: { 1 }, { value = 123 } > +[554297568020834] ust_tests_demo2:loop: { 1 }, { intfield = 0, intfield2 = 0x0, longfield = 0, netintfield = 0, netintfieldhex = 0x0, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } > +[554297568024780] ust_tests_demo2:loop: { 1 }, { intfield = 1, intfield2 = 0x1, longfield = 1, netintfield = 1, netintfieldhex = 0x1, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } > +[554297568027050] ust_tests_demo2:loop: { 1 }, { intfield = 2, intfield2 = 0x2, longfield = 2, netintfield = 2, netintfieldhex = 0x2, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } > +[554297568029014] ust_tests_demo2:loop: { 1 }, { intfield = 3, intfield2 = 0x3, longfield = 3, netintfield = 3, netintfieldhex = 0x3, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } > +[554297568030861] ust_tests_demo2:loop: { 1 }, { intfield = 4, intfield2 = 0x4, longfield = 4, netintfield = 4, netintfieldhex = 0x4, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222, doublefield = 2 } > +[554297568033138] ust_tests_demo:done: { 1 }, { value = 456 } > +[554297568034533] ust_tests_demo3:done: { 1 }, { value = 42 } > diff --git a/doc/examples/demo/demo-trace b/doc/examples/demo/demo-trace > new file mode 100755 > index 0000000..dd67727 > --- /dev/null > +++ b/doc/examples/demo/demo-trace > @@ -0,0 +1,6 @@ > +#!/bin/sh > + > +DIR=$(dirname $0) > +DIR=$(readlink -f $DIR) > + > +LD_PRELOAD=$DIR/lttng-ust-provider-ust-tests-demo.so:$DIR/lttng-ust-provider-ust-tests-demo3.so $DIR/demo ${*} > diff --git a/doc/examples/demo/demo.c b/doc/examples/demo/demo.c > new file mode 100644 > index 0000000..e2b61c2 > --- /dev/null > +++ b/doc/examples/demo/demo.c > @@ -0,0 +1,65 @@ > +/* > + * Copyright (C) 2009 Pierre-Marc Fournier > + * Copyright (C) 2011 Mathieu Desnoyers > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; version 2.1 of > + * the License. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define TRACEPOINT_DEFINE > +#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE > +#include "ust_tests_demo.h" > +#include "ust_tests_demo2.h" > +#include "ust_tests_demo3.h" > + > +int main(int argc, char **argv) > +{ > + int i, netint; > + long values[] = { 1, 2, 3 }; > + char text[10] = "test"; > + double dbl = 2.0; > + float flt = 2222.0; > + int delay = 0; > + > + if (argc == 2) > + delay = atoi(argv[1]); > + > + fprintf(stderr, "Demo program starting.\n"); > + > + sleep(delay); > + > + fprintf(stderr, "Tracing... "); > + tracepoint(ust_tests_demo, starting, 123); > + for (i = 0; i < 5; i++) { > + netint = htonl(i); > + tracepoint(ust_tests_demo2, loop, i, netint, values, > + text, strlen(text), dbl, flt); > + } > + tracepoint(ust_tests_demo, done, 456); > + tracepoint(ust_tests_demo3, done, 42); > + fprintf(stderr, " done.\n"); > + return 0; > +} > diff --git a/doc/examples/demo/tp.c b/doc/examples/demo/tp.c > new file mode 100644 > index 0000000..8e44db4 > --- /dev/null > +++ b/doc/examples/demo/tp.c > @@ -0,0 +1,26 @@ > +/* > + * tp.c > + * > + * Copyright (c) 2011 Mathieu Desnoyers > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE > + * SOFTWARE. > + */ > + > +#define TRACEPOINT_CREATE_PROBES > +#include "ust_tests_demo.h" > diff --git a/doc/examples/demo/tp2.c b/doc/examples/demo/tp2.c > new file mode 100644 > index 0000000..ba45c23 > --- /dev/null > +++ b/doc/examples/demo/tp2.c > @@ -0,0 +1,26 @@ > +/* > + * tp2.c > + * > + * Copyright (c) 2011 Mathieu Desnoyers > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE > + * SOFTWARE. > + */ > + > +#define TRACEPOINT_CREATE_PROBES > +#include "ust_tests_demo2.h" > diff --git a/doc/examples/demo/tp3.c b/doc/examples/demo/tp3.c > new file mode 100644 > index 0000000..5f97651 > --- /dev/null > +++ b/doc/examples/demo/tp3.c > @@ -0,0 +1,26 @@ > +/* > + * tp3.c > + * > + * Copyright (c) 2011 Mathieu Desnoyers > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE > + * SOFTWARE. > + */ > + > +#define TRACEPOINT_CREATE_PROBES > +#include "ust_tests_demo3.h" > diff --git a/doc/examples/demo/ust_tests_demo.h b/doc/examples/demo/ust_tests_demo.h > new file mode 100644 > index 0000000..b27d539 > --- /dev/null > +++ b/doc/examples/demo/ust_tests_demo.h > @@ -0,0 +1,71 @@ > +#undef TRACEPOINT_PROVIDER > +#define TRACEPOINT_PROVIDER ust_tests_demo > + > +#if !defined(_TRACEPOINT_UST_TESTS_DEMO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) > +#define _TRACEPOINT_UST_TESTS_DEMO_H > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +/* > + * Copyright (C) 2011 Mathieu Desnoyers > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE > + * SOFTWARE. > + */ > + > +#include > + > +TRACEPOINT_EVENT(ust_tests_demo, starting, > + TP_ARGS(int, value), > + TP_FIELDS( > + ctf_integer(int, value, value) > + ) > +) > +TRACEPOINT_LOGLEVEL(ust_tests_demo, starting, TRACE_CRIT) > + > +/* > + * Dummy model information, just for example. TODO: we should check if > + * EMF model URI have some standard format we should follow. > + */ > +TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, starting, > + "http://example.com/path_to_model?q=ust_tests_demo:starting") > + > +TRACEPOINT_EVENT(ust_tests_demo, done, > + TP_ARGS(int, value), > + TP_FIELDS( > + ctf_integer(int, value, value) > + ) > +) > +TRACEPOINT_LOGLEVEL(ust_tests_demo, done, TRACE_CRIT) > + > +TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, done, > + "http://example.com/path_to_model?q=ust_tests_demo:done") > + > +#endif /* _TRACEPOINT_UST_TESTS_DEMO_H */ > + > +#undef TRACEPOINT_INCLUDE > +#define TRACEPOINT_INCLUDE "./ust_tests_demo.h" > + > +/* This part must be outside ifdef protection */ > +#include > + > +#ifdef __cplusplus > +} > +#endif > diff --git a/doc/examples/demo/ust_tests_demo2.h b/doc/examples/demo/ust_tests_demo2.h > new file mode 100644 > index 0000000..25d42ad > --- /dev/null > +++ b/doc/examples/demo/ust_tests_demo2.h > @@ -0,0 +1,68 @@ > +#undef TRACEPOINT_PROVIDER > +#define TRACEPOINT_PROVIDER ust_tests_demo2 > + > +#if !defined(_TRACEPOINT_UST_TESTS_DEMO2_H) || defined(TRACEPOINT_HEADER_MULTI_READ) > +#define _TRACEPOINT_UST_TESTS_DEMO2_H > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +/* > + * Copyright (C) 2011 Mathieu Desnoyers > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE > + * SOFTWARE. > + */ > + > +#include > + > +TRACEPOINT_EVENT(ust_tests_demo2, loop, > + TP_ARGS(int, anint, int, netint, long *, values, > + char *, text, size_t, textlen, > + double, doublearg, float, floatarg), > + TP_FIELDS( > + ctf_integer(int, intfield, anint) > + ctf_integer_hex(int, intfield2, anint) > + ctf_integer(long, longfield, anint) > + ctf_integer_network(int, netintfield, netint) > + ctf_integer_network_hex(int, netintfieldhex, netint) > + ctf_array(long, arrfield1, values, 3) > + ctf_array_text(char, arrfield2, text, 10) > + ctf_sequence(char, seqfield1, text, > + size_t, textlen) > + ctf_sequence_text(char, seqfield2, text, > + size_t, textlen) > + ctf_string(stringfield, text) > + ctf_float(float, floatfield, floatarg) > + ctf_float(double, doublefield, doublearg) > + ) > +) > +TRACEPOINT_LOGLEVEL(ust_tests_demo2, loop, TRACE_WARNING) > + > +#endif /* _TRACEPOINT_UST_TESTS_DEMO2_H */ > + > +#undef TRACEPOINT_INCLUDE > +#define TRACEPOINT_INCLUDE "./ust_tests_demo2.h" > + > +/* This part must be outside ifdef protection */ > +#include > + > +#ifdef __cplusplus > +} > +#endif > diff --git a/doc/examples/demo/ust_tests_demo3.h b/doc/examples/demo/ust_tests_demo3.h > new file mode 100644 > index 0000000..c7b63dd > --- /dev/null > +++ b/doc/examples/demo/ust_tests_demo3.h > @@ -0,0 +1,53 @@ > +#undef TRACEPOINT_PROVIDER > +#define TRACEPOINT_PROVIDER ust_tests_demo3 > + > +#if !defined(_TRACEPOINT_UST_TESTS_DEMO3_H) || defined(TRACEPOINT_HEADER_MULTI_READ) > +#define _TRACEPOINT_UST_TESTS_DEMO3_H > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +/* > + * Copyright (C) 2011 Mathieu Desnoyers > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE > + * SOFTWARE. > + */ > + > +#include > + > +TRACEPOINT_EVENT(ust_tests_demo3, done, > + TP_ARGS(int, value), > + TP_FIELDS( > + ctf_integer(int, value, value) > + ) > +) > +TRACEPOINT_LOGLEVEL(ust_tests_demo3, done, TRACE_WARNING) > + > +#endif /* _TRACEPOINT_UST_TESTS_DEMO3_H */ > + > +#undef TRACEPOINT_INCLUDE > +#define TRACEPOINT_INCLUDE "./ust_tests_demo3.h" > + > +/* This part must be outside ifdef protection */ > +#include > + > +#ifdef __cplusplus > +} > +#endif > diff --git a/doc/man/lttng-ust.3 b/doc/man/lttng-ust.3 > index 7cc3bfd..da3976d 100644 > --- a/doc/man/lttng-ust.3 > +++ b/doc/man/lttng-ust.3 > @@ -283,7 +283,7 @@ carefully: > needed. Another way is to dlopen the tracepoint probe when needed > by the application. > - Example: > - - tests/demo/ demo.c tp*.c ust_tests_demo*.h demo-trace > + - doc/examples/demo demo.c tp*.c ust_tests_demo*.h demo-trace > > - Note about dlclose() usage: it is not safe to use dlclose on a > provider shared object that is being actively used for tracing due > @@ -365,7 +365,7 @@ lttng-gen-tp(1), lttng(1), babeltrace(1), lttng-sessiond(8) > .SH "BUGS" > > .PP > -No knows bugs at this point. > +No known bugs at this point. > > If you encounter any issues or usability problem, please report it on > our mailing list to help improve this > -- > 1.8.2 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From matthew.khouzam at ericsson.com Thu Mar 28 11:03:24 2013 From: matthew.khouzam at ericsson.com (Matthew Khouzam) Date: Thu, 28 Mar 2013 11:03:24 -0400 Subject: [lttng-dev] On git and mail requests Message-ID: <51545BBC.4090701@ericsson.com> Hello tracing sorcerers, I was having a harder and harder time reading the mailing list's discussions. I have a filter to hide "patches" in my mail client. I think though it would be interesting maybe to use redmine's code review system and keep the mailing list for support? That way we can see the user issues more easily? Any thoughts? Matthew From jeremie.galarneau at efficios.com Thu Mar 28 11:12:19 2013 From: jeremie.galarneau at efficios.com (=?ISO-8859-1?Q?J=E9r=E9mie_Galarneau?=) Date: Thu, 28 Mar 2013 11:12:19 -0400 Subject: [lttng-dev] On git and mail requests In-Reply-To: <51545BBC.4090701@ericsson.com> References: <51545BBC.4090701@ericsson.com> Message-ID: I know some projects use separate dev and user mailing lists. Perhaps we could follow this route. J?r?mie On Thu, Mar 28, 2013 at 11:03 AM, Matthew Khouzam wrote: > Hello tracing sorcerers, > > I was having a harder and harder time reading the mailing list's > discussions. I have a filter to hide "patches" in my mail client. I > think though it would be interesting maybe to use redmine's code review > system and keep the mailing list for support? That way we can see the > user issues more easily? > > Any thoughts? > Matthew > > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- J?r?mie Galarneau EfficiOS Inc. http://www.efficios.com From yannick.brosseau at gmail.com Thu Mar 28 11:25:25 2013 From: yannick.brosseau at gmail.com (Yannick Brosseau) Date: Thu, 28 Mar 2013 11:25:25 -0400 Subject: [lttng-dev] On git and mail requests In-Reply-To: References: <51545BBC.4090701@ericsson.com> Message-ID: <515460E5.6090308@gmail.com> I don't think we have enough traffic to justify 2 mailing list. Yannick On 2013-03-28 11:12, J?r?mie Galarneau wrote: > I know some projects use separate dev and user mailing lists. Perhaps > we could follow this route. > > J?r?mie > > On Thu, Mar 28, 2013 at 11:03 AM, Matthew Khouzam > wrote: >> Hello tracing sorcerers, >> >> I was having a harder and harder time reading the mailing list's >> discussions. I have a filter to hide "patches" in my mail client. I >> think though it would be interesting maybe to use redmine's code review >> system and keep the mailing list for support? That way we can see the >> user issues more easily? >> >> Any thoughts? >> Matthew >> >> >> >> _______________________________________________ >> lttng-dev mailing list >> lttng-dev at lists.lttng.org >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > From matthew.khouzam at ericsson.com Thu Mar 28 11:47:26 2013 From: matthew.khouzam at ericsson.com (Matthew Khouzam) Date: Thu, 28 Mar 2013 11:47:26 -0400 Subject: [lttng-dev] On git and mail requests In-Reply-To: <515460E5.6090308@gmail.com> References: <51545BBC.4090701@ericsson.com> <515460E5.6090308@gmail.com> Message-ID: <5154660E.4070603@ericsson.com> So to conclude from the discussion on IRC. It is being considered but redmine's code review system is not good enough yet. Glad it was thought out. btw, if anyone else is having the issue, filter on the word "PATCH" in the header, the mailing list becomes much cleaner. :) On 13-03-28 11:25 AM, Yannick Brosseau wrote: > I don't think we have enough traffic to justify 2 mailing list. > > Yannick > > On 2013-03-28 11:12, J?r?mie Galarneau wrote: >> I know some projects use separate dev and user mailing lists. Perhaps >> we could follow this route. >> >> J?r?mie >> >> On Thu, Mar 28, 2013 at 11:03 AM, Matthew Khouzam >> wrote: >>> Hello tracing sorcerers, >>> >>> I was having a harder and harder time reading the mailing list's >>> discussions. I have a filter to hide "patches" in my mail client. I >>> think though it would be interesting maybe to use redmine's code review >>> system and keep the mailing list for support? That way we can see the >>> user issues more easily? >>> >>> Any thoughts? >>> Matthew >>> >>> >>> >>> _______________________________________________ >>> lttng-dev mailing list >>> lttng-dev at lists.lttng.org >>> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev >> > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From simon.marchi at polymtl.ca Thu Mar 28 12:03:01 2013 From: simon.marchi at polymtl.ca (Simon Marchi) Date: Thu, 28 Mar 2013 12:03:01 -0400 Subject: [lttng-dev] On git and mail requests In-Reply-To: References: <51545BBC.4090701@ericsson.com> Message-ID: I think the point is that having patches in emails is not very convenient. Given the quality of web based tools available today, I think it would be relevant that the LTTng project adopt one of them. With the current system: - it is hard to see what the resulting code is. You juste have a blob of + and -, and it is very hard to see what the code looks in the end. Web based code review tools allow you to quickly see the modifications as part of the complete file, with nice colors and other visual aids. - It is hard to follow the sequence of comments. With a web based tool, all discussions related to a topic are clearly laid out. - It is hard to follow the evolution of a patch (differences between patch versions) - Sometimes patches on the list fall into cracks and are never replied to. Code review has proven to be very useful to maintain code quality and avoid bugs. It might be only me, but the current system doesn't encourage me to go look at other people's code and comment, because it is hard to do so. Simon On 28 March 2013 11:12, J?r?mie Galarneau wrote: > I know some projects use separate dev and user mailing lists. Perhaps > we could follow this route. > > J?r?mie > > On Thu, Mar 28, 2013 at 11:03 AM, Matthew Khouzam > wrote: >> Hello tracing sorcerers, >> >> I was having a harder and harder time reading the mailing list's >> discussions. I have a filter to hide "patches" in my mail client. I >> think though it would be interesting maybe to use redmine's code review >> system and keep the mailing list for support? That way we can see the >> user issues more easily? >> >> Any thoughts? >> Matthew >> >> >> >> _______________________________________________ >> lttng-dev mailing list >> lttng-dev at lists.lttng.org >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > > > > -- > J?r?mie Galarneau > EfficiOS Inc. > http://www.efficios.com > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From yannick.brosseau at gmail.com Thu Mar 28 12:06:25 2013 From: yannick.brosseau at gmail.com (Yannick Brosseau) Date: Thu, 28 Mar 2013 12:06:25 -0400 Subject: [lttng-dev] On git and mail requests In-Reply-To: References: <51545BBC.4090701@ericsson.com> Message-ID: <51546A81.7000403@gmail.com> On 2013-03-28 12:03, Simon Marchi wrote: > I think the point is that having patches in emails is not very > convenient. Given the quality of web based tools available today, I > think it would be relevant that the LTTng project adopt one of them. > > With the current system: > - it is hard to see what the resulting code is. You juste have a blob > of + and -, and it is very hard to see what the code looks in the > end. Web based code review tools allow you to quickly see the > modifications as part of the complete file, with nice colors and other > visual aids. > - It is hard to follow the sequence of comments. With a web based > tool, all discussions related to a topic are clearly laid out. > - It is hard to follow the evolution of a patch (differences between > patch versions) > - Sometimes patches on the list fall into cracks and are never replied to. > > Is there any of the available code review tools that can work offline? From simon.marchi at polymtl.ca Thu Mar 28 12:14:43 2013 From: simon.marchi at polymtl.ca (Simon Marchi) Date: Thu, 28 Mar 2013 12:14:43 -0400 Subject: [lttng-dev] On git and mail requests In-Reply-To: <51546A81.7000403@gmail.com> References: <51545BBC.4090701@ericsson.com> <51546A81.7000403@gmail.com> Message-ID: Not that I know. But for example, with Gerrit, you could probably fetch all the changesets you were asked to review to your git tree before boarding your plane to Australia and at least read them. You would still have to enter your comments when you get back online. Do you happen to work offline often ? Is this really important ? On 28 March 2013 12:06, Yannick Brosseau wrote: > On 2013-03-28 12:03, Simon Marchi wrote: >> I think the point is that having patches in emails is not very >> convenient. Given the quality of web based tools available today, I >> think it would be relevant that the LTTng project adopt one of them. >> >> With the current system: >> - it is hard to see what the resulting code is. You juste have a blob >> of + and -, and it is very hard to see what the code looks in the >> end. Web based code review tools allow you to quickly see the >> modifications as part of the complete file, with nice colors and other >> visual aids. >> - It is hard to follow the sequence of comments. With a web based >> tool, all discussions related to a topic are clearly laid out. >> - It is hard to follow the evolution of a patch (differences between >> patch versions) >> - Sometimes patches on the list fall into cracks and are never replied to. >> >> > Is there any of the available code review tools that can work offline? > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From raphael.beamonte at polymtl.ca Thu Mar 28 12:27:56 2013 From: raphael.beamonte at polymtl.ca (=?ISO-8859-1?Q?Rapha=EBl_Beamonte?=) Date: Thu, 28 Mar 2013 12:27:56 -0400 Subject: [lttng-dev] On git and mail requests In-Reply-To: References: <51545BBC.4090701@ericsson.com> <51546A81.7000403@gmail.com> Message-ID: 2013/3/28 Simon Marchi > Not that I know. But for example, with Gerrit, you could probably > fetch all the changesets you were asked to review to your git tree > before boarding your plane to Australia and at least read them. You > would still have to enter your comments when you get back online. > > Do you happen to work offline often ? Is this really important ? > For what it's worth, I like the current e-mail based patching system. Using another tool would just conduct me to have to : 1/ Follow online if there isn't any way to get the information by email 2/ Subscribe to the "send me all the info by email" if it exists 3/ Have to connect (and login?) to the website to answer if necessary, so taking more time to do it than now if there isn't any "reply directly by email" system 4/ Answer by email if it's possible So, in the best situation, I'll do exactly as I do right now. In the worst condition... I'll not be able to continue following what happens on the lttng world as I'll never think about giving a look at a website. I like the way the information comes to me, I'd not like to have to search for the information. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthew.khouzam at ericsson.com Thu Mar 28 14:34:40 2013 From: matthew.khouzam at ericsson.com (Matthew Khouzam) Date: Thu, 28 Mar 2013 14:34:40 -0400 Subject: [lttng-dev] On git and mail requests In-Reply-To: <51546A81.7000403@gmail.com> References: <51545BBC.4090701@ericsson.com> <51546A81.7000403@gmail.com> Message-ID: <51548D40.3020805@ericsson.com> R4E works offline and I can hook you up with the devs. I think you don't want online only but that you can "sync" then review on the run. Here's the recently edited, soon to be reverted list of software from wiki. http://en.wikipedia.org/wiki/List_of_tools_for_code_review On 13-03-28 12:06 PM, Yannick Brosseau wrote: > On 2013-03-28 12:03, Simon Marchi wrote: >> I think the point is that having patches in emails is not very >> convenient. Given the quality of web based tools available today, I >> think it would be relevant that the LTTng project adopt one of them. >> >> With the current system: >> - it is hard to see what the resulting code is. You juste have a blob >> of + and -, and it is very hard to see what the code looks in the >> end. Web based code review tools allow you to quickly see the >> modifications as part of the complete file, with nice colors and other >> visual aids. >> - It is hard to follow the sequence of comments. With a web based >> tool, all discussions related to a topic are clearly laid out. >> - It is hard to follow the evolution of a patch (differences between >> patch versions) >> - Sometimes patches on the list fall into cracks and are never replied to. >> >> > Is there any of the available code review tools that can work offline? > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev From mathieu.desnoyers at efficios.com Thu Mar 28 15:54:12 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Thu, 28 Mar 2013 15:54:12 -0400 Subject: [lttng-dev] [lttng-tools PATCH] Fix: don't keep vpid, procname, nor patchlevel environment for per-uid buffers Message-ID: <20130328195412.GA1311@Krystal> Signed-off-by: Mathieu Desnoyers --- diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index fdcad1c..221aa97 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1499,7 +1499,9 @@ static int setup_buffer_reg_pid(struct ust_app_session *ua_sess, ret = ust_registry_session_init(®_pid->registry->reg.ust, app, app->bits_per_long, app->uint8_t_alignment, app->uint16_t_alignment, app->uint32_t_alignment, - app->uint64_t_alignment, app->long_alignment, app->byte_order); + app->uint64_t_alignment, app->long_alignment, + app->byte_order, app->version.major, + app->version.minor); if (ret < 0) { goto error; } @@ -1550,10 +1552,12 @@ static int setup_buffer_reg_uid(struct ltt_ust_session *usess, } /* Initialize registry. */ - ret = ust_registry_session_init(®_uid->registry->reg.ust, app, + ret = ust_registry_session_init(®_uid->registry->reg.ust, NULL, app->bits_per_long, app->uint8_t_alignment, app->uint16_t_alignment, app->uint32_t_alignment, - app->uint64_t_alignment, app->long_alignment, app->byte_order); + app->uint64_t_alignment, app->long_alignment, + app->byte_order, app->version.major, + app->version.minor); if (ret < 0) { goto error; } diff --git a/src/bin/lttng-sessiond/ust-metadata.c b/src/bin/lttng-sessiond/ust-metadata.c index 2735169..b0f83d2 100644 --- a/src/bin/lttng-sessiond/ust-metadata.c +++ b/src/bin/lttng-sessiond/ust-metadata.c @@ -520,7 +520,9 @@ uint64_t measure_clock_offset(void) * Should be called with session registry mutex held. */ int ust_metadata_session_statedump(struct ust_registry_session *session, - struct ust_app *app) + struct ust_app *app, + uint32_t major, + uint32_t minor) { unsigned char *uuid_c; char uuid_s[UUID_STR_LEN], @@ -529,7 +531,6 @@ int ust_metadata_session_statedump(struct ust_registry_session *session, char hostname[HOST_NAME_MAX]; assert(session); - assert(app); uuid_c = session->uuid; @@ -585,12 +586,10 @@ int ust_metadata_session_statedump(struct ust_registry_session *session, " domain = \"ust\";\n" " tracer_name = \"lttng-ust\";\n" " tracer_major = %u;\n" - " tracer_minor = %u;\n" - " tracer_patchlevel = %u;\n", + " tracer_minor = %u;\n", hostname, - app->version.major, - app->version.minor, - app->version.patchlevel + major, + minor ); if (ret) goto end; @@ -601,8 +600,10 @@ int ust_metadata_session_statedump(struct ust_registry_session *session, */ if (app) { ret = lttng_metadata_printf(session, + " tracer_patchlevel = %u;\n" " vpid = %d;\n" " procname = \"%s\";\n", + app->version.patchlevel, (int) app->pid, app->name ); diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c index 19cff09..6c483e4 100644 --- a/src/bin/lttng-sessiond/ust-registry.c +++ b/src/bin/lttng-sessiond/ust-registry.c @@ -452,13 +452,14 @@ int ust_registry_session_init(struct ust_registry_session **sessionp, uint32_t uint32_t_alignment, uint32_t uint64_t_alignment, uint32_t long_alignment, - int byte_order) + int byte_order, + uint32_t major, + uint32_t minor) { int ret; struct ust_registry_session *session; assert(sessionp); - assert(app); session = zmalloc(sizeof(*session)); if (!session) { @@ -487,7 +488,7 @@ int ust_registry_session_init(struct ust_registry_session **sessionp, } pthread_mutex_lock(&session->lock); - ret = ust_metadata_session_statedump(session, app); + ret = ust_metadata_session_statedump(session, app, major, minor); pthread_mutex_unlock(&session->lock); if (ret) { ERR("Failed to generate session metadata (errno = %d)", ret); diff --git a/src/bin/lttng-sessiond/ust-registry.h b/src/bin/lttng-sessiond/ust-registry.h index 1500f74..3cd474b 100644 --- a/src/bin/lttng-sessiond/ust-registry.h +++ b/src/bin/lttng-sessiond/ust-registry.h @@ -216,7 +216,9 @@ int ust_registry_session_init(struct ust_registry_session **sessionp, uint32_t uint32_t_alignment, uint32_t uint64_t_alignment, uint32_t long_alignment, - int byte_order); + int byte_order, + uint32_t major, + uint32_t minor); void ust_registry_session_destroy(struct ust_registry_session *session); int ust_registry_create_event(struct ust_registry_session *session, @@ -230,7 +232,7 @@ void ust_registry_destroy_event(struct ust_registry_channel *chan, /* app can be NULL for registry shared across applications. */ int ust_metadata_session_statedump(struct ust_registry_session *session, - struct ust_app *app); + struct ust_app *app, uint32_t major, uint32_t minor); int ust_metadata_channel_statedump(struct ust_registry_session *session, struct ust_registry_channel *chan); int ust_metadata_event_statedump(struct ust_registry_session *session, -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From mathieu.desnoyers at efficios.com Thu Mar 28 16:24:22 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Thu, 28 Mar 2013 16:24:22 -0400 Subject: [lttng-dev] [RELEASE] LTTng-UST 2.2.0-rc1 (Cuda) Message-ID: <20130328202422.GA1499@Krystal> LTTng-UST, the Linux Trace Toolkit Next Generation Userspace Tracer, is port of the low-overhead tracing capabilities of the LTTng kernel tracer to user-space. The library "liblttng-ust" enables tracing of applications and libraries. Major new features: - Per context filtering (vtid, vpid, procname) with e.g. --filter 'procname=="apache2"' - Buffers shared across applications with same user id e.g. lttng enable-channel -u mychan --buffers-uid - Implement --switch-timer and --read-timer options (periodical flush and RT-awareness). - Function entry/exit tracing (see lttng-ust-cyg-profile(3) manpage). Release name: Cuda Description (Cuda): Brewed at the Benelux microbrewery, this IPA has huge floral, citric and resinous hop aroma, simply an amazing nose. The flavor is very fresh with a light caramel malting touch completing a strong body. Huge amounts of hops, lots of grapefruit, lemon and oranges. This is an outstanding IPA! Changelog: 2013-03-28 lttng-ust 2.2.0-rc1 * Fix: tracepoint instrumentation constructor order issue * Documentation: update 2.0 to 2.x * Add demo test back as an example * Don't rely on explicit context for filtering * Implement per-context filtering * Fix: filter string comparison should check for literal * update tests/demo readme file * Add man page for lttng-ust-cyg-profile * Fix: filter string wildcard comparison * Fix: Remove test runner script * Fix: forwarding of call_site argument to field * Add demo README * Tests: Use Perl prove as the testsuite runner * Remove tests depending on consumerd * Convert hello.cxx test to a build test * Clean-up of configure.ac and tests/Makefile.am * Fix snprintf test and output result to TAP format * Replace same_line_marker test with same_line_tracepoint * Remove tests-libustinstr-malloc * Remove exit-fast test * Remove fork test * Remove daemon test * Remove demo test * Remove outdated test-nevents test * Remove outdated simple_include test * Remove outdated register_test test * Convert hello-static-lib test to a build test * Convert hello test to a build test only * Remove outdated libustctl_function_tests test * Remove outdated test hello2 * Remove outdated dlopen test * Remove outdated test basic long * Remove outdated test basic * cyg_profile: implement fast and verbose .so * Performance: add unlikely to tracepoint dynamic linking test * Fix: _LGPL_SOURCE rcu dereference fix * Implement liblttng-ust-cyg-profile function entry/exit instrumentation * Minor fix: libc wrapper internal run script * Fix: ustctl_recv_register_event pointer mixup * Fix: allow enabling same events for two channels * Add channel ID field to attr * Remove useless else clause * tracepoint: move "probe" test outside of loop * Fix uninitialized has_loglevel variable * Fix clang warnings * Cleanup: work-around clang unused result warning * Cleanup compile warning * Cleanup: remove unused variables * tracepoint: Don't add NULL probes * Remove mention of locking issues associated with dlopen usage * Implement read timer (for RT) * Only flush when there are readers active * Add mutex for channel wakeup fd update * Fix: fields should be initialized to NULL * Implement ustctl_duplicate_ust_object_data * Add channel wakeup fd to monitor close * Fix: refcount issue in lttng-ust-abi.c * Fix: only consumerd should print errors * Implement ring buffer periodic buffer switch timer * Fix: ensure all probe providers have their symbols * Reactivate error printing * Unregister tracepoint probes when not needed * Cleanup: remove now unused metadata code from UST * Fix: notification timeout logic * Fix: don't print error in comm proto connect on ENOENT * Fix: return expected error return values for sessiond * Fix: set wait/wake fd to -1 before close * Fix: Only notify socket should have timeout/nonblock * Fix: ustctl: return -EPIPE to sessiond if connection is closed * Fix: Add timeout on notification socket * Remove now unused metadata printf code * Move metadata creation into lttng-sessiond and lttng-consumed * Add write metadata API to ust-ctl.h * Move UST registry into sessiond and implement notifiers * Fix: don't flush-final for offset 0 if reader is on sub-buffer * Use tp rcu link test in provider * Remove direct dependency of probes on urcu-bp * Use urcu tls-compat.h * Lazy provider registration * Always use lttng_get_probe_list_head to get probe list * Fix static build * Move LTTng-UST buffer ownership from application to consumer * Fix package: don't distribute generated headers * Fix: don't cancel already exited threads * Scalability fix: tracepoint.c hash table size increase * Scalability fix for many events: event hash table size * Speed up probe registration for large amount of events * Add missing demo-trace shell script to dist tarball * Documentation: add uuid package name for Fedora in README * Fix: missing test for lttng_ust_comm_should_quit in lttng-ust-comm.c * Add compilation support for Tile architectures * Documentation: clarify debian package name for uuid in README * Fix: comment in ust-ctl.h * Fix I/O-related error values in ustctl * Introduce hash table for lttng_create_event_if_missing() * Fix: don't build C++ example if a C++ compiler isn't available * Remove LIBFORMAT output in configure. * Document dependency on libuuid Project website: http://lttng.org Download link: http://lttng.org/download (please refer to the README file for installation instructions) -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From dgoulet at efficios.com Thu Mar 28 16:35:04 2013 From: dgoulet at efficios.com (David Goulet) Date: Thu, 28 Mar 2013 16:35:04 -0400 Subject: [lttng-dev] [RELEASE] LTTng Tools 2.2.0-rc1 (Cuda) Message-ID: <5154A978.80708@efficios.com> Greetings everyone (including LTTng elves), The lttng-tools project provides a session daemon (lttng-sessiond) that acts as a tracing registry, the "lttng" command line for tracing control, a lttng-ctl library for tracing control and a lttng-relayd for network streaming. Introducing "Cuda", the 2.2.0-rc1 release. Use "lttng version" for a full description of the codename. We are now in feature freeze for 2.2 and this is the release candidate 1. Some bugs are still in the pipe in the bug tracker but the new features are now usable and ready for your precious testing! The following ChangeLog lists what was added in this version. 2013-03-28 lttng-tools 2.2.0-rc1 * Add UST per UID buffers support * UST metadata generation are created on the sessiond side * Move LTTng-UST buffer ownership from application to consumer * Add a UST registry of events and channel in the sessiond * UST periodical metadata flush * Refactor tests to use prove and tap * Support for trace file rotation for the relayd and on disk * Support per-context filtering * Add channel wakeup fd to monitor close * Deprecate enable/disable-consumer * Multiple fixes and memory leak fix. The major addition is the UST per UID buffers which can be used like this: $ lttng create $ lttng enable-channel chan1 -u --buffers-uid >From this point on, the session only support per UID channel. Per PID and per UID buffers can NOT coexist. $ lttng enable-event -a -u -c chan1 $ lttng start ... Every application sharing the same UID will use the same buffers. Furthermore, you can now set the attributes of the channel metadata. This is particularly useful with the periodical flush that was added for the metadata. For instance: $ lttng enable-channel metadata --switch-timer 200000 -u Also, the buffers for UST application are now created in the consumer and passed to the application. Thus, the buffer ownership has been transfered from the UST tracer to the consumer. Finally, the new feature worth noting is the trace file rotation. The -C and -W option are added to the enable-channel command and control the maximum size of trace files and the maximum number of them. See man lttng.1 for more details. Please feel free to email the list about any questions/comments concerning this release. For bugs or missing documentations, use bugs.lttng.org! Using it is testing it! Project website: http://lttng.org/lttng2.0 Download link: http://lttng.org/files/lttng-tools/lttng-tools-2.2.0-rc1.tar.bz2 (for the PGP signature, same file with .asc appended) Thanks to all! Cheers! David From mathieu.desnoyers at efficios.com Fri Mar 29 22:41:44 2013 From: mathieu.desnoyers at efficios.com (Mathieu Desnoyers) Date: Fri, 29 Mar 2013 22:41:44 -0400 Subject: [lttng-dev] [RELEASE] LTTng modules 2.2.0-rc1 Message-ID: <20130330024144.GA20642@Krystal> The LTTng modules provide Linux kernel tracing capability to the LTTng 2.2 tracer toolset. Noteworthy changes: - Many new subsystems are instrumented. Thanks to Mentor Graphics for the patches. Changelog: 2013-03-29 LTTng modules 2.2.0-rc1 * Update README * Fix: vmscan instrumentation build * writeback instrumentation: remove duplicated structures * block: update instrumentation to 3.9 rc kernel * rcu: update to 3.9 rc kernel instrumentation * workqueue instrumentation: remove duplicated structures * Rename odd event names * Introduce API to remap event names exposed by LTTng * lttng-module: sched.h: Fix compilation on 3.9 kernel * Fix Linux 3.8 btrfs probe warning * Fix Linux 3.8 ext4 probe support * Fix 3.8 kernel support: namespace lttng_is_signed_type() * Fix: don't flush-final for offset 0 if reader is on sub-buffer * instrumentation sched: add missing fork pid info * Fix check in lttng_strlen_user_inatomic * instrumentation: sync with Linux commit a1ce392 * Fix: statedump: missing locking, use lttng_iterate_fd * Implement lttng_iterate_fd wrapper * Instrumentation cleanup: kmem events should print hex pointers * Fix compilation of ext4 and btrfs tracepoints on 2.6.40 kernels * Fix: statedump hang/too early completion due to logic error * Fix: statedump hang due to incorrect wait/wakeup use * put_ulong calls in lib_ring_buffer_compat_ioctl() should be compat * wrapper/perf.h: Fix kernel version condition * Add new kernel probes instrumentation * Update kernel probes to more detailed match to kernel versions * Fix possible kernel build errors with linux-patches * Add missing MIT license text to 3 files under this license * Update sites using kernel version checking macro to new range * Make upper bound of kernel version checking macro exclusive * sock instrumentation: fix fields to get referenced values * ext3 instrumentation: fix of assignment code conversion * sched instrumentation: rename "pid" fields in sched_process_exec * Remove remaining semicolons in TP_fast_assign blocks * Fix compilation for 3.0 kernels that are named 2.6.40 * Fix compilation for 3.0 branch (>= 3.0.39) * Add kernel version checking macro * Remove semicolons in TP_fast_assign blocks * Add ifdefs to net probe to support Linux 2.6.39 * Add kernel probes for supplementary subsystems * Check if interrupt action name is not null in statedump * Fix exec instrumentation: only for kernels 3.4.0 and higher * Add TRACE_EVENT(sched_process_exec) to sched.h * lib/ringbuffer/frontend_api.h: Include linux/prefetch.h. * Fix warning with 3.6.0 kernel * ABI with support for compat 32/64 bits * Perform calculation on bit size in 64-bit * Use uint64_t for packet header content size and packet size * Fix: compat layer only on supported architectures * Fix ring buffer 32/64 bits compat * Fix cleanup: move lttng-tracer-core.h include to lib ringbuffer config.h * Fix ring_buffer_frontend.c: missing include lttng-tracer-core.h * Fix: statedump missing check for NULL namespace Project website: http://lttng.org Download link: http://lttng.org/download (please refer to the README files for installation instructions and lttng-tools doc/quickstart.txt for usage information) -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com From nashii at gmail.com Thu Mar 28 12:26:37 2013 From: nashii at gmail.com (=?ISO-8859-1?Q?Rapha=EBl_B=2E?=) Date: Thu, 28 Mar 2013 12:26:37 -0400 Subject: [lttng-dev] On git and mail requests In-Reply-To: References: <51545BBC.4090701@ericsson.com> <51546A81.7000403@gmail.com> Message-ID: 2013/3/28 Simon Marchi > Not that I know. But for example, with Gerrit, you could probably > fetch all the changesets you were asked to review to your git tree > before boarding your plane to Australia and at least read them. You > would still have to enter your comments when you get back online. > > Do you happen to work offline often ? Is this really important ? > For what it's worth, I like the current e-mail based patching system. Using another tool would just conduct me to have to : 1/ Follow online if there isn't any way to get the information by email 2/ Subscribe to the "send me all the info by email" if it exists 3/ Have to connect (and login?) to the website to answer if necessary, so taking more time to do it than now if there isn't any "reply directly by email" system 4/ Answer by email if it's possible So, in the best situation, I'll do exactly as I do right now. In the worst condition... I'll not be able to continue following what happens on the lttng world as I'll never think about giving a look at a website. I like the way the information comes to me, I'd not like to have to search for the information. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sunyin51 at gmail.com Sun Mar 31 13:14:29 2013 From: sunyin51 at gmail.com (yin sun) Date: Sun, 31 Mar 2013 10:14:29 -0700 Subject: [lttng-dev] lttng-tools 2.2.0-rc1 build error, librt no symbols Message-ID: I am trying the latest git 2.2.0-rc1. seems the the librt is not resolved correctly on my ubuntu 12.10 64bit. Don't know why. I tried to build with static lib seems fine. here is my diff. diff --git a/src/bin/lttng-consumerd/Makefile.am b/src/bin/lttng-consumerd/Makefile.am index a418eb4..1711581 100644 --- a/src/bin/lttng-consumerd/Makefile.am +++ b/src/bin/lttng-consumerd/Makefile.am @@ -4,7 +4,7 @@ lttnglibexec_PROGRAMS = lttng-consumerd lttng_consumerd_SOURCES = lttng-consumerd.c lttng-consumerd.h -lttng_consumerd_LDADD = -lrt \ +lttng_consumerd_LDADD = /usr/lib/x86_64-linux-gnu/librt.a \ $(top_builddir)/src/common/libconsumer.la \ $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \ $(top_builddir)/src/common/libcommon.la -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.marchi at polymtl.ca Sun Mar 31 14:25:34 2013 From: simon.marchi at polymtl.ca (Simon Marchi) Date: Sun, 31 Mar 2013 14:25:34 -0400 Subject: [lttng-dev] lttng-tools 2.2.0-rc1 build error, librt no symbols In-Reply-To: References: Message-ID: Hi Yin, I get the same error. Try putting -lrt after the other arguments of the LDADD. Since libconsumer.la uses timer_settime from librt, -lrt has to be after it on the command line. Simon On 31 March 2013 13:14, yin sun wrote: > I am trying the latest git 2.2.0-rc1. seems the the librt is not resolved > correctly on my ubuntu 12.10 64bit. Don't know why. > > I tried to build with static lib seems fine. here is my diff. > > diff --git a/src/bin/lttng-consumerd/Makefile.am > b/src/bin/lttng-consumerd/Makefile.am > index a418eb4..1711581 100644 > --- a/src/bin/lttng-consumerd/Makefile.am > +++ b/src/bin/lttng-consumerd/Makefile.am > @@ -4,7 +4,7 @@ lttnglibexec_PROGRAMS = lttng-consumerd > > lttng_consumerd_SOURCES = lttng-consumerd.c lttng-consumerd.h > > -lttng_consumerd_LDADD = -lrt \ > +lttng_consumerd_LDADD = /usr/lib/x86_64-linux-gnu/librt.a \ > $(top_builddir)/src/common/libconsumer.la \ > $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \ > $(top_builddir)/src/common/libcommon.la > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev > From simon.marchi at polymtl.ca Sun Mar 31 14:40:18 2013 From: simon.marchi at polymtl.ca (Simon Marchi) Date: Sun, 31 Mar 2013 14:40:18 -0400 Subject: [lttng-dev] [PATCH lttng-tools] Fix link: move -lrt at the end of the link line Message-ID: <1364755218-27374-1-git-send-email-simon.marchi@polymtl.ca> It has to be after libconsumer.la. Signed-off-by: Simon Marchi --- src/bin/lttng-consumerd/Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-consumerd/Makefile.am b/src/bin/lttng-consumerd/Makefile.am index a418eb4..d340c68 100644 --- a/src/bin/lttng-consumerd/Makefile.am +++ b/src/bin/lttng-consumerd/Makefile.am @@ -4,10 +4,11 @@ lttnglibexec_PROGRAMS = lttng-consumerd lttng_consumerd_SOURCES = lttng-consumerd.c lttng-consumerd.h -lttng_consumerd_LDADD = -lrt \ +lttng_consumerd_LDADD = \ $(top_builddir)/src/common/libconsumer.la \ $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \ - $(top_builddir)/src/common/libcommon.la + $(top_builddir)/src/common/libcommon.la \ + -lrt if HAVE_LIBLTTNG_UST_CTL lttng_consumerd_LDADD += -llttng-ust-ctl -- 1.7.10.4