Commit | Line | Data |
---|---|---|
9dad1eb8 PMF |
1 | /* |
2 | * Copyright (C) 2005,2006,2008 Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca) | |
3 | * | |
4 | * This contains the definitions for the Linux Trace Toolkit tracer. | |
5 | */ | |
6 | ||
7 | #ifndef _LTT_TRACER_H | |
8 | #define _LTT_TRACER_H | |
9 | ||
b6bf28ec PMF |
10 | //ust// #include <stdarg.h> |
11 | //ust// #include <linux/types.h> | |
12 | //ust// #include <linux/limits.h> | |
13 | //ust// #include <linux/list.h> | |
14 | //ust// #include <linux/cache.h> | |
15 | //ust// #include <linux/kernel.h> | |
16 | //ust// #include <linux/timex.h> | |
17 | //ust// #include <linux/wait.h> | |
18 | //ust// #include <linux/ltt-relay.h> | |
19 | //ust// #include <linux/ltt-channels.h> | |
20 | //ust// #include <linux/ltt-core.h> | |
21 | //ust// #include <linux/marker.h> | |
22 | //ust// #include <linux/trace-clock.h> | |
23 | //ust// #include <asm/atomic.h> | |
24 | //ust// #include <asm/local.h> | |
25 | #include <sys/types.h> | |
9dad1eb8 | 26 | #include <stdarg.h> |
b6bf28ec PMF |
27 | #include "relay.h" |
28 | #include "list.h" | |
29 | #include "kernelcompat.h" | |
30 | #include "channels.h" | |
bb07823d | 31 | #include "tracercore.h" |
8d938dbd | 32 | #include "marker.h" |
9dad1eb8 PMF |
33 | |
34 | /* Number of bytes to log with a read/write event */ | |
35 | #define LTT_LOG_RW_SIZE 32L | |
36 | ||
37 | /* Interval (in jiffies) at which the LTT per-CPU timer fires */ | |
38 | #define LTT_PERCPU_TIMER_INTERVAL 1 | |
39 | ||
40 | #ifndef LTT_ARCH_TYPE | |
41 | #define LTT_ARCH_TYPE LTT_ARCH_TYPE_UNDEFINED | |
42 | #endif | |
43 | ||
44 | #ifndef LTT_ARCH_VARIANT | |
45 | #define LTT_ARCH_VARIANT LTT_ARCH_VARIANT_NONE | |
46 | #endif | |
47 | ||
48 | struct ltt_active_marker; | |
49 | ||
50 | /* Maximum number of callbacks per marker */ | |
51 | #define LTT_NR_CALLBACKS 10 | |
52 | ||
53 | struct ltt_serialize_closure; | |
54 | struct ltt_probe_private_data; | |
55 | ||
56 | /* Serialization callback '%k' */ | |
57 | typedef size_t (*ltt_serialize_cb)(struct rchan_buf *buf, size_t buf_offset, | |
58 | struct ltt_serialize_closure *closure, | |
59 | void *serialize_private, int *largest_align, | |
60 | const char *fmt, va_list *args); | |
61 | ||
62 | struct ltt_serialize_closure { | |
63 | ltt_serialize_cb *callbacks; | |
64 | long cb_args[LTT_NR_CALLBACKS]; | |
65 | unsigned int cb_idx; | |
66 | }; | |
67 | ||
68 | size_t ltt_serialize_data(struct rchan_buf *buf, size_t buf_offset, | |
69 | struct ltt_serialize_closure *closure, | |
70 | void *serialize_private, | |
71 | int *largest_align, const char *fmt, va_list *args); | |
72 | ||
8d938dbd PMF |
73 | struct ltt_available_probe { |
74 | const char *name; /* probe name */ | |
75 | const char *format; | |
76 | marker_probe_func *probe_func; | |
77 | ltt_serialize_cb callbacks[LTT_NR_CALLBACKS]; | |
78 | struct list_head node; /* registered probes list */ | |
79 | }; | |
9dad1eb8 PMF |
80 | |
81 | struct ltt_probe_private_data { | |
82 | struct ltt_trace_struct *trace; /* | |
83 | * Target trace, for metadata | |
84 | * or statedump. | |
85 | */ | |
86 | ltt_serialize_cb serializer; /* | |
87 | * Serialization function override. | |
88 | */ | |
89 | void *serialize_private; /* | |
90 | * Private data for serialization | |
91 | * functions. | |
92 | */ | |
93 | }; | |
94 | ||
95 | enum ltt_channels { | |
96 | LTT_CHANNEL_METADATA, | |
b6bf28ec | 97 | LTT_CHANNEL_UST, |
9dad1eb8 PMF |
98 | }; |
99 | ||
100 | struct ltt_active_marker { | |
101 | struct list_head node; /* active markers list */ | |
102 | const char *channel; | |
103 | const char *name; | |
104 | const char *format; | |
105 | struct ltt_available_probe *probe; | |
106 | }; | |
107 | ||
b6bf28ec | 108 | struct marker; //ust// |
9dad1eb8 PMF |
109 | extern void ltt_vtrace(const struct marker *mdata, void *probe_data, |
110 | void *call_data, const char *fmt, va_list *args); | |
111 | extern void ltt_trace(const struct marker *mdata, void *probe_data, | |
112 | void *call_data, const char *fmt, ...); | |
113 | ||
114 | /* | |
115 | * Unique ID assigned to each registered probe. | |
116 | */ | |
117 | enum marker_id { | |
118 | MARKER_ID_SET_MARKER_ID = 0, /* Static IDs available (range 0-7) */ | |
119 | MARKER_ID_SET_MARKER_FORMAT, | |
120 | MARKER_ID_COMPACT, /* Compact IDs (range: 8-127) */ | |
121 | MARKER_ID_DYNAMIC, /* Dynamic IDs (range: 128-65535) */ | |
122 | }; | |
123 | ||
124 | /* static ids 0-1 reserved for internal use. */ | |
125 | #define MARKER_CORE_IDS 2 | |
126 | static inline enum marker_id marker_id_type(uint16_t id) | |
127 | { | |
128 | if (id < MARKER_CORE_IDS) | |
129 | return (enum marker_id)id; | |
130 | else | |
131 | return MARKER_ID_DYNAMIC; | |
132 | } | |
133 | ||
b6bf28ec | 134 | //ust// #ifdef CONFIG_LTT |
9dad1eb8 PMF |
135 | |
136 | struct user_dbg_data { | |
137 | unsigned long avail_size; | |
138 | unsigned long write; | |
139 | unsigned long read; | |
140 | }; | |
141 | ||
142 | struct ltt_trace_ops { | |
143 | /* First 32 bytes cache-hot cacheline */ | |
144 | int (*reserve_slot) (struct ltt_trace_struct *trace, | |
145 | struct ltt_channel_struct *channel, | |
146 | void **transport_data, size_t data_size, | |
147 | size_t *slot_size, long *buf_offset, u64 *tsc, | |
148 | unsigned int *rflags, | |
149 | int largest_align, | |
150 | int cpu); | |
151 | void (*commit_slot) (struct ltt_channel_struct *channel, | |
152 | void **transport_data, long buf_offset, | |
153 | size_t slot_size); | |
154 | void (*wakeup_channel) (struct ltt_channel_struct *ltt_channel); | |
bb07823d PMF |
155 | int (*user_blocking) (struct ltt_trace_struct *trace, |
156 | unsigned int index, size_t data_size, | |
157 | struct user_dbg_data *dbg); | |
158 | /* End of first 32 bytes cacheline */ | |
159 | int (*create_dirs) (struct ltt_trace_struct *new_trace); | |
160 | void (*remove_dirs) (struct ltt_trace_struct *new_trace); | |
b6bf28ec PMF |
161 | int (*create_channel) (const char *trace_name, |
162 | struct ltt_trace_struct *trace, | |
163 | struct dentry *dir, const char *channel_name, | |
164 | struct ltt_channel_struct *ltt_chan, | |
165 | unsigned int subbuf_size, | |
166 | unsigned int n_subbufs, int overwrite); | |
167 | void (*finish_channel) (struct ltt_channel_struct *channel); | |
168 | void (*remove_channel) (struct ltt_channel_struct *channel); | |
169 | void (*user_errors) (struct ltt_trace_struct *trace, | |
170 | unsigned int index, size_t data_size, | |
171 | struct user_dbg_data *dbg, int cpu); | |
172 | //ust// #ifdef CONFIG_HOTPLUG_CPU | |
173 | //ust// int (*handle_cpuhp) (struct notifier_block *nb, | |
174 | //ust// unsigned long action, void *hcpu, | |
175 | //ust// struct ltt_trace_struct *trace); | |
176 | //ust// #endif | |
9dad1eb8 PMF |
177 | } ____cacheline_aligned; |
178 | ||
179 | struct ltt_transport { | |
180 | char *name; | |
181 | struct module *owner; | |
182 | struct list_head node; | |
183 | struct ltt_trace_ops ops; | |
184 | }; | |
185 | ||
186 | enum trace_mode { LTT_TRACE_NORMAL, LTT_TRACE_FLIGHT, LTT_TRACE_HYBRID }; | |
187 | ||
188 | #define CHANNEL_FLAG_ENABLE (1U<<0) | |
189 | #define CHANNEL_FLAG_OVERWRITE (1U<<1) | |
190 | ||
191 | /* Per-trace information - each trace/flight recorder represented by one */ | |
192 | struct ltt_trace_struct { | |
193 | /* First 32 bytes cache-hot cacheline */ | |
194 | struct list_head list; | |
195 | struct ltt_trace_ops *ops; | |
196 | int active; | |
197 | /* Second 32 bytes cache-hot cacheline */ | |
198 | struct ltt_channel_struct *channels; | |
199 | unsigned int nr_channels; | |
200 | u32 freq_scale; | |
201 | u64 start_freq; | |
202 | u64 start_tsc; | |
203 | unsigned long long start_monotonic; | |
204 | struct timeval start_time; | |
205 | struct ltt_channel_setting *settings; | |
206 | struct { | |
207 | struct dentry *trace_root; | |
208 | } dentry; | |
b6bf28ec | 209 | //ust// struct rchan_callbacks callbacks; |
9dad1eb8 PMF |
210 | struct kref kref; /* Each channel has a kref of the trace struct */ |
211 | struct ltt_transport *transport; | |
212 | struct kref ltt_transport_kref; | |
b6bf28ec | 213 | //ust// wait_queue_head_t kref_wq; /* Place for ltt_trace_destroy to sleep */ |
9dad1eb8 PMF |
214 | char trace_name[NAME_MAX]; |
215 | } ____cacheline_aligned; | |
216 | ||
217 | /* Hardcoded event headers | |
218 | * | |
219 | * event header for a trace with active heartbeat : 27 bits timestamps | |
220 | * | |
221 | * headers are 32-bits aligned. In order to insure such alignment, a dynamic per | |
222 | * trace alignment value must be done. | |
223 | * | |
224 | * Remember that the C compiler does align each member on the boundary | |
225 | * equivalent to their own size. | |
226 | * | |
227 | * As relay subbuffers are aligned on pages, we are sure that they are 4 and 8 | |
228 | * bytes aligned, so the buffer header and trace header are aligned. | |
229 | * | |
230 | * Event headers are aligned depending on the trace alignment option. | |
231 | * | |
232 | * Note using C structure bitfields for cross-endianness and portability | |
233 | * concerns. | |
234 | */ | |
235 | ||
236 | #define LTT_RESERVED_EVENTS 3 | |
237 | #define LTT_EVENT_BITS 5 | |
238 | #define LTT_FREE_EVENTS ((1 << LTT_EVENT_BITS) - LTT_RESERVED_EVENTS) | |
239 | #define LTT_TSC_BITS 27 | |
240 | #define LTT_TSC_MASK ((1 << LTT_TSC_BITS) - 1) | |
241 | ||
242 | struct ltt_event_header { | |
243 | u32 id_time; /* 5 bits event id (MSB); 27 bits time (LSB) */ | |
244 | }; | |
245 | ||
246 | /* Reservation flags */ | |
247 | #define LTT_RFLAG_ID (1 << 0) | |
248 | #define LTT_RFLAG_ID_SIZE (1 << 1) | |
249 | #define LTT_RFLAG_ID_SIZE_TSC (1 << 2) | |
250 | ||
251 | /* | |
252 | * We use asm/timex.h : cpu_khz/HZ variable in here : we might have to deal | |
253 | * specifically with CPU frequency scaling someday, so using an interpolation | |
254 | * between the start and end of buffer values is not flexible enough. Using an | |
255 | * immediate frequency value permits to calculate directly the times for parts | |
256 | * of a buffer that would be before a frequency change. | |
257 | * | |
258 | * Keep the natural field alignment for _each field_ within this structure if | |
259 | * you ever add/remove a field from this header. Packed attribute is not used | |
260 | * because gcc generates poor code on at least powerpc and mips. Don't ever | |
261 | * let gcc add padding between the structure elements. | |
262 | */ | |
263 | struct ltt_subbuffer_header { | |
264 | uint64_t cycle_count_begin; /* Cycle count at subbuffer start */ | |
265 | uint64_t cycle_count_end; /* Cycle count at subbuffer end */ | |
266 | uint32_t magic_number; /* | |
267 | * Trace magic number. | |
268 | * contains endianness information. | |
269 | */ | |
270 | uint8_t major_version; | |
271 | uint8_t minor_version; | |
272 | uint8_t arch_size; /* Architecture pointer size */ | |
273 | uint8_t alignment; /* LTT data alignment */ | |
274 | uint64_t start_time_sec; /* NTP-corrected start time */ | |
275 | uint64_t start_time_usec; | |
276 | uint64_t start_freq; /* | |
277 | * Frequency at trace start, | |
278 | * used all along the trace. | |
279 | */ | |
280 | uint32_t freq_scale; /* Frequency scaling (divisor) */ | |
281 | uint32_t lost_size; /* Size unused at end of subbuffer */ | |
282 | uint32_t buf_size; /* Size of this subbuffer */ | |
283 | uint32_t events_lost; /* | |
284 | * Events lost in this subbuffer since | |
285 | * the beginning of the trace. | |
286 | * (may overflow) | |
287 | */ | |
288 | uint32_t subbuf_corrupt; /* | |
289 | * Corrupted (lost) subbuffers since | |
290 | * the begginig of the trace. | |
291 | * (may overflow) | |
292 | */ | |
293 | uint8_t header_end[0]; /* End of header */ | |
294 | }; | |
295 | ||
296 | /** | |
297 | * ltt_subbuffer_header_size - called on buffer-switch to a new sub-buffer | |
298 | * | |
299 | * Return header size without padding after the structure. Don't use packed | |
300 | * structure because gcc generates inefficient code on some architectures | |
301 | * (powerpc, mips..) | |
302 | */ | |
303 | static inline size_t ltt_subbuffer_header_size(void) | |
304 | { | |
305 | return offsetof(struct ltt_subbuffer_header, header_end); | |
306 | } | |
307 | ||
308 | /* | |
309 | * ltt_get_header_size | |
310 | * | |
311 | * Calculate alignment offset to 32-bits. This is the alignment offset of the | |
312 | * event header. | |
313 | * | |
314 | * Important note : | |
315 | * The event header must be 32-bits. The total offset calculated here : | |
316 | * | |
317 | * Alignment of header struct on 32 bits (min arch size, header size) | |
318 | * + sizeof(header struct) (32-bits) | |
319 | * + (opt) u16 (ext. event id) | |
320 | * + (opt) u16 (event_size) (if event_size == 0xFFFFUL, has ext. event size) | |
321 | * + (opt) u32 (ext. event size) | |
322 | * + (opt) u64 full TSC (aligned on min(64-bits, arch size)) | |
323 | * | |
324 | * The payload must itself determine its own alignment from the biggest type it | |
325 | * contains. | |
326 | * */ | |
327 | static inline unsigned char ltt_get_header_size( | |
328 | struct ltt_channel_struct *channel, | |
329 | size_t offset, | |
330 | size_t data_size, | |
331 | size_t *before_hdr_pad, | |
332 | unsigned int rflags) | |
333 | { | |
334 | size_t orig_offset = offset; | |
335 | size_t padding; | |
336 | ||
bb07823d | 337 | //ust// BUILD_BUG_ON(sizeof(struct ltt_event_header) != sizeof(u32)); |
9dad1eb8 PMF |
338 | |
339 | padding = ltt_align(offset, sizeof(struct ltt_event_header)); | |
340 | offset += padding; | |
341 | offset += sizeof(struct ltt_event_header); | |
342 | ||
343 | switch (rflags) { | |
344 | case LTT_RFLAG_ID_SIZE_TSC: | |
345 | offset += sizeof(u16) + sizeof(u16); | |
346 | if (data_size >= 0xFFFFU) | |
347 | offset += sizeof(u32); | |
348 | offset += ltt_align(offset, sizeof(u64)); | |
349 | offset += sizeof(u64); | |
350 | break; | |
351 | case LTT_RFLAG_ID_SIZE: | |
352 | offset += sizeof(u16) + sizeof(u16); | |
353 | if (data_size >= 0xFFFFU) | |
354 | offset += sizeof(u32); | |
355 | break; | |
356 | case LTT_RFLAG_ID: | |
357 | offset += sizeof(u16); | |
358 | break; | |
359 | } | |
360 | ||
361 | *before_hdr_pad = padding; | |
362 | return offset - orig_offset; | |
363 | } | |
364 | ||
365 | /* | |
366 | * ltt_write_event_header | |
367 | * | |
368 | * Writes the event header to the offset (already aligned on 32-bits). | |
369 | * | |
370 | * @trace : trace to write to. | |
371 | * @channel : pointer to the channel structure.. | |
372 | * @buf : buffer to write to. | |
373 | * @buf_offset : buffer offset to write to (aligned on 32 bits). | |
374 | * @eID : event ID | |
375 | * @event_size : size of the event, excluding the event header. | |
376 | * @tsc : time stamp counter. | |
377 | * @rflags : reservation flags. | |
378 | * | |
379 | * returns : offset where the event data must be written. | |
380 | */ | |
381 | static inline size_t ltt_write_event_header(struct ltt_trace_struct *trace, | |
382 | struct ltt_channel_struct *channel, | |
383 | struct rchan_buf *buf, long buf_offset, | |
384 | u16 eID, size_t event_size, | |
385 | u64 tsc, unsigned int rflags) | |
386 | { | |
387 | struct ltt_event_header header; | |
388 | size_t small_size; | |
389 | ||
390 | switch (rflags) { | |
391 | case LTT_RFLAG_ID_SIZE_TSC: | |
392 | header.id_time = 29 << LTT_TSC_BITS; | |
393 | break; | |
394 | case LTT_RFLAG_ID_SIZE: | |
395 | header.id_time = 30 << LTT_TSC_BITS; | |
396 | break; | |
397 | case LTT_RFLAG_ID: | |
398 | header.id_time = 31 << LTT_TSC_BITS; | |
399 | break; | |
400 | default: | |
401 | header.id_time = eID << LTT_TSC_BITS; | |
402 | break; | |
403 | } | |
404 | header.id_time |= (u32)tsc & LTT_TSC_MASK; | |
405 | ltt_relay_write(buf, buf_offset, &header, sizeof(header)); | |
406 | buf_offset += sizeof(header); | |
407 | ||
408 | switch (rflags) { | |
409 | case LTT_RFLAG_ID_SIZE_TSC: | |
410 | small_size = min_t(size_t, event_size, 0xFFFFU); | |
411 | ltt_relay_write(buf, buf_offset, | |
412 | (u16[]){ (u16)eID }, sizeof(u16)); | |
413 | buf_offset += sizeof(u16); | |
414 | ltt_relay_write(buf, buf_offset, | |
415 | (u16[]){ (u16)small_size }, sizeof(u16)); | |
416 | buf_offset += sizeof(u16); | |
417 | if (small_size == 0xFFFFU) { | |
418 | ltt_relay_write(buf, buf_offset, | |
419 | (u32[]){ (u32)event_size }, sizeof(u32)); | |
420 | buf_offset += sizeof(u32); | |
421 | } | |
422 | buf_offset += ltt_align(buf_offset, sizeof(u64)); | |
423 | ltt_relay_write(buf, buf_offset, | |
424 | (u64[]){ (u64)tsc }, sizeof(u64)); | |
425 | buf_offset += sizeof(u64); | |
426 | break; | |
427 | case LTT_RFLAG_ID_SIZE: | |
428 | small_size = min_t(size_t, event_size, 0xFFFFU); | |
429 | ltt_relay_write(buf, buf_offset, | |
430 | (u16[]){ (u16)eID }, sizeof(u16)); | |
431 | buf_offset += sizeof(u16); | |
432 | ltt_relay_write(buf, buf_offset, | |
433 | (u16[]){ (u16)small_size }, sizeof(u16)); | |
434 | buf_offset += sizeof(u16); | |
435 | if (small_size == 0xFFFFU) { | |
436 | ltt_relay_write(buf, buf_offset, | |
437 | (u32[]){ (u32)event_size }, sizeof(u32)); | |
438 | buf_offset += sizeof(u32); | |
439 | } | |
440 | break; | |
441 | case LTT_RFLAG_ID: | |
442 | ltt_relay_write(buf, buf_offset, | |
443 | (u16[]){ (u16)eID }, sizeof(u16)); | |
444 | buf_offset += sizeof(u16); | |
445 | break; | |
446 | default: | |
447 | break; | |
448 | } | |
449 | ||
450 | return buf_offset; | |
451 | } | |
452 | ||
453 | /* Lockless LTTng */ | |
454 | ||
455 | /* Buffer offset macros */ | |
456 | ||
457 | /* | |
458 | * BUFFER_TRUNC zeroes the subbuffer offset and the subbuffer number parts of | |
459 | * the offset, which leaves only the buffer number. | |
460 | */ | |
461 | #define BUFFER_TRUNC(offset, chan) \ | |
462 | ((offset) & (~((chan)->alloc_size-1))) | |
463 | #define BUFFER_OFFSET(offset, chan) ((offset) & ((chan)->alloc_size - 1)) | |
464 | #define SUBBUF_OFFSET(offset, chan) ((offset) & ((chan)->subbuf_size - 1)) | |
465 | #define SUBBUF_ALIGN(offset, chan) \ | |
466 | (((offset) + (chan)->subbuf_size) & (~((chan)->subbuf_size - 1))) | |
467 | #define SUBBUF_TRUNC(offset, chan) \ | |
468 | ((offset) & (~((chan)->subbuf_size - 1))) | |
469 | #define SUBBUF_INDEX(offset, chan) \ | |
470 | (BUFFER_OFFSET((offset), chan) >> (chan)->subbuf_size_order) | |
471 | ||
472 | /* | |
473 | * ltt_reserve_slot | |
474 | * | |
475 | * Atomic slot reservation in a LTTng buffer. It will take care of | |
476 | * sub-buffer switching. | |
477 | * | |
478 | * Parameters: | |
479 | * | |
480 | * @trace : the trace structure to log to. | |
481 | * @channel : the chanel to reserve space into. | |
482 | * @transport_data : specific transport data. | |
483 | * @data_size : size of the variable length data to log. | |
484 | * @slot_size : pointer to total size of the slot (out) | |
485 | * @buf_offset : pointer to reserve offset (out) | |
486 | * @tsc : pointer to the tsc at the slot reservation (out) | |
487 | * @rflags : reservation flags (header specificity) | |
488 | * @cpu : cpu id | |
489 | * | |
490 | * Return : -ENOSPC if not enough space, else 0. | |
491 | */ | |
492 | static inline int ltt_reserve_slot( | |
493 | struct ltt_trace_struct *trace, | |
494 | struct ltt_channel_struct *channel, | |
495 | void **transport_data, | |
496 | size_t data_size, | |
497 | size_t *slot_size, | |
498 | long *buf_offset, | |
499 | u64 *tsc, | |
500 | unsigned int *rflags, | |
501 | int largest_align, | |
502 | int cpu) | |
503 | { | |
504 | return trace->ops->reserve_slot(trace, channel, transport_data, | |
505 | data_size, slot_size, buf_offset, tsc, rflags, | |
506 | largest_align, cpu); | |
507 | } | |
508 | ||
509 | ||
510 | /* | |
511 | * ltt_commit_slot | |
512 | * | |
513 | * Atomic unordered slot commit. Increments the commit count in the | |
514 | * specified sub-buffer, and delivers it if necessary. | |
515 | * | |
516 | * Parameters: | |
517 | * | |
518 | * @channel : the chanel to reserve space into. | |
519 | * @transport_data : specific transport data. | |
520 | * @buf_offset : offset of beginning of reserved slot | |
521 | * @slot_size : size of the reserved slot. | |
522 | */ | |
523 | static inline void ltt_commit_slot( | |
524 | struct ltt_channel_struct *channel, | |
525 | void **transport_data, | |
526 | long buf_offset, | |
527 | size_t slot_size) | |
528 | { | |
529 | struct ltt_trace_struct *trace = channel->trace; | |
530 | ||
531 | trace->ops->commit_slot(channel, transport_data, buf_offset, slot_size); | |
532 | } | |
533 | ||
534 | /* | |
535 | * Control channels : | |
536 | * control/metadata | |
537 | * control/interrupts | |
538 | * control/... | |
539 | * | |
540 | * cpu channel : | |
541 | * cpu | |
542 | */ | |
b6bf28ec PMF |
543 | //ust// #define LTT_RELAY_ROOT "ltt" |
544 | //ust// #define LTT_RELAY_LOCKED_ROOT "ltt-locked" | |
9dad1eb8 PMF |
545 | |
546 | #define LTT_METADATA_CHANNEL "metadata_state" | |
b6bf28ec | 547 | #define LTT_UST_CHANNEL "ust" |
9dad1eb8 PMF |
548 | |
549 | #define LTT_FLIGHT_PREFIX "flight-" | |
550 | ||
551 | /* Tracer properties */ | |
552 | #define LTT_DEFAULT_SUBBUF_SIZE_LOW 65536 | |
553 | #define LTT_DEFAULT_N_SUBBUFS_LOW 2 | |
554 | #define LTT_DEFAULT_SUBBUF_SIZE_MED 262144 | |
555 | #define LTT_DEFAULT_N_SUBBUFS_MED 2 | |
556 | #define LTT_DEFAULT_SUBBUF_SIZE_HIGH 1048576 | |
557 | #define LTT_DEFAULT_N_SUBBUFS_HIGH 2 | |
558 | #define LTT_TRACER_MAGIC_NUMBER 0x00D6B7ED | |
559 | #define LTT_TRACER_VERSION_MAJOR 2 | |
560 | #define LTT_TRACER_VERSION_MINOR 3 | |
561 | ||
562 | /* | |
563 | * Size reserved for high priority events (interrupts, NMI, BH) at the end of a | |
564 | * nearly full buffer. User space won't use this last amount of space when in | |
565 | * blocking mode. This space also includes the event header that would be | |
566 | * written by this user space event. | |
567 | */ | |
568 | #define LTT_RESERVE_CRITICAL 4096 | |
569 | ||
570 | /* Register and unregister function pointers */ | |
571 | ||
572 | enum ltt_module_function { | |
573 | LTT_FUNCTION_RUN_FILTER, | |
574 | LTT_FUNCTION_FILTER_CONTROL, | |
575 | LTT_FUNCTION_STATEDUMP | |
576 | }; | |
577 | ||
b6bf28ec PMF |
578 | //ust// extern int ltt_module_register(enum ltt_module_function name, void *function, |
579 | //ust// struct module *owner); | |
580 | //ust// extern void ltt_module_unregister(enum ltt_module_function name); | |
9dad1eb8 PMF |
581 | |
582 | void ltt_transport_register(struct ltt_transport *transport); | |
583 | void ltt_transport_unregister(struct ltt_transport *transport); | |
584 | ||
585 | /* Exported control function */ | |
586 | ||
b6bf28ec PMF |
587 | //ust// enum ltt_control_msg { |
588 | //ust// LTT_CONTROL_START, | |
589 | //ust// LTT_CONTROL_STOP, | |
590 | //ust// LTT_CONTROL_CREATE_TRACE, | |
591 | //ust// LTT_CONTROL_DESTROY_TRACE | |
592 | //ust// }; | |
9dad1eb8 PMF |
593 | |
594 | union ltt_control_args { | |
595 | struct { | |
596 | enum trace_mode mode; | |
597 | unsigned int subbuf_size_low; | |
598 | unsigned int n_subbufs_low; | |
599 | unsigned int subbuf_size_med; | |
600 | unsigned int n_subbufs_med; | |
601 | unsigned int subbuf_size_high; | |
602 | unsigned int n_subbufs_high; | |
603 | } new_trace; | |
604 | }; | |
605 | ||
606 | int _ltt_trace_setup(const char *trace_name); | |
607 | int ltt_trace_setup(const char *trace_name); | |
608 | struct ltt_trace_struct *_ltt_trace_find_setup(const char *trace_name); | |
609 | int ltt_trace_set_type(const char *trace_name, const char *trace_type); | |
610 | int ltt_trace_set_channel_subbufsize(const char *trace_name, | |
611 | const char *channel_name, unsigned int size); | |
612 | int ltt_trace_set_channel_subbufcount(const char *trace_name, | |
613 | const char *channel_name, unsigned int cnt); | |
614 | int ltt_trace_set_channel_enable(const char *trace_name, | |
615 | const char *channel_name, unsigned int enable); | |
616 | int ltt_trace_set_channel_overwrite(const char *trace_name, | |
617 | const char *channel_name, unsigned int overwrite); | |
618 | int ltt_trace_alloc(const char *trace_name); | |
619 | int ltt_trace_destroy(const char *trace_name); | |
620 | int ltt_trace_start(const char *trace_name); | |
621 | int ltt_trace_stop(const char *trace_name); | |
622 | ||
b6bf28ec PMF |
623 | //ust// extern int ltt_control(enum ltt_control_msg msg, const char *trace_name, |
624 | //ust// const char *trace_type, union ltt_control_args args); | |
9dad1eb8 PMF |
625 | |
626 | enum ltt_filter_control_msg { | |
627 | LTT_FILTER_DEFAULT_ACCEPT, | |
628 | LTT_FILTER_DEFAULT_REJECT | |
629 | }; | |
630 | ||
631 | extern int ltt_filter_control(enum ltt_filter_control_msg msg, | |
632 | const char *trace_name); | |
633 | ||
634 | extern struct dentry *get_filter_root(void); | |
635 | ||
636 | void ltt_write_trace_header(struct ltt_trace_struct *trace, | |
637 | struct ltt_subbuffer_header *header); | |
638 | extern void ltt_buffer_destroy(struct ltt_channel_struct *ltt_chan); | |
639 | ||
640 | void ltt_core_register(int (*function)(u8, void *)); | |
641 | ||
642 | void ltt_core_unregister(void); | |
643 | ||
644 | void ltt_release_trace(struct kref *kref); | |
645 | void ltt_release_transport(struct kref *kref); | |
646 | ||
647 | extern int ltt_probe_register(struct ltt_available_probe *pdata); | |
648 | extern int ltt_probe_unregister(struct ltt_available_probe *pdata); | |
649 | extern int ltt_marker_connect(const char *channel, const char *mname, | |
650 | const char *pname); | |
651 | extern int ltt_marker_disconnect(const char *channel, const char *mname, | |
652 | const char *pname); | |
653 | extern void ltt_dump_marker_state(struct ltt_trace_struct *trace); | |
654 | ||
655 | void ltt_lock_traces(void); | |
656 | void ltt_unlock_traces(void); | |
657 | ||
b6bf28ec PMF |
658 | //ust// extern void ltt_dump_softirq_vec(void *call_data); |
659 | //ust// | |
660 | //ust// #ifdef CONFIG_HAVE_LTT_DUMP_TABLES | |
661 | //ust// extern void ltt_dump_sys_call_table(void *call_data); | |
662 | //ust// extern void ltt_dump_idt_table(void *call_data); | |
663 | //ust// #else | |
664 | //ust// static inline void ltt_dump_sys_call_table(void *call_data) | |
665 | //ust// { | |
666 | //ust// } | |
667 | //ust// | |
668 | //ust// static inline void ltt_dump_idt_table(void *call_data) | |
669 | //ust// { | |
670 | //ust// } | |
671 | //ust// #endif | |
672 | ||
673 | //ust// #ifdef CONFIG_LTT_KPROBES | |
674 | //ust// extern void ltt_dump_kprobes_table(void *call_data); | |
675 | //ust// #else | |
676 | //ust// static inline void ltt_dump_kprobes_table(void *call_data) | |
677 | //ust// { | |
678 | //ust// } | |
679 | //ust// #endif | |
680 | ||
681 | //ust// /* Relay IOCTL */ | |
682 | //ust// | |
683 | //ust// /* Get the next sub buffer that can be read. */ | |
684 | //ust// #define RELAY_GET_SUBBUF _IOR(0xF5, 0x00, __u32) | |
685 | //ust// /* Release the oldest reserved (by "get") sub buffer. */ | |
686 | //ust// #define RELAY_PUT_SUBBUF _IOW(0xF5, 0x01, __u32) | |
687 | //ust// /* returns the number of sub buffers in the per cpu channel. */ | |
688 | //ust// #define RELAY_GET_N_SUBBUFS _IOR(0xF5, 0x02, __u32) | |
689 | //ust// /* returns the size of the sub buffers. */ | |
690 | //ust// #define RELAY_GET_SUBBUF_SIZE _IOR(0xF5, 0x03, __u32) | |
691 | ||
692 | //ust// #endif /* CONFIG_LTT */ | |
9dad1eb8 PMF |
693 | |
694 | #endif /* _LTT_TRACER_H */ |