Commit | Line | Data |
---|---|---|
1c25284c MD |
1 | /** |
2 | * ltt-type-serializer.c | |
3 | * | |
4 | * LTTng specialized type serializer. | |
5 | * | |
6 | * Copyright Mathieu Desnoyers, 2008. | |
7 | * | |
8 | * Dual LGPL v2.1/GPL v2 license. | |
9 | */ | |
10 | #include <linux/module.h> | |
11 | ||
12 | #include "ltt-type-serializer.h" | |
13 | #include "ltt-relay-lockless.h" | |
14 | ||
15 | notrace | |
16 | void _ltt_specialized_trace(void *probe_data, | |
17 | void *serialize_private, unsigned int data_size, | |
18 | unsigned int largest_align) | |
19 | { | |
20 | struct ltt_event *event = probe_data; | |
21 | int ret; | |
22 | uint16_t eID; | |
23 | size_t slot_size; | |
24 | struct ltt_chanbuf *buf; | |
25 | struct ltt_channel *chan; | |
26 | struct ltt_session *session; | |
27 | uint64_t tsc; | |
28 | long buf_offset; | |
29 | int cpu; | |
30 | unsigned int rflags; | |
31 | ||
32 | /* disabled from tracepoints rcu_read_lock_sched_notrace(); */ | |
33 | cpu = smp_processor_id(); | |
34 | __get_cpu_var(ltt_nesting)++; | |
35 | /* | |
36 | * asm volatile and "memory" clobber prevent the compiler from moving | |
37 | * instructions out of the ltt nesting count. This is required to ensure | |
38 | * that probe side-effects which can cause recursion (e.g. unforeseen | |
39 | * traps, divisions by 0, ...) are triggered within the incremented | |
40 | * nesting count section. | |
41 | */ | |
42 | barrier(); | |
43 | eID = event->id; | |
44 | chan = event->chan; | |
45 | session = chan->session; | |
46 | ||
47 | if (unlikely(!session->active)) | |
48 | goto skip; | |
49 | if (unlikely(!ltt_run_filter(session, chan, event))) | |
50 | goto skip; | |
51 | #ifdef LTT_DEBUG_EVENT_SIZE | |
52 | rflags = LTT_RFLAG_ID_SIZE; | |
53 | #else | |
54 | if (unlikely(eID >= LTT_FREE_EVENTS)) | |
55 | rflags = LTT_RFLAG_ID; | |
56 | else | |
57 | rflags = 0; | |
58 | #endif | |
59 | /* reserve space : header and data */ | |
60 | ret = ltt_reserve_slot(chan, trace, data_size, largest_align, | |
61 | cpu, &buf, &slot_size, &buf_offset, &tsc, | |
62 | &rflags); | |
63 | if (unlikely(ret < 0)) | |
64 | goto skip; /* buffer full */ | |
65 | ||
66 | /* Out-of-order write : header and data */ | |
67 | buf_offset = ltt_write_event_header(&buf->a, &chan->a, | |
68 | buf_offset, eID, data_size, | |
69 | tsc, rflags); | |
70 | if (data_size) { | |
71 | buf_offset += ltt_align(buf_offset, largest_align); | |
72 | ltt_relay_write(&buf->a, &chan->a, buf_offset, | |
73 | serialize_private, data_size); | |
74 | buf_offset += data_size; | |
75 | } | |
76 | /* Out-of-order commit */ | |
77 | ltt_commit_slot(buf, chan, buf_offset, data_size, slot_size); | |
78 | skip: | |
79 | /* | |
80 | * asm volatile and "memory" clobber prevent the compiler from moving | |
81 | * instructions out of the ltt nesting count. This is required to ensure | |
82 | * that probe side-effects which can cause recursion (e.g. unforeseen | |
83 | * traps, divisions by 0, ...) are triggered within the incremented | |
84 | * nesting count section. | |
85 | */ | |
86 | barrier(); | |
87 | __get_cpu_var(ltt_nesting)--; | |
88 | /* disabled from tracepoints rcu_read_unlock_sched_notrace(); */ | |
89 | } | |
90 | EXPORT_SYMBOL_GPL(_ltt_specialized_trace); | |
91 | ||
92 | MODULE_LICENSE("GPL and additional rights"); | |
93 | MODULE_AUTHOR("Mathieu Desnoyers"); | |
94 | MODULE_DESCRIPTION("LTT type serializer"); |