Fix: use after free on metadata cache reallocation
[lttng-modules.git] / lttng-events.c
1 /*
2 * lttng-events.c
3 *
4 * Holds LTTng per-session event registry.
5 *
6 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; only
11 * version 2.1 of the License.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /*
24 * This page_alloc.h wrapper needs to be included before gfpflags.h because it
25 * overrides a function with a define.
26 */
27 #include "wrapper/page_alloc.h"
28
29 #include <linux/module.h>
30 #include <linux/mutex.h>
31 #include <linux/sched.h>
32 #include <linux/slab.h>
33 #include <linux/jiffies.h>
34 #include <linux/utsname.h>
35 #include <linux/err.h>
36 #include <linux/seq_file.h>
37 #include <linux/file.h>
38 #include <linux/anon_inodes.h>
39 #include "wrapper/file.h"
40 #include <linux/jhash.h>
41 #include <linux/uaccess.h>
42
43 #include "wrapper/uuid.h"
44 #include "wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */
45 #include "wrapper/random.h"
46 #include "wrapper/tracepoint.h"
47 #include "wrapper/list.h"
48 #include "lttng-kernel-version.h"
49 #include "lttng-events.h"
50 #include "lttng-tracer.h"
51 #include "lttng-abi-old.h"
52
53 #define METADATA_CACHE_DEFAULT_SIZE 4096
54
55 static LIST_HEAD(sessions);
56 static LIST_HEAD(lttng_transport_list);
57 /*
58 * Protect the sessions and metadata caches.
59 */
60 static DEFINE_MUTEX(sessions_mutex);
61 static struct kmem_cache *event_cache;
62
63 static void lttng_session_lazy_sync_enablers(struct lttng_session *session);
64 static void lttng_session_sync_enablers(struct lttng_session *session);
65 static void lttng_enabler_destroy(struct lttng_enabler *enabler);
66
67 static void _lttng_event_destroy(struct lttng_event *event);
68 static void _lttng_channel_destroy(struct lttng_channel *chan);
69 static int _lttng_event_unregister(struct lttng_event *event);
70 static
71 int _lttng_event_metadata_statedump(struct lttng_session *session,
72 struct lttng_channel *chan,
73 struct lttng_event *event);
74 static
75 int _lttng_session_metadata_statedump(struct lttng_session *session);
76 static
77 void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream);
78
79 void synchronize_trace(void)
80 {
81 synchronize_sched();
82 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
83 #ifdef CONFIG_PREEMPT_RT_FULL
84 synchronize_rcu();
85 #endif
86 #else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) */
87 #ifdef CONFIG_PREEMPT_RT
88 synchronize_rcu();
89 #endif
90 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) */
91 }
92
93 void lttng_lock_sessions(void)
94 {
95 mutex_lock(&sessions_mutex);
96 }
97
98 void lttng_unlock_sessions(void)
99 {
100 mutex_unlock(&sessions_mutex);
101 }
102
103 /*
104 * Called with sessions lock held.
105 */
106 int lttng_session_active(void)
107 {
108 struct lttng_session *iter;
109
110 list_for_each_entry(iter, &sessions, list) {
111 if (iter->active)
112 return 1;
113 }
114 return 0;
115 }
116
117 struct lttng_session *lttng_session_create(void)
118 {
119 struct lttng_session *session;
120 struct lttng_metadata_cache *metadata_cache;
121 int i;
122
123 mutex_lock(&sessions_mutex);
124 session = kzalloc(sizeof(struct lttng_session), GFP_KERNEL);
125 if (!session)
126 goto err;
127 INIT_LIST_HEAD(&session->chan);
128 INIT_LIST_HEAD(&session->events);
129 uuid_le_gen(&session->uuid);
130
131 metadata_cache = kzalloc(sizeof(struct lttng_metadata_cache),
132 GFP_KERNEL);
133 if (!metadata_cache)
134 goto err_free_session;
135 metadata_cache->data = kzalloc(METADATA_CACHE_DEFAULT_SIZE,
136 GFP_KERNEL);
137 if (!metadata_cache->data)
138 goto err_free_cache;
139 metadata_cache->cache_alloc = METADATA_CACHE_DEFAULT_SIZE;
140 kref_init(&metadata_cache->refcount);
141 mutex_init(&metadata_cache->lock);
142 session->metadata_cache = metadata_cache;
143 INIT_LIST_HEAD(&metadata_cache->metadata_stream);
144 memcpy(&metadata_cache->uuid, &session->uuid,
145 sizeof(metadata_cache->uuid));
146 INIT_LIST_HEAD(&session->enablers_head);
147 for (i = 0; i < LTTNG_EVENT_HT_SIZE; i++)
148 INIT_HLIST_HEAD(&session->events_ht.table[i]);
149 list_add(&session->list, &sessions);
150 mutex_unlock(&sessions_mutex);
151 return session;
152
153 err_free_cache:
154 kfree(metadata_cache);
155 err_free_session:
156 kfree(session);
157 err:
158 mutex_unlock(&sessions_mutex);
159 return NULL;
160 }
161
162 void metadata_cache_destroy(struct kref *kref)
163 {
164 struct lttng_metadata_cache *cache =
165 container_of(kref, struct lttng_metadata_cache, refcount);
166 kfree(cache->data);
167 kfree(cache);
168 }
169
170 void lttng_session_destroy(struct lttng_session *session)
171 {
172 struct lttng_channel *chan, *tmpchan;
173 struct lttng_event *event, *tmpevent;
174 struct lttng_metadata_stream *metadata_stream;
175 struct lttng_enabler *enabler, *tmpenabler;
176 int ret;
177
178 mutex_lock(&sessions_mutex);
179 ACCESS_ONCE(session->active) = 0;
180 list_for_each_entry(chan, &session->chan, list) {
181 ret = lttng_syscalls_unregister(chan);
182 WARN_ON(ret);
183 }
184 list_for_each_entry(event, &session->events, list) {
185 ret = _lttng_event_unregister(event);
186 WARN_ON(ret);
187 }
188 synchronize_trace(); /* Wait for in-flight events to complete */
189 list_for_each_entry_safe(enabler, tmpenabler,
190 &session->enablers_head, node)
191 lttng_enabler_destroy(enabler);
192 list_for_each_entry_safe(event, tmpevent, &session->events, list)
193 _lttng_event_destroy(event);
194 list_for_each_entry_safe(chan, tmpchan, &session->chan, list) {
195 BUG_ON(chan->channel_type == METADATA_CHANNEL);
196 _lttng_channel_destroy(chan);
197 }
198 list_for_each_entry(metadata_stream, &session->metadata_cache->metadata_stream, list)
199 _lttng_metadata_channel_hangup(metadata_stream);
200 if (session->pid_tracker)
201 lttng_pid_tracker_destroy(session->pid_tracker);
202 kref_put(&session->metadata_cache->refcount, metadata_cache_destroy);
203 list_del(&session->list);
204 mutex_unlock(&sessions_mutex);
205 kfree(session);
206 }
207
208 int lttng_session_enable(struct lttng_session *session)
209 {
210 int ret = 0;
211 struct lttng_channel *chan;
212
213 mutex_lock(&sessions_mutex);
214 if (session->active) {
215 ret = -EBUSY;
216 goto end;
217 }
218
219 /* Set transient enabler state to "enabled" */
220 session->tstate = 1;
221
222 /*
223 * Snapshot the number of events per channel to know the type of header
224 * we need to use.
225 */
226 list_for_each_entry(chan, &session->chan, list) {
227 if (chan->header_type)
228 continue; /* don't change it if session stop/restart */
229 if (chan->free_event_id < 31)
230 chan->header_type = 1; /* compact */
231 else
232 chan->header_type = 2; /* large */
233 }
234
235 /* We need to sync enablers with session before activation. */
236 lttng_session_sync_enablers(session);
237
238 ACCESS_ONCE(session->active) = 1;
239 ACCESS_ONCE(session->been_active) = 1;
240 ret = _lttng_session_metadata_statedump(session);
241 if (ret) {
242 ACCESS_ONCE(session->active) = 0;
243 goto end;
244 }
245 ret = lttng_statedump_start(session);
246 if (ret)
247 ACCESS_ONCE(session->active) = 0;
248 end:
249 mutex_unlock(&sessions_mutex);
250 return ret;
251 }
252
253 int lttng_session_disable(struct lttng_session *session)
254 {
255 int ret = 0;
256
257 mutex_lock(&sessions_mutex);
258 if (!session->active) {
259 ret = -EBUSY;
260 goto end;
261 }
262 ACCESS_ONCE(session->active) = 0;
263
264 /* Set transient enabler state to "disabled" */
265 session->tstate = 0;
266 lttng_session_sync_enablers(session);
267 end:
268 mutex_unlock(&sessions_mutex);
269 return ret;
270 }
271
272 int lttng_channel_enable(struct lttng_channel *channel)
273 {
274 int ret = 0;
275
276 mutex_lock(&sessions_mutex);
277 if (channel->channel_type == METADATA_CHANNEL) {
278 ret = -EPERM;
279 goto end;
280 }
281 if (channel->enabled) {
282 ret = -EEXIST;
283 goto end;
284 }
285 /* Set transient enabler state to "enabled" */
286 channel->tstate = 1;
287 lttng_session_sync_enablers(channel->session);
288 /* Set atomically the state to "enabled" */
289 ACCESS_ONCE(channel->enabled) = 1;
290 end:
291 mutex_unlock(&sessions_mutex);
292 return ret;
293 }
294
295 int lttng_channel_disable(struct lttng_channel *channel)
296 {
297 int ret = 0;
298
299 mutex_lock(&sessions_mutex);
300 if (channel->channel_type == METADATA_CHANNEL) {
301 ret = -EPERM;
302 goto end;
303 }
304 if (!channel->enabled) {
305 ret = -EEXIST;
306 goto end;
307 }
308 /* Set atomically the state to "disabled" */
309 ACCESS_ONCE(channel->enabled) = 0;
310 /* Set transient enabler state to "enabled" */
311 channel->tstate = 0;
312 lttng_session_sync_enablers(channel->session);
313 end:
314 mutex_unlock(&sessions_mutex);
315 return ret;
316 }
317
318 int lttng_event_enable(struct lttng_event *event)
319 {
320 int ret = 0;
321
322 mutex_lock(&sessions_mutex);
323 if (event->chan->channel_type == METADATA_CHANNEL) {
324 ret = -EPERM;
325 goto end;
326 }
327 if (event->enabled) {
328 ret = -EEXIST;
329 goto end;
330 }
331 ACCESS_ONCE(event->enabled) = 1;
332 lttng_session_sync_enablers(event->chan->session);
333 end:
334 mutex_unlock(&sessions_mutex);
335 return ret;
336 }
337
338 int lttng_event_disable(struct lttng_event *event)
339 {
340 int ret = 0;
341
342 mutex_lock(&sessions_mutex);
343 if (event->chan->channel_type == METADATA_CHANNEL) {
344 ret = -EPERM;
345 goto end;
346 }
347 if (!event->enabled) {
348 ret = -EEXIST;
349 goto end;
350 }
351 ACCESS_ONCE(event->enabled) = 0;
352 lttng_session_sync_enablers(event->chan->session);
353 end:
354 mutex_unlock(&sessions_mutex);
355 return ret;
356 }
357
358 static struct lttng_transport *lttng_transport_find(const char *name)
359 {
360 struct lttng_transport *transport;
361
362 list_for_each_entry(transport, &lttng_transport_list, node) {
363 if (!strcmp(transport->name, name))
364 return transport;
365 }
366 return NULL;
367 }
368
369 struct lttng_channel *lttng_channel_create(struct lttng_session *session,
370 const char *transport_name,
371 void *buf_addr,
372 size_t subbuf_size, size_t num_subbuf,
373 unsigned int switch_timer_interval,
374 unsigned int read_timer_interval,
375 enum channel_type channel_type)
376 {
377 struct lttng_channel *chan;
378 struct lttng_transport *transport = NULL;
379
380 mutex_lock(&sessions_mutex);
381 if (session->been_active && channel_type != METADATA_CHANNEL)
382 goto active; /* Refuse to add channel to active session */
383 transport = lttng_transport_find(transport_name);
384 if (!transport) {
385 printk(KERN_WARNING "LTTng transport %s not found\n",
386 transport_name);
387 goto notransport;
388 }
389 if (!try_module_get(transport->owner)) {
390 printk(KERN_WARNING "LTT : Can't lock transport module.\n");
391 goto notransport;
392 }
393 chan = kzalloc(sizeof(struct lttng_channel), GFP_KERNEL);
394 if (!chan)
395 goto nomem;
396 chan->session = session;
397 chan->id = session->free_chan_id++;
398 chan->ops = &transport->ops;
399 /*
400 * Note: the channel creation op already writes into the packet
401 * headers. Therefore the "chan" information used as input
402 * should be already accessible.
403 */
404 chan->chan = transport->ops.channel_create(transport_name,
405 chan, buf_addr, subbuf_size, num_subbuf,
406 switch_timer_interval, read_timer_interval);
407 if (!chan->chan)
408 goto create_error;
409 chan->tstate = 1;
410 chan->enabled = 1;
411 chan->transport = transport;
412 chan->channel_type = channel_type;
413 list_add(&chan->list, &session->chan);
414 mutex_unlock(&sessions_mutex);
415 return chan;
416
417 create_error:
418 kfree(chan);
419 nomem:
420 if (transport)
421 module_put(transport->owner);
422 notransport:
423 active:
424 mutex_unlock(&sessions_mutex);
425 return NULL;
426 }
427
428 /*
429 * Only used internally at session destruction for per-cpu channels, and
430 * when metadata channel is released.
431 * Needs to be called with sessions mutex held.
432 */
433 static
434 void _lttng_channel_destroy(struct lttng_channel *chan)
435 {
436 chan->ops->channel_destroy(chan->chan);
437 module_put(chan->transport->owner);
438 list_del(&chan->list);
439 lttng_destroy_context(chan->ctx);
440 kfree(chan);
441 }
442
443 void lttng_metadata_channel_destroy(struct lttng_channel *chan)
444 {
445 BUG_ON(chan->channel_type != METADATA_CHANNEL);
446
447 /* Protect the metadata cache with the sessions_mutex. */
448 mutex_lock(&sessions_mutex);
449 _lttng_channel_destroy(chan);
450 mutex_unlock(&sessions_mutex);
451 }
452 EXPORT_SYMBOL_GPL(lttng_metadata_channel_destroy);
453
454 static
455 void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream)
456 {
457 stream->finalized = 1;
458 wake_up_interruptible(&stream->read_wait);
459 }
460
461 /*
462 * Supports event creation while tracing session is active.
463 * Needs to be called with sessions mutex held.
464 */
465 struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
466 struct lttng_kernel_event *event_param,
467 void *filter,
468 const struct lttng_event_desc *event_desc,
469 enum lttng_kernel_instrumentation itype)
470 {
471 struct lttng_session *session = chan->session;
472 struct lttng_event *event;
473 const char *event_name;
474 struct hlist_head *head;
475 size_t name_len;
476 uint32_t hash;
477 int ret;
478
479 if (chan->free_event_id == -1U) {
480 ret = -EMFILE;
481 goto full;
482 }
483
484 switch (itype) {
485 case LTTNG_KERNEL_TRACEPOINT:
486 event_name = event_desc->name;
487 break;
488 case LTTNG_KERNEL_KPROBE:
489 case LTTNG_KERNEL_KRETPROBE:
490 case LTTNG_KERNEL_FUNCTION:
491 case LTTNG_KERNEL_NOOP:
492 case LTTNG_KERNEL_SYSCALL:
493 event_name = event_param->name;
494 break;
495 default:
496 WARN_ON_ONCE(1);
497 ret = -EINVAL;
498 goto type_error;
499 }
500 name_len = strlen(event_name);
501 hash = jhash(event_name, name_len, 0);
502 head = &session->events_ht.table[hash & (LTTNG_EVENT_HT_SIZE - 1)];
503 lttng_hlist_for_each_entry(event, head, hlist) {
504 WARN_ON_ONCE(!event->desc);
505 if (!strncmp(event->desc->name, event_name,
506 LTTNG_KERNEL_SYM_NAME_LEN - 1)
507 && chan == event->chan) {
508 ret = -EEXIST;
509 goto exist;
510 }
511 }
512
513 event = kmem_cache_zalloc(event_cache, GFP_KERNEL);
514 if (!event) {
515 ret = -ENOMEM;
516 goto cache_error;
517 }
518 event->chan = chan;
519 event->filter = filter;
520 event->id = chan->free_event_id++;
521 event->instrumentation = itype;
522 event->evtype = LTTNG_TYPE_EVENT;
523 INIT_LIST_HEAD(&event->bytecode_runtime_head);
524 INIT_LIST_HEAD(&event->enablers_ref_head);
525
526 switch (itype) {
527 case LTTNG_KERNEL_TRACEPOINT:
528 /* Event will be enabled by enabler sync. */
529 event->enabled = 0;
530 event->registered = 0;
531 event->desc = lttng_event_get(event_name);
532 if (!event->desc) {
533 ret = -ENOENT;
534 goto register_error;
535 }
536 /* Populate lttng_event structure before event registration. */
537 smp_wmb();
538 break;
539 case LTTNG_KERNEL_KPROBE:
540 event->enabled = 1;
541 event->registered = 1;
542 /*
543 * Populate lttng_event structure before event
544 * registration.
545 */
546 smp_wmb();
547 ret = lttng_kprobes_register(event_name,
548 event_param->u.kprobe.symbol_name,
549 event_param->u.kprobe.offset,
550 event_param->u.kprobe.addr,
551 event);
552 if (ret) {
553 ret = -EINVAL;
554 goto register_error;
555 }
556 ret = try_module_get(event->desc->owner);
557 WARN_ON_ONCE(!ret);
558 break;
559 case LTTNG_KERNEL_KRETPROBE:
560 {
561 struct lttng_event *event_return;
562
563 /* kretprobe defines 2 events */
564 event->enabled = 1;
565 event->registered = 1;
566 event_return =
567 kmem_cache_zalloc(event_cache, GFP_KERNEL);
568 if (!event_return) {
569 ret = -ENOMEM;
570 goto register_error;
571 }
572 event_return->chan = chan;
573 event_return->filter = filter;
574 event_return->id = chan->free_event_id++;
575 event_return->enabled = 1;
576 event_return->registered = 1;
577 event_return->instrumentation = itype;
578 /*
579 * Populate lttng_event structure before kretprobe registration.
580 */
581 smp_wmb();
582 ret = lttng_kretprobes_register(event_name,
583 event_param->u.kretprobe.symbol_name,
584 event_param->u.kretprobe.offset,
585 event_param->u.kretprobe.addr,
586 event, event_return);
587 if (ret) {
588 kmem_cache_free(event_cache, event_return);
589 ret = -EINVAL;
590 goto register_error;
591 }
592 /* Take 2 refs on the module: one per event. */
593 ret = try_module_get(event->desc->owner);
594 WARN_ON_ONCE(!ret);
595 ret = try_module_get(event->desc->owner);
596 WARN_ON_ONCE(!ret);
597 ret = _lttng_event_metadata_statedump(chan->session, chan,
598 event_return);
599 WARN_ON_ONCE(ret > 0);
600 if (ret) {
601 kmem_cache_free(event_cache, event_return);
602 module_put(event->desc->owner);
603 module_put(event->desc->owner);
604 goto statedump_error;
605 }
606 list_add(&event_return->list, &chan->session->events);
607 break;
608 }
609 case LTTNG_KERNEL_FUNCTION:
610 event->enabled = 1;
611 event->registered = 1;
612 /*
613 * Populate lttng_event structure before event
614 * registration.
615 */
616 smp_wmb();
617 ret = lttng_ftrace_register(event_name,
618 event_param->u.ftrace.symbol_name,
619 event);
620 if (ret) {
621 goto register_error;
622 }
623 ret = try_module_get(event->desc->owner);
624 WARN_ON_ONCE(!ret);
625 break;
626 case LTTNG_KERNEL_NOOP:
627 case LTTNG_KERNEL_SYSCALL:
628 event->enabled = 1;
629 event->registered = 0;
630 event->desc = event_desc;
631 if (!event->desc) {
632 ret = -EINVAL;
633 goto register_error;
634 }
635 break;
636 default:
637 WARN_ON_ONCE(1);
638 ret = -EINVAL;
639 goto register_error;
640 }
641 ret = _lttng_event_metadata_statedump(chan->session, chan, event);
642 WARN_ON_ONCE(ret > 0);
643 if (ret) {
644 goto statedump_error;
645 }
646 hlist_add_head(&event->hlist, head);
647 list_add(&event->list, &chan->session->events);
648 return event;
649
650 statedump_error:
651 /* If a statedump error occurs, events will not be readable. */
652 register_error:
653 kmem_cache_free(event_cache, event);
654 cache_error:
655 exist:
656 type_error:
657 full:
658 return ERR_PTR(ret);
659 }
660
661 struct lttng_event *lttng_event_create(struct lttng_channel *chan,
662 struct lttng_kernel_event *event_param,
663 void *filter,
664 const struct lttng_event_desc *event_desc,
665 enum lttng_kernel_instrumentation itype)
666 {
667 struct lttng_event *event;
668
669 mutex_lock(&sessions_mutex);
670 event = _lttng_event_create(chan, event_param, filter, event_desc,
671 itype);
672 mutex_unlock(&sessions_mutex);
673 return event;
674 }
675
676 /* Only used for tracepoints for now. */
677 static
678 void register_event(struct lttng_event *event)
679 {
680 const struct lttng_event_desc *desc;
681 int ret = -EINVAL;
682
683 if (event->registered)
684 return;
685
686 desc = event->desc;
687 switch (event->instrumentation) {
688 case LTTNG_KERNEL_TRACEPOINT:
689 ret = lttng_wrapper_tracepoint_probe_register(desc->kname,
690 desc->probe_callback,
691 event);
692 break;
693 case LTTNG_KERNEL_SYSCALL:
694 ret = lttng_syscall_filter_enable(event->chan,
695 desc->name);
696 break;
697 case LTTNG_KERNEL_KPROBE:
698 case LTTNG_KERNEL_KRETPROBE:
699 case LTTNG_KERNEL_FUNCTION:
700 case LTTNG_KERNEL_NOOP:
701 ret = 0;
702 break;
703 default:
704 WARN_ON_ONCE(1);
705 }
706 if (!ret)
707 event->registered = 1;
708 }
709
710 /*
711 * Only used internally at session destruction.
712 */
713 int _lttng_event_unregister(struct lttng_event *event)
714 {
715 const struct lttng_event_desc *desc;
716 int ret = -EINVAL;
717
718 if (!event->registered)
719 return 0;
720
721 desc = event->desc;
722 switch (event->instrumentation) {
723 case LTTNG_KERNEL_TRACEPOINT:
724 ret = lttng_wrapper_tracepoint_probe_unregister(event->desc->kname,
725 event->desc->probe_callback,
726 event);
727 break;
728 case LTTNG_KERNEL_KPROBE:
729 lttng_kprobes_unregister(event);
730 ret = 0;
731 break;
732 case LTTNG_KERNEL_KRETPROBE:
733 lttng_kretprobes_unregister(event);
734 ret = 0;
735 break;
736 case LTTNG_KERNEL_FUNCTION:
737 lttng_ftrace_unregister(event);
738 ret = 0;
739 break;
740 case LTTNG_KERNEL_SYSCALL:
741 ret = lttng_syscall_filter_disable(event->chan,
742 desc->name);
743 break;
744 case LTTNG_KERNEL_NOOP:
745 ret = 0;
746 break;
747 default:
748 WARN_ON_ONCE(1);
749 }
750 if (!ret)
751 event->registered = 0;
752 return ret;
753 }
754
755 /*
756 * Only used internally at session destruction.
757 */
758 static
759 void _lttng_event_destroy(struct lttng_event *event)
760 {
761 switch (event->instrumentation) {
762 case LTTNG_KERNEL_TRACEPOINT:
763 lttng_event_put(event->desc);
764 break;
765 case LTTNG_KERNEL_KPROBE:
766 module_put(event->desc->owner);
767 lttng_kprobes_destroy_private(event);
768 break;
769 case LTTNG_KERNEL_KRETPROBE:
770 module_put(event->desc->owner);
771 lttng_kretprobes_destroy_private(event);
772 break;
773 case LTTNG_KERNEL_FUNCTION:
774 module_put(event->desc->owner);
775 lttng_ftrace_destroy_private(event);
776 break;
777 case LTTNG_KERNEL_NOOP:
778 case LTTNG_KERNEL_SYSCALL:
779 break;
780 default:
781 WARN_ON_ONCE(1);
782 }
783 list_del(&event->list);
784 lttng_destroy_context(event->ctx);
785 kmem_cache_free(event_cache, event);
786 }
787
788 int lttng_session_track_pid(struct lttng_session *session, int pid)
789 {
790 int ret;
791
792 if (pid < -1)
793 return -EINVAL;
794 mutex_lock(&sessions_mutex);
795 if (pid == -1) {
796 /* track all pids: destroy tracker. */
797 if (session->pid_tracker) {
798 struct lttng_pid_tracker *lpf;
799
800 lpf = session->pid_tracker;
801 rcu_assign_pointer(session->pid_tracker, NULL);
802 synchronize_trace();
803 lttng_pid_tracker_destroy(lpf);
804 }
805 ret = 0;
806 } else {
807 if (!session->pid_tracker) {
808 struct lttng_pid_tracker *lpf;
809
810 lpf = lttng_pid_tracker_create();
811 if (!lpf) {
812 ret = -ENOMEM;
813 goto unlock;
814 }
815 ret = lttng_pid_tracker_add(lpf, pid);
816 rcu_assign_pointer(session->pid_tracker, lpf);
817 } else {
818 ret = lttng_pid_tracker_add(session->pid_tracker, pid);
819 }
820 }
821 unlock:
822 mutex_unlock(&sessions_mutex);
823 return ret;
824 }
825
826 int lttng_session_untrack_pid(struct lttng_session *session, int pid)
827 {
828 int ret;
829
830 if (pid < -1)
831 return -EINVAL;
832 mutex_lock(&sessions_mutex);
833 if (pid == -1) {
834 /* untrack all pids: replace by empty tracker. */
835 struct lttng_pid_tracker *old_lpf = session->pid_tracker;
836 struct lttng_pid_tracker *lpf;
837
838 lpf = lttng_pid_tracker_create();
839 if (!lpf) {
840 ret = -ENOMEM;
841 goto unlock;
842 }
843 rcu_assign_pointer(session->pid_tracker, lpf);
844 synchronize_trace();
845 if (old_lpf)
846 lttng_pid_tracker_destroy(old_lpf);
847 ret = 0;
848 } else {
849 if (!session->pid_tracker) {
850 ret = -ENOENT;
851 goto unlock;
852 }
853 ret = lttng_pid_tracker_del(session->pid_tracker, pid);
854 }
855 unlock:
856 mutex_unlock(&sessions_mutex);
857 return ret;
858 }
859
860 static
861 void *pid_list_start(struct seq_file *m, loff_t *pos)
862 {
863 struct lttng_session *session = m->private;
864 struct lttng_pid_tracker *lpf;
865 struct lttng_pid_hash_node *e;
866 int iter = 0, i;
867
868 mutex_lock(&sessions_mutex);
869 lpf = session->pid_tracker;
870 if (lpf) {
871 for (i = 0; i < LTTNG_PID_TABLE_SIZE; i++) {
872 struct hlist_head *head = &lpf->pid_hash[i];
873
874 lttng_hlist_for_each_entry(e, head, hlist) {
875 if (iter++ >= *pos)
876 return e;
877 }
878 }
879 } else {
880 /* PID tracker disabled. */
881 if (iter >= *pos && iter == 0) {
882 return session; /* empty tracker */
883 }
884 iter++;
885 }
886 /* End of list */
887 return NULL;
888 }
889
890 /* Called with sessions_mutex held. */
891 static
892 void *pid_list_next(struct seq_file *m, void *p, loff_t *ppos)
893 {
894 struct lttng_session *session = m->private;
895 struct lttng_pid_tracker *lpf;
896 struct lttng_pid_hash_node *e;
897 int iter = 0, i;
898
899 (*ppos)++;
900 lpf = session->pid_tracker;
901 if (lpf) {
902 for (i = 0; i < LTTNG_PID_TABLE_SIZE; i++) {
903 struct hlist_head *head = &lpf->pid_hash[i];
904
905 lttng_hlist_for_each_entry(e, head, hlist) {
906 if (iter++ >= *ppos)
907 return e;
908 }
909 }
910 } else {
911 /* PID tracker disabled. */
912 if (iter >= *ppos && iter == 0)
913 return session; /* empty tracker */
914 iter++;
915 }
916
917 /* End of list */
918 return NULL;
919 }
920
921 static
922 void pid_list_stop(struct seq_file *m, void *p)
923 {
924 mutex_unlock(&sessions_mutex);
925 }
926
927 static
928 int pid_list_show(struct seq_file *m, void *p)
929 {
930 int pid;
931
932 if (p == m->private) {
933 /* Tracker disabled. */
934 pid = -1;
935 } else {
936 const struct lttng_pid_hash_node *e = p;
937
938 pid = lttng_pid_tracker_get_node_pid(e);
939 }
940 seq_printf(m, "process { pid = %d; };\n", pid);
941 return 0;
942 }
943
944 static
945 const struct seq_operations lttng_tracker_pids_list_seq_ops = {
946 .start = pid_list_start,
947 .next = pid_list_next,
948 .stop = pid_list_stop,
949 .show = pid_list_show,
950 };
951
952 static
953 int lttng_tracker_pids_list_open(struct inode *inode, struct file *file)
954 {
955 return seq_open(file, &lttng_tracker_pids_list_seq_ops);
956 }
957
958 static
959 int lttng_tracker_pids_list_release(struct inode *inode, struct file *file)
960 {
961 struct seq_file *m = file->private_data;
962 struct lttng_session *session = m->private;
963 int ret;
964
965 WARN_ON_ONCE(!session);
966 ret = seq_release(inode, file);
967 if (!ret && session)
968 fput(session->file);
969 return ret;
970 }
971
972 const struct file_operations lttng_tracker_pids_list_fops = {
973 .owner = THIS_MODULE,
974 .open = lttng_tracker_pids_list_open,
975 .read = seq_read,
976 .llseek = seq_lseek,
977 .release = lttng_tracker_pids_list_release,
978 };
979
980 int lttng_session_list_tracker_pids(struct lttng_session *session)
981 {
982 struct file *tracker_pids_list_file;
983 struct seq_file *m;
984 int file_fd, ret;
985
986 file_fd = lttng_get_unused_fd();
987 if (file_fd < 0) {
988 ret = file_fd;
989 goto fd_error;
990 }
991
992 tracker_pids_list_file = anon_inode_getfile("[lttng_tracker_pids_list]",
993 &lttng_tracker_pids_list_fops,
994 NULL, O_RDWR);
995 if (IS_ERR(tracker_pids_list_file)) {
996 ret = PTR_ERR(tracker_pids_list_file);
997 goto file_error;
998 }
999 ret = lttng_tracker_pids_list_fops.open(NULL, tracker_pids_list_file);
1000 if (ret < 0)
1001 goto open_error;
1002 m = tracker_pids_list_file->private_data;
1003 m->private = session;
1004 fd_install(file_fd, tracker_pids_list_file);
1005 atomic_long_inc(&session->file->f_count);
1006
1007 return file_fd;
1008
1009 open_error:
1010 fput(tracker_pids_list_file);
1011 file_error:
1012 put_unused_fd(file_fd);
1013 fd_error:
1014 return ret;
1015 }
1016
1017 /*
1018 * Enabler management.
1019 */
1020 static
1021 int lttng_match_enabler_wildcard(const char *desc_name,
1022 const char *name)
1023 {
1024 /* Compare excluding final '*' */
1025 if (strncmp(desc_name, name, strlen(name) - 1))
1026 return 0;
1027 return 1;
1028 }
1029
1030 static
1031 int lttng_match_enabler_name(const char *desc_name,
1032 const char *name)
1033 {
1034 if (strcmp(desc_name, name))
1035 return 0;
1036 return 1;
1037 }
1038
1039 static
1040 int lttng_desc_match_enabler(const struct lttng_event_desc *desc,
1041 struct lttng_enabler *enabler)
1042 {
1043 const char *desc_name, *enabler_name;
1044
1045 enabler_name = enabler->event_param.name;
1046 switch (enabler->event_param.instrumentation) {
1047 case LTTNG_KERNEL_TRACEPOINT:
1048 desc_name = desc->name;
1049 break;
1050 case LTTNG_KERNEL_SYSCALL:
1051 desc_name = desc->name;
1052 if (!strncmp(desc_name, "compat_", strlen("compat_")))
1053 desc_name += strlen("compat_");
1054 if (!strncmp(desc_name, "syscall_exit_",
1055 strlen("syscall_exit_"))) {
1056 desc_name += strlen("syscall_exit_");
1057 } else if (!strncmp(desc_name, "syscall_entry_",
1058 strlen("syscall_entry_"))) {
1059 desc_name += strlen("syscall_entry_");
1060 } else {
1061 WARN_ON_ONCE(1);
1062 return -EINVAL;
1063 }
1064 break;
1065 default:
1066 WARN_ON_ONCE(1);
1067 return -EINVAL;
1068 }
1069 switch (enabler->type) {
1070 case LTTNG_ENABLER_WILDCARD:
1071 return lttng_match_enabler_wildcard(desc_name, enabler_name);
1072 case LTTNG_ENABLER_NAME:
1073 return lttng_match_enabler_name(desc_name, enabler_name);
1074 default:
1075 return -EINVAL;
1076 }
1077 }
1078
1079 static
1080 int lttng_event_match_enabler(struct lttng_event *event,
1081 struct lttng_enabler *enabler)
1082 {
1083 if (enabler->event_param.instrumentation != event->instrumentation)
1084 return 0;
1085 if (lttng_desc_match_enabler(event->desc, enabler)
1086 && event->chan == enabler->chan)
1087 return 1;
1088 else
1089 return 0;
1090 }
1091
1092 static
1093 struct lttng_enabler_ref *lttng_event_enabler_ref(struct lttng_event *event,
1094 struct lttng_enabler *enabler)
1095 {
1096 struct lttng_enabler_ref *enabler_ref;
1097
1098 list_for_each_entry(enabler_ref,
1099 &event->enablers_ref_head, node) {
1100 if (enabler_ref->ref == enabler)
1101 return enabler_ref;
1102 }
1103 return NULL;
1104 }
1105
1106 static
1107 void lttng_create_tracepoint_if_missing(struct lttng_enabler *enabler)
1108 {
1109 struct lttng_session *session = enabler->chan->session;
1110 struct lttng_probe_desc *probe_desc;
1111 const struct lttng_event_desc *desc;
1112 int i;
1113 struct list_head *probe_list;
1114
1115 probe_list = lttng_get_probe_list_head();
1116 /*
1117 * For each probe event, if we find that a probe event matches
1118 * our enabler, create an associated lttng_event if not
1119 * already present.
1120 */
1121 list_for_each_entry(probe_desc, probe_list, head) {
1122 for (i = 0; i < probe_desc->nr_events; i++) {
1123 int found = 0;
1124 struct hlist_head *head;
1125 const char *event_name;
1126 size_t name_len;
1127 uint32_t hash;
1128 struct lttng_event *event;
1129
1130 desc = probe_desc->event_desc[i];
1131 if (!lttng_desc_match_enabler(desc, enabler))
1132 continue;
1133 event_name = desc->name;
1134 name_len = strlen(event_name);
1135
1136 /*
1137 * Check if already created.
1138 */
1139 hash = jhash(event_name, name_len, 0);
1140 head = &session->events_ht.table[hash & (LTTNG_EVENT_HT_SIZE - 1)];
1141 lttng_hlist_for_each_entry(event, head, hlist) {
1142 if (event->desc == desc
1143 && event->chan == enabler->chan)
1144 found = 1;
1145 }
1146 if (found)
1147 continue;
1148
1149 /*
1150 * We need to create an event for this
1151 * event probe.
1152 */
1153 event = _lttng_event_create(enabler->chan,
1154 NULL, NULL, desc,
1155 LTTNG_KERNEL_TRACEPOINT);
1156 if (!event) {
1157 printk(KERN_INFO "Unable to create event %s\n",
1158 probe_desc->event_desc[i]->name);
1159 }
1160 }
1161 }
1162 }
1163
1164 static
1165 void lttng_create_syscall_if_missing(struct lttng_enabler *enabler)
1166 {
1167 int ret;
1168
1169 ret = lttng_syscalls_register(enabler->chan, NULL);
1170 WARN_ON_ONCE(ret);
1171 }
1172
1173 /*
1174 * Create struct lttng_event if it is missing and present in the list of
1175 * tracepoint probes.
1176 * Should be called with sessions mutex held.
1177 */
1178 static
1179 void lttng_create_event_if_missing(struct lttng_enabler *enabler)
1180 {
1181 switch (enabler->event_param.instrumentation) {
1182 case LTTNG_KERNEL_TRACEPOINT:
1183 lttng_create_tracepoint_if_missing(enabler);
1184 break;
1185 case LTTNG_KERNEL_SYSCALL:
1186 lttng_create_syscall_if_missing(enabler);
1187 break;
1188 default:
1189 WARN_ON_ONCE(1);
1190 break;
1191 }
1192 }
1193
1194 /*
1195 * Create events associated with an enabler (if not already present),
1196 * and add backward reference from the event to the enabler.
1197 * Should be called with sessions mutex held.
1198 */
1199 static
1200 int lttng_enabler_ref_events(struct lttng_enabler *enabler)
1201 {
1202 struct lttng_session *session = enabler->chan->session;
1203 struct lttng_event *event;
1204
1205 /* First ensure that probe events are created for this enabler. */
1206 lttng_create_event_if_missing(enabler);
1207
1208 /* For each event matching enabler in session event list. */
1209 list_for_each_entry(event, &session->events, list) {
1210 struct lttng_enabler_ref *enabler_ref;
1211
1212 if (!lttng_event_match_enabler(event, enabler))
1213 continue;
1214 enabler_ref = lttng_event_enabler_ref(event, enabler);
1215 if (!enabler_ref) {
1216 /*
1217 * If no backward ref, create it.
1218 * Add backward ref from event to enabler.
1219 */
1220 enabler_ref = kzalloc(sizeof(*enabler_ref), GFP_KERNEL);
1221 if (!enabler_ref)
1222 return -ENOMEM;
1223 enabler_ref->ref = enabler;
1224 list_add(&enabler_ref->node,
1225 &event->enablers_ref_head);
1226 }
1227
1228 /*
1229 * Link filter bytecodes if not linked yet.
1230 */
1231 lttng_enabler_event_link_bytecode(event, enabler);
1232
1233 /* TODO: merge event context. */
1234 }
1235 return 0;
1236 }
1237
1238 /*
1239 * Called at module load: connect the probe on all enablers matching
1240 * this event.
1241 * Called with sessions lock held.
1242 */
1243 int lttng_fix_pending_events(void)
1244 {
1245 struct lttng_session *session;
1246
1247 list_for_each_entry(session, &sessions, list)
1248 lttng_session_lazy_sync_enablers(session);
1249 return 0;
1250 }
1251
1252 struct lttng_enabler *lttng_enabler_create(enum lttng_enabler_type type,
1253 struct lttng_kernel_event *event_param,
1254 struct lttng_channel *chan)
1255 {
1256 struct lttng_enabler *enabler;
1257
1258 enabler = kzalloc(sizeof(*enabler), GFP_KERNEL);
1259 if (!enabler)
1260 return NULL;
1261 enabler->type = type;
1262 INIT_LIST_HEAD(&enabler->filter_bytecode_head);
1263 memcpy(&enabler->event_param, event_param,
1264 sizeof(enabler->event_param));
1265 enabler->chan = chan;
1266 /* ctx left NULL */
1267 enabler->enabled = 0;
1268 enabler->evtype = LTTNG_TYPE_ENABLER;
1269 mutex_lock(&sessions_mutex);
1270 list_add(&enabler->node, &enabler->chan->session->enablers_head);
1271 lttng_session_lazy_sync_enablers(enabler->chan->session);
1272 mutex_unlock(&sessions_mutex);
1273 return enabler;
1274 }
1275
1276 int lttng_enabler_enable(struct lttng_enabler *enabler)
1277 {
1278 mutex_lock(&sessions_mutex);
1279 enabler->enabled = 1;
1280 lttng_session_lazy_sync_enablers(enabler->chan->session);
1281 mutex_unlock(&sessions_mutex);
1282 return 0;
1283 }
1284
1285 int lttng_enabler_disable(struct lttng_enabler *enabler)
1286 {
1287 mutex_lock(&sessions_mutex);
1288 enabler->enabled = 0;
1289 lttng_session_lazy_sync_enablers(enabler->chan->session);
1290 mutex_unlock(&sessions_mutex);
1291 return 0;
1292 }
1293
1294 int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
1295 struct lttng_kernel_filter_bytecode __user *bytecode)
1296 {
1297 struct lttng_filter_bytecode_node *bytecode_node;
1298 uint32_t bytecode_len;
1299 int ret;
1300
1301 ret = get_user(bytecode_len, &bytecode->len);
1302 if (ret)
1303 return ret;
1304 bytecode_node = kzalloc(sizeof(*bytecode_node) + bytecode_len,
1305 GFP_KERNEL);
1306 if (!bytecode_node)
1307 return -ENOMEM;
1308 ret = copy_from_user(&bytecode_node->bc, bytecode,
1309 sizeof(*bytecode) + bytecode_len);
1310 if (ret)
1311 goto error_free;
1312 bytecode_node->enabler = enabler;
1313 /* Enforce length based on allocated size */
1314 bytecode_node->bc.len = bytecode_len;
1315 list_add_tail(&bytecode_node->node, &enabler->filter_bytecode_head);
1316 lttng_session_lazy_sync_enablers(enabler->chan->session);
1317 return 0;
1318
1319 error_free:
1320 kfree(bytecode_node);
1321 return ret;
1322 }
1323
1324 int lttng_enabler_attach_context(struct lttng_enabler *enabler,
1325 struct lttng_kernel_context *context_param)
1326 {
1327 return -ENOSYS;
1328 }
1329
1330 static
1331 void lttng_enabler_destroy(struct lttng_enabler *enabler)
1332 {
1333 struct lttng_filter_bytecode_node *filter_node, *tmp_filter_node;
1334
1335 /* Destroy filter bytecode */
1336 list_for_each_entry_safe(filter_node, tmp_filter_node,
1337 &enabler->filter_bytecode_head, node) {
1338 kfree(filter_node);
1339 }
1340
1341 /* Destroy contexts */
1342 lttng_destroy_context(enabler->ctx);
1343
1344 list_del(&enabler->node);
1345 kfree(enabler);
1346 }
1347
1348 /*
1349 * lttng_session_sync_enablers should be called just before starting a
1350 * session.
1351 * Should be called with sessions mutex held.
1352 */
1353 static
1354 void lttng_session_sync_enablers(struct lttng_session *session)
1355 {
1356 struct lttng_enabler *enabler;
1357 struct lttng_event *event;
1358
1359 list_for_each_entry(enabler, &session->enablers_head, node)
1360 lttng_enabler_ref_events(enabler);
1361 /*
1362 * For each event, if at least one of its enablers is enabled,
1363 * and its channel and session transient states are enabled, we
1364 * enable the event, else we disable it.
1365 */
1366 list_for_each_entry(event, &session->events, list) {
1367 struct lttng_enabler_ref *enabler_ref;
1368 struct lttng_bytecode_runtime *runtime;
1369 int enabled = 0, has_enablers_without_bytecode = 0;
1370
1371 switch (event->instrumentation) {
1372 case LTTNG_KERNEL_TRACEPOINT:
1373 case LTTNG_KERNEL_SYSCALL:
1374 /* Enable events */
1375 list_for_each_entry(enabler_ref,
1376 &event->enablers_ref_head, node) {
1377 if (enabler_ref->ref->enabled) {
1378 enabled = 1;
1379 break;
1380 }
1381 }
1382 break;
1383 default:
1384 /* Not handled with lazy sync. */
1385 continue;
1386 }
1387 /*
1388 * Enabled state is based on union of enablers, with
1389 * intesection of session and channel transient enable
1390 * states.
1391 */
1392 enabled = enabled && session->tstate && event->chan->tstate;
1393
1394 ACCESS_ONCE(event->enabled) = enabled;
1395 /*
1396 * Sync tracepoint registration with event enabled
1397 * state.
1398 */
1399 if (enabled) {
1400 register_event(event);
1401 } else {
1402 _lttng_event_unregister(event);
1403 }
1404
1405 /* Check if has enablers without bytecode enabled */
1406 list_for_each_entry(enabler_ref,
1407 &event->enablers_ref_head, node) {
1408 if (enabler_ref->ref->enabled
1409 && list_empty(&enabler_ref->ref->filter_bytecode_head)) {
1410 has_enablers_without_bytecode = 1;
1411 break;
1412 }
1413 }
1414 event->has_enablers_without_bytecode =
1415 has_enablers_without_bytecode;
1416
1417 /* Enable filters */
1418 list_for_each_entry(runtime,
1419 &event->bytecode_runtime_head, node)
1420 lttng_filter_sync_state(runtime);
1421 }
1422 }
1423
1424 /*
1425 * Apply enablers to session events, adding events to session if need
1426 * be. It is required after each modification applied to an active
1427 * session, and right before session "start".
1428 * "lazy" sync means we only sync if required.
1429 * Should be called with sessions mutex held.
1430 */
1431 static
1432 void lttng_session_lazy_sync_enablers(struct lttng_session *session)
1433 {
1434 /* We can skip if session is not active */
1435 if (!session->active)
1436 return;
1437 lttng_session_sync_enablers(session);
1438 }
1439
1440 /*
1441 * Serialize at most one packet worth of metadata into a metadata
1442 * channel.
1443 * We grab the metadata cache mutex to get exclusive access to our metadata
1444 * buffer and to the metadata cache. Exclusive access to the metadata buffer
1445 * allows us to do racy operations such as looking for remaining space left in
1446 * packet and write, since mutual exclusion protects us from concurrent writes.
1447 * Mutual exclusion on the metadata cache allow us to read the cache content
1448 * without racing against reallocation of the cache by updates.
1449 * Returns the number of bytes written in the channel, 0 if no data
1450 * was written and a negative value on error.
1451 */
1452 int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
1453 struct channel *chan)
1454 {
1455 struct lib_ring_buffer_ctx ctx;
1456 int ret = 0;
1457 size_t len, reserve_len;
1458
1459 /*
1460 * Ensure we support mutiple get_next / put sequences followed by
1461 * put_next. The metadata cache lock protects reading the metadata
1462 * cache. It can indeed be read concurrently by "get_next_subbuf" and
1463 * "flush" operations on the buffer invoked by different processes.
1464 * Moreover, since the metadata cache memory can be reallocated, we
1465 * need to have exclusive access against updates even though we only
1466 * read it.
1467 */
1468 mutex_lock(&stream->metadata_cache->lock);
1469 WARN_ON(stream->metadata_in < stream->metadata_out);
1470 if (stream->metadata_in != stream->metadata_out)
1471 goto end;
1472
1473 len = stream->metadata_cache->metadata_written -
1474 stream->metadata_in;
1475 if (!len)
1476 goto end;
1477 reserve_len = min_t(size_t,
1478 stream->transport->ops.packet_avail_size(chan),
1479 len);
1480 lib_ring_buffer_ctx_init(&ctx, chan, NULL, reserve_len,
1481 sizeof(char), -1);
1482 /*
1483 * If reservation failed, return an error to the caller.
1484 */
1485 ret = stream->transport->ops.event_reserve(&ctx, 0);
1486 if (ret != 0) {
1487 printk(KERN_WARNING "LTTng: Metadata event reservation failed\n");
1488 goto end;
1489 }
1490 stream->transport->ops.event_write(&ctx,
1491 stream->metadata_cache->data + stream->metadata_in,
1492 reserve_len);
1493 stream->transport->ops.event_commit(&ctx);
1494 stream->metadata_in += reserve_len;
1495 ret = reserve_len;
1496
1497 end:
1498 mutex_unlock(&stream->metadata_cache->lock);
1499 return ret;
1500 }
1501
1502 /*
1503 * Write the metadata to the metadata cache.
1504 * Must be called with sessions_mutex held.
1505 * The metadata cache lock protects us from concurrent read access from
1506 * thread outputting metadata content to ring buffer.
1507 */
1508 int lttng_metadata_printf(struct lttng_session *session,
1509 const char *fmt, ...)
1510 {
1511 char *str;
1512 size_t len;
1513 va_list ap;
1514 struct lttng_metadata_stream *stream;
1515
1516 WARN_ON_ONCE(!ACCESS_ONCE(session->active));
1517
1518 va_start(ap, fmt);
1519 str = kvasprintf(GFP_KERNEL, fmt, ap);
1520 va_end(ap);
1521 if (!str)
1522 return -ENOMEM;
1523
1524 len = strlen(str);
1525 mutex_lock(&session->metadata_cache->lock);
1526 if (session->metadata_cache->metadata_written + len >
1527 session->metadata_cache->cache_alloc) {
1528 char *tmp_cache_realloc;
1529 unsigned int tmp_cache_alloc_size;
1530
1531 tmp_cache_alloc_size = max_t(unsigned int,
1532 session->metadata_cache->cache_alloc + len,
1533 session->metadata_cache->cache_alloc << 1);
1534 tmp_cache_realloc = krealloc(session->metadata_cache->data,
1535 tmp_cache_alloc_size, GFP_KERNEL);
1536 if (!tmp_cache_realloc)
1537 goto err;
1538 session->metadata_cache->cache_alloc = tmp_cache_alloc_size;
1539 session->metadata_cache->data = tmp_cache_realloc;
1540 }
1541 memcpy(session->metadata_cache->data +
1542 session->metadata_cache->metadata_written,
1543 str, len);
1544 session->metadata_cache->metadata_written += len;
1545 mutex_unlock(&session->metadata_cache->lock);
1546 kfree(str);
1547
1548 list_for_each_entry(stream, &session->metadata_cache->metadata_stream, list)
1549 wake_up_interruptible(&stream->read_wait);
1550
1551 return 0;
1552
1553 err:
1554 mutex_unlock(&session->metadata_cache->lock);
1555 kfree(str);
1556 return -ENOMEM;
1557 }
1558
1559 /*
1560 * Must be called with sessions_mutex held.
1561 */
1562 static
1563 int _lttng_field_statedump(struct lttng_session *session,
1564 const struct lttng_event_field *field)
1565 {
1566 int ret = 0;
1567
1568 switch (field->type.atype) {
1569 case atype_integer:
1570 ret = lttng_metadata_printf(session,
1571 " integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s;\n",
1572 field->type.u.basic.integer.size,
1573 field->type.u.basic.integer.alignment,
1574 field->type.u.basic.integer.signedness,
1575 (field->type.u.basic.integer.encoding == lttng_encode_none)
1576 ? "none"
1577 : (field->type.u.basic.integer.encoding == lttng_encode_UTF8)
1578 ? "UTF8"
1579 : "ASCII",
1580 field->type.u.basic.integer.base,
1581 #ifdef __BIG_ENDIAN
1582 field->type.u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
1583 #else
1584 field->type.u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
1585 #endif
1586 field->name);
1587 break;
1588 case atype_enum:
1589 ret = lttng_metadata_printf(session,
1590 " %s _%s;\n",
1591 field->type.u.basic.enumeration.name,
1592 field->name);
1593 break;
1594 case atype_array:
1595 {
1596 const struct lttng_basic_type *elem_type;
1597
1598 elem_type = &field->type.u.array.elem_type;
1599 ret = lttng_metadata_printf(session,
1600 " integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[%u];\n",
1601 elem_type->u.basic.integer.size,
1602 elem_type->u.basic.integer.alignment,
1603 elem_type->u.basic.integer.signedness,
1604 (elem_type->u.basic.integer.encoding == lttng_encode_none)
1605 ? "none"
1606 : (elem_type->u.basic.integer.encoding == lttng_encode_UTF8)
1607 ? "UTF8"
1608 : "ASCII",
1609 elem_type->u.basic.integer.base,
1610 #ifdef __BIG_ENDIAN
1611 elem_type->u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
1612 #else
1613 elem_type->u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
1614 #endif
1615 field->name, field->type.u.array.length);
1616 break;
1617 }
1618 case atype_sequence:
1619 {
1620 const struct lttng_basic_type *elem_type;
1621 const struct lttng_basic_type *length_type;
1622
1623 elem_type = &field->type.u.sequence.elem_type;
1624 length_type = &field->type.u.sequence.length_type;
1625 ret = lttng_metadata_printf(session,
1626 " integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } __%s_length;\n",
1627 length_type->u.basic.integer.size,
1628 (unsigned int) length_type->u.basic.integer.alignment,
1629 length_type->u.basic.integer.signedness,
1630 (length_type->u.basic.integer.encoding == lttng_encode_none)
1631 ? "none"
1632 : ((length_type->u.basic.integer.encoding == lttng_encode_UTF8)
1633 ? "UTF8"
1634 : "ASCII"),
1635 length_type->u.basic.integer.base,
1636 #ifdef __BIG_ENDIAN
1637 length_type->u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
1638 #else
1639 length_type->u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
1640 #endif
1641 field->name);
1642 if (ret)
1643 return ret;
1644
1645 ret = lttng_metadata_printf(session,
1646 " integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[ __%s_length ];\n",
1647 elem_type->u.basic.integer.size,
1648 (unsigned int) elem_type->u.basic.integer.alignment,
1649 elem_type->u.basic.integer.signedness,
1650 (elem_type->u.basic.integer.encoding == lttng_encode_none)
1651 ? "none"
1652 : ((elem_type->u.basic.integer.encoding == lttng_encode_UTF8)
1653 ? "UTF8"
1654 : "ASCII"),
1655 elem_type->u.basic.integer.base,
1656 #ifdef __BIG_ENDIAN
1657 elem_type->u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
1658 #else
1659 elem_type->u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
1660 #endif
1661 field->name,
1662 field->name);
1663 break;
1664 }
1665
1666 case atype_string:
1667 /* Default encoding is UTF8 */
1668 ret = lttng_metadata_printf(session,
1669 " string%s _%s;\n",
1670 field->type.u.basic.string.encoding == lttng_encode_ASCII ?
1671 " { encoding = ASCII; }" : "",
1672 field->name);
1673 break;
1674 default:
1675 WARN_ON_ONCE(1);
1676 return -EINVAL;
1677 }
1678 return ret;
1679 }
1680
1681 static
1682 int _lttng_context_metadata_statedump(struct lttng_session *session,
1683 struct lttng_ctx *ctx)
1684 {
1685 int ret = 0;
1686 int i;
1687
1688 if (!ctx)
1689 return 0;
1690 for (i = 0; i < ctx->nr_fields; i++) {
1691 const struct lttng_ctx_field *field = &ctx->fields[i];
1692
1693 ret = _lttng_field_statedump(session, &field->event_field);
1694 if (ret)
1695 return ret;
1696 }
1697 return ret;
1698 }
1699
1700 static
1701 int _lttng_fields_metadata_statedump(struct lttng_session *session,
1702 struct lttng_event *event)
1703 {
1704 const struct lttng_event_desc *desc = event->desc;
1705 int ret = 0;
1706 int i;
1707
1708 for (i = 0; i < desc->nr_fields; i++) {
1709 const struct lttng_event_field *field = &desc->fields[i];
1710
1711 ret = _lttng_field_statedump(session, field);
1712 if (ret)
1713 return ret;
1714 }
1715 return ret;
1716 }
1717
1718 /*
1719 * Must be called with sessions_mutex held.
1720 */
1721 static
1722 int _lttng_event_metadata_statedump(struct lttng_session *session,
1723 struct lttng_channel *chan,
1724 struct lttng_event *event)
1725 {
1726 int ret = 0;
1727
1728 if (event->metadata_dumped || !ACCESS_ONCE(session->active))
1729 return 0;
1730 if (chan->channel_type == METADATA_CHANNEL)
1731 return 0;
1732
1733 ret = lttng_metadata_printf(session,
1734 "event {\n"
1735 " name = \"%s\";\n"
1736 " id = %u;\n"
1737 " stream_id = %u;\n",
1738 event->desc->name,
1739 event->id,
1740 event->chan->id);
1741 if (ret)
1742 goto end;
1743
1744 if (event->ctx) {
1745 ret = lttng_metadata_printf(session,
1746 " context := struct {\n");
1747 if (ret)
1748 goto end;
1749 }
1750 ret = _lttng_context_metadata_statedump(session, event->ctx);
1751 if (ret)
1752 goto end;
1753 if (event->ctx) {
1754 ret = lttng_metadata_printf(session,
1755 " };\n");
1756 if (ret)
1757 goto end;
1758 }
1759
1760 ret = lttng_metadata_printf(session,
1761 " fields := struct {\n"
1762 );
1763 if (ret)
1764 goto end;
1765
1766 ret = _lttng_fields_metadata_statedump(session, event);
1767 if (ret)
1768 goto end;
1769
1770 /*
1771 * LTTng space reservation can only reserve multiples of the
1772 * byte size.
1773 */
1774 ret = lttng_metadata_printf(session,
1775 " };\n"
1776 "};\n\n");
1777 if (ret)
1778 goto end;
1779
1780 event->metadata_dumped = 1;
1781 end:
1782 return ret;
1783
1784 }
1785
1786 /*
1787 * Must be called with sessions_mutex held.
1788 */
1789 static
1790 int _lttng_channel_metadata_statedump(struct lttng_session *session,
1791 struct lttng_channel *chan)
1792 {
1793 int ret = 0;
1794
1795 if (chan->metadata_dumped || !ACCESS_ONCE(session->active))
1796 return 0;
1797
1798 if (chan->channel_type == METADATA_CHANNEL)
1799 return 0;
1800
1801 WARN_ON_ONCE(!chan->header_type);
1802 ret = lttng_metadata_printf(session,
1803 "stream {\n"
1804 " id = %u;\n"
1805 " event.header := %s;\n"
1806 " packet.context := struct packet_context;\n",
1807 chan->id,
1808 chan->header_type == 1 ? "struct event_header_compact" :
1809 "struct event_header_large");
1810 if (ret)
1811 goto end;
1812
1813 if (chan->ctx) {
1814 ret = lttng_metadata_printf(session,
1815 " event.context := struct {\n");
1816 if (ret)
1817 goto end;
1818 }
1819 ret = _lttng_context_metadata_statedump(session, chan->ctx);
1820 if (ret)
1821 goto end;
1822 if (chan->ctx) {
1823 ret = lttng_metadata_printf(session,
1824 " };\n");
1825 if (ret)
1826 goto end;
1827 }
1828
1829 ret = lttng_metadata_printf(session,
1830 "};\n\n");
1831
1832 chan->metadata_dumped = 1;
1833 end:
1834 return ret;
1835 }
1836
1837 /*
1838 * Must be called with sessions_mutex held.
1839 */
1840 static
1841 int _lttng_stream_packet_context_declare(struct lttng_session *session)
1842 {
1843 return lttng_metadata_printf(session,
1844 "struct packet_context {\n"
1845 " uint64_clock_monotonic_t timestamp_begin;\n"
1846 " uint64_clock_monotonic_t timestamp_end;\n"
1847 " uint64_t content_size;\n"
1848 " uint64_t packet_size;\n"
1849 " unsigned long events_discarded;\n"
1850 " uint32_t cpu_id;\n"
1851 "};\n\n"
1852 );
1853 }
1854
1855 /*
1856 * Compact header:
1857 * id: range: 0 - 30.
1858 * id 31 is reserved to indicate an extended header.
1859 *
1860 * Large header:
1861 * id: range: 0 - 65534.
1862 * id 65535 is reserved to indicate an extended header.
1863 *
1864 * Must be called with sessions_mutex held.
1865 */
1866 static
1867 int _lttng_event_header_declare(struct lttng_session *session)
1868 {
1869 return lttng_metadata_printf(session,
1870 "struct event_header_compact {\n"
1871 " enum : uint5_t { compact = 0 ... 30, extended = 31 } id;\n"
1872 " variant <id> {\n"
1873 " struct {\n"
1874 " uint27_clock_monotonic_t timestamp;\n"
1875 " } compact;\n"
1876 " struct {\n"
1877 " uint32_t id;\n"
1878 " uint64_clock_monotonic_t timestamp;\n"
1879 " } extended;\n"
1880 " } v;\n"
1881 "} align(%u);\n"
1882 "\n"
1883 "struct event_header_large {\n"
1884 " enum : uint16_t { compact = 0 ... 65534, extended = 65535 } id;\n"
1885 " variant <id> {\n"
1886 " struct {\n"
1887 " uint32_clock_monotonic_t timestamp;\n"
1888 " } compact;\n"
1889 " struct {\n"
1890 " uint32_t id;\n"
1891 " uint64_clock_monotonic_t timestamp;\n"
1892 " } extended;\n"
1893 " } v;\n"
1894 "} align(%u);\n\n",
1895 lttng_alignof(uint32_t) * CHAR_BIT,
1896 lttng_alignof(uint16_t) * CHAR_BIT
1897 );
1898 }
1899
1900 /*
1901 * Approximation of NTP time of day to clock monotonic correlation,
1902 * taken at start of trace.
1903 * Yes, this is only an approximation. Yes, we can (and will) do better
1904 * in future versions.
1905 */
1906 static
1907 uint64_t measure_clock_offset(void)
1908 {
1909 uint64_t offset, monotonic[2], realtime;
1910 struct timespec rts = { 0, 0 };
1911 unsigned long flags;
1912
1913 /* Disable interrupts to increase correlation precision. */
1914 local_irq_save(flags);
1915 monotonic[0] = trace_clock_read64();
1916 getnstimeofday(&rts);
1917 monotonic[1] = trace_clock_read64();
1918 local_irq_restore(flags);
1919
1920 offset = (monotonic[0] + monotonic[1]) >> 1;
1921 realtime = (uint64_t) rts.tv_sec * NSEC_PER_SEC;
1922 realtime += rts.tv_nsec;
1923 offset = realtime - offset;
1924 return offset;
1925 }
1926
1927 /*
1928 * Output metadata into this session's metadata buffers.
1929 * Must be called with sessions_mutex held.
1930 */
1931 static
1932 int _lttng_session_metadata_statedump(struct lttng_session *session)
1933 {
1934 unsigned char *uuid_c = session->uuid.b;
1935 unsigned char uuid_s[37], clock_uuid_s[BOOT_ID_LEN];
1936 struct lttng_channel *chan;
1937 struct lttng_event *event;
1938 int ret = 0;
1939
1940 if (!ACCESS_ONCE(session->active))
1941 return 0;
1942 if (session->metadata_dumped)
1943 goto skip_session;
1944
1945 snprintf(uuid_s, sizeof(uuid_s),
1946 "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
1947 uuid_c[0], uuid_c[1], uuid_c[2], uuid_c[3],
1948 uuid_c[4], uuid_c[5], uuid_c[6], uuid_c[7],
1949 uuid_c[8], uuid_c[9], uuid_c[10], uuid_c[11],
1950 uuid_c[12], uuid_c[13], uuid_c[14], uuid_c[15]);
1951
1952 ret = lttng_metadata_printf(session,
1953 "typealias integer { size = 8; align = %u; signed = false; } := uint8_t;\n"
1954 "typealias integer { size = 16; align = %u; signed = false; } := uint16_t;\n"
1955 "typealias integer { size = 32; align = %u; signed = false; } := uint32_t;\n"
1956 "typealias integer { size = 64; align = %u; signed = false; } := uint64_t;\n"
1957 "typealias integer { size = %u; align = %u; signed = false; } := unsigned long;\n"
1958 "typealias integer { size = 5; align = 1; signed = false; } := uint5_t;\n"
1959 "typealias integer { size = 27; align = 1; signed = false; } := uint27_t;\n"
1960 "\n"
1961 "trace {\n"
1962 " major = %u;\n"
1963 " minor = %u;\n"
1964 " uuid = \"%s\";\n"
1965 " byte_order = %s;\n"
1966 " packet.header := struct {\n"
1967 " uint32_t magic;\n"
1968 " uint8_t uuid[16];\n"
1969 " uint32_t stream_id;\n"
1970 " };\n"
1971 "};\n\n",
1972 lttng_alignof(uint8_t) * CHAR_BIT,
1973 lttng_alignof(uint16_t) * CHAR_BIT,
1974 lttng_alignof(uint32_t) * CHAR_BIT,
1975 lttng_alignof(uint64_t) * CHAR_BIT,
1976 sizeof(unsigned long) * CHAR_BIT,
1977 lttng_alignof(unsigned long) * CHAR_BIT,
1978 CTF_SPEC_MAJOR,
1979 CTF_SPEC_MINOR,
1980 uuid_s,
1981 #ifdef __BIG_ENDIAN
1982 "be"
1983 #else
1984 "le"
1985 #endif
1986 );
1987 if (ret)
1988 goto end;
1989
1990 ret = lttng_metadata_printf(session,
1991 "env {\n"
1992 " hostname = \"%s\";\n"
1993 " domain = \"kernel\";\n"
1994 " sysname = \"%s\";\n"
1995 " kernel_release = \"%s\";\n"
1996 " kernel_version = \"%s\";\n"
1997 " tracer_name = \"lttng-modules\";\n"
1998 " tracer_major = %d;\n"
1999 " tracer_minor = %d;\n"
2000 " tracer_patchlevel = %d;\n"
2001 "};\n\n",
2002 current->nsproxy->uts_ns->name.nodename,
2003 utsname()->sysname,
2004 utsname()->release,
2005 utsname()->version,
2006 LTTNG_MODULES_MAJOR_VERSION,
2007 LTTNG_MODULES_MINOR_VERSION,
2008 LTTNG_MODULES_PATCHLEVEL_VERSION
2009 );
2010 if (ret)
2011 goto end;
2012
2013 ret = lttng_metadata_printf(session,
2014 "clock {\n"
2015 " name = %s;\n",
2016 "monotonic"
2017 );
2018 if (ret)
2019 goto end;
2020
2021 if (!trace_clock_uuid(clock_uuid_s)) {
2022 ret = lttng_metadata_printf(session,
2023 " uuid = \"%s\";\n",
2024 clock_uuid_s
2025 );
2026 if (ret)
2027 goto end;
2028 }
2029
2030 ret = lttng_metadata_printf(session,
2031 " description = \"Monotonic Clock\";\n"
2032 " freq = %llu; /* Frequency, in Hz */\n"
2033 " /* clock value offset from Epoch is: offset * (1/freq) */\n"
2034 " offset = %llu;\n"
2035 "};\n\n",
2036 (unsigned long long) trace_clock_freq(),
2037 (unsigned long long) measure_clock_offset()
2038 );
2039 if (ret)
2040 goto end;
2041
2042 ret = lttng_metadata_printf(session,
2043 "typealias integer {\n"
2044 " size = 27; align = 1; signed = false;\n"
2045 " map = clock.monotonic.value;\n"
2046 "} := uint27_clock_monotonic_t;\n"
2047 "\n"
2048 "typealias integer {\n"
2049 " size = 32; align = %u; signed = false;\n"
2050 " map = clock.monotonic.value;\n"
2051 "} := uint32_clock_monotonic_t;\n"
2052 "\n"
2053 "typealias integer {\n"
2054 " size = 64; align = %u; signed = false;\n"
2055 " map = clock.monotonic.value;\n"
2056 "} := uint64_clock_monotonic_t;\n\n",
2057 lttng_alignof(uint32_t) * CHAR_BIT,
2058 lttng_alignof(uint64_t) * CHAR_BIT
2059 );
2060 if (ret)
2061 goto end;
2062
2063 ret = _lttng_stream_packet_context_declare(session);
2064 if (ret)
2065 goto end;
2066
2067 ret = _lttng_event_header_declare(session);
2068 if (ret)
2069 goto end;
2070
2071 skip_session:
2072 list_for_each_entry(chan, &session->chan, list) {
2073 ret = _lttng_channel_metadata_statedump(session, chan);
2074 if (ret)
2075 goto end;
2076 }
2077
2078 list_for_each_entry(event, &session->events, list) {
2079 ret = _lttng_event_metadata_statedump(session, event->chan, event);
2080 if (ret)
2081 goto end;
2082 }
2083 session->metadata_dumped = 1;
2084 end:
2085 return ret;
2086 }
2087
2088 /**
2089 * lttng_transport_register - LTT transport registration
2090 * @transport: transport structure
2091 *
2092 * Registers a transport which can be used as output to extract the data out of
2093 * LTTng. The module calling this registration function must ensure that no
2094 * trap-inducing code will be executed by the transport functions. E.g.
2095 * vmalloc_sync_all() must be called between a vmalloc and the moment the memory
2096 * is made visible to the transport function. This registration acts as a
2097 * vmalloc_sync_all. Therefore, only if the module allocates virtual memory
2098 * after its registration must it synchronize the TLBs.
2099 */
2100 void lttng_transport_register(struct lttng_transport *transport)
2101 {
2102 /*
2103 * Make sure no page fault can be triggered by the module about to be
2104 * registered. We deal with this here so we don't have to call
2105 * vmalloc_sync_all() in each module's init.
2106 */
2107 wrapper_vmalloc_sync_all();
2108
2109 mutex_lock(&sessions_mutex);
2110 list_add_tail(&transport->node, &lttng_transport_list);
2111 mutex_unlock(&sessions_mutex);
2112 }
2113 EXPORT_SYMBOL_GPL(lttng_transport_register);
2114
2115 /**
2116 * lttng_transport_unregister - LTT transport unregistration
2117 * @transport: transport structure
2118 */
2119 void lttng_transport_unregister(struct lttng_transport *transport)
2120 {
2121 mutex_lock(&sessions_mutex);
2122 list_del(&transport->node);
2123 mutex_unlock(&sessions_mutex);
2124 }
2125 EXPORT_SYMBOL_GPL(lttng_transport_unregister);
2126
2127 static int __init lttng_events_init(void)
2128 {
2129 int ret;
2130
2131 ret = wrapper_lttng_fixup_sig(THIS_MODULE);
2132 if (ret)
2133 return ret;
2134 ret = wrapper_get_pfnblock_flags_mask_init();
2135 if (ret)
2136 return ret;
2137 ret = lttng_context_init();
2138 if (ret)
2139 return ret;
2140 ret = lttng_tracepoint_init();
2141 if (ret)
2142 goto error_tp;
2143 event_cache = KMEM_CACHE(lttng_event, 0);
2144 if (!event_cache) {
2145 ret = -ENOMEM;
2146 goto error_kmem;
2147 }
2148 ret = lttng_abi_init();
2149 if (ret)
2150 goto error_abi;
2151 ret = lttng_logger_init();
2152 if (ret)
2153 goto error_logger;
2154 return 0;
2155
2156 error_logger:
2157 lttng_abi_exit();
2158 error_abi:
2159 kmem_cache_destroy(event_cache);
2160 error_kmem:
2161 lttng_tracepoint_exit();
2162 error_tp:
2163 lttng_context_exit();
2164 return ret;
2165 }
2166
2167 module_init(lttng_events_init);
2168
2169 static void __exit lttng_events_exit(void)
2170 {
2171 struct lttng_session *session, *tmpsession;
2172
2173 lttng_logger_exit();
2174 lttng_abi_exit();
2175 list_for_each_entry_safe(session, tmpsession, &sessions, list)
2176 lttng_session_destroy(session);
2177 kmem_cache_destroy(event_cache);
2178 lttng_tracepoint_exit();
2179 lttng_context_exit();
2180 }
2181
2182 module_exit(lttng_events_exit);
2183
2184 MODULE_LICENSE("GPL and additional rights");
2185 MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
2186 MODULE_DESCRIPTION("LTTng Events");
2187 MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
2188 __stringify(LTTNG_MODULES_MINOR_VERSION) "."
2189 __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
2190 LTTNG_MODULES_EXTRAVERSION);
This page took 0.110329 seconds and 5 git commands to generate.