2 * ltt-type-serializer.c
4 * LTTng specialized type serializer.
6 * Copyright Mathieu Desnoyers, 2008.
8 * Dual LGPL v2.1/GPL v2 license.
10 #include <linux/module.h>
12 #include "ltt-type-serializer.h"
13 #include "ltt-relay-lockless.h"
16 void _ltt_specialized_trace(const struct marker
*mdata
, void *probe_data
,
17 void *serialize_private
, unsigned int data_size
,
18 unsigned int largest_align
)
23 unsigned int chan_index
;
24 struct ltt_chanbuf
*buf
;
25 struct ltt_chan
*chan
;
26 struct ltt_trace
*trace
;
33 * If we get here, it's probably because we have useful work to do.
35 if (unlikely(ltt_traces
.num_active_traces
== 0))
38 rcu_read_lock_sched_notrace();
39 cpu
= smp_processor_id();
40 __get_cpu_var(ltt_nesting
)++;
42 * asm volatile and "memory" clobber prevent the compiler from moving
43 * instructions out of the ltt nesting count. This is required to ensure
44 * that probe side-effects which can cause recursion (e.g. unforeseen
45 * traps, divisions by 0, ...) are triggered within the incremented
46 * nesting count section.
49 eID
= mdata
->event_id
;
50 chan_index
= mdata
->channel_id
;
53 * Iterate on each trace, typically small number of active traces,
54 * list iteration with prefetch is usually slower.
56 __list_for_each_entry_rcu(trace
, <t_traces
.head
, list
) {
57 if (unlikely(!trace
->active
))
59 if (unlikely(!ltt_run_filter(trace
, eID
)))
61 #ifdef LTT_DEBUG_EVENT_SIZE
62 rflags
= LTT_RFLAG_ID_SIZE
;
64 if (unlikely(eID
>= LTT_FREE_EVENTS
))
65 rflags
= LTT_RFLAG_ID
;
70 * Skip channels added after trace creation.
72 if (unlikely(chan_index
>= trace
->nr_channels
))
74 chan
= &trace
->channels
[chan_index
];
78 /* reserve space : header and data */
79 ret
= ltt_reserve_slot(chan
, trace
, data_size
, largest_align
,
80 cpu
, &buf
, &slot_size
, &buf_offset
, &tsc
,
82 if (unlikely(ret
< 0))
83 continue; /* buffer full */
85 /* Out-of-order write : header and data */
86 buf_offset
= ltt_write_event_header(&buf
->a
, &chan
->a
,
87 buf_offset
, eID
, data_size
,
90 buf_offset
+= ltt_align(buf_offset
, largest_align
);
91 ltt_relay_write(&buf
->a
, &chan
->a
, buf_offset
,
92 serialize_private
, data_size
);
93 buf_offset
+= data_size
;
95 /* Out-of-order commit */
96 ltt_commit_slot(buf
, chan
, buf_offset
, data_size
, slot_size
);
99 * asm volatile and "memory" clobber prevent the compiler from moving
100 * instructions out of the ltt nesting count. This is required to ensure
101 * that probe side-effects which can cause recursion (e.g. unforeseen
102 * traps, divisions by 0, ...) are triggered within the incremented
103 * nesting count section.
106 __get_cpu_var(ltt_nesting
)--;
107 rcu_read_unlock_sched_notrace();
109 EXPORT_SYMBOL_GPL(_ltt_specialized_trace
);
111 MODULE_LICENSE("GPL and additional rights");
112 MODULE_AUTHOR("Mathieu Desnoyers");
113 MODULE_DESCRIPTION("LTT type serializer");
This page took 0.031883 seconds and 4 git commands to generate.