811a2537199a9ef8ad3ecae9e9959bfc6469e29a
[lttv.git] / usertrace-fast / ltt-usertrace-fast.h
1
2 /* LTTng user-space "fast" tracing header
3 *
4 * Copyright 2006 Mathieu Desnoyers
5 *
6 */
7
8 #ifndef _LTT_USERTRACE_FAST_H
9 #define _LTT_USERTRACE_FAST_H
10
11 #include <errno.h>
12 #include <asm/atomic.h>
13 #include <pthread.h>
14
15
16 #ifndef LTT_N_SUBBUFS
17 #define LTT_N_SUBBUFS 2
18 #endif //LTT_N_SUBBUFS
19
20 #ifndef LTT_SUBBUF_SIZE_CPU
21 #define LTT_SUBBUF_SIZE_CPU 1048576
22 #endif //LTT_BUF_SIZE_CPU
23
24 #define LTT_BUF_SIZE_CPU (LTT_SUBBUF_SIZE_CPU * LTT_N_SUBBUFS)
25
26 #ifndef LTT_SUBBUF_SIZE_FACILITIES
27 #define LTT_SUBBUF_SIZE_FACILITIES 4096
28 #endif //LTT_BUF_SIZE_FACILITIES
29
30 #define LTT_BUF_SIZE_FACILITIES (LTT_SUBBUF_SIZE_FACILITIES * LTT_N_SUBBUFS)
31
32 #ifndef LTT_USERTRACE_ROOT
33 #define LTT_USERTRACE_ROOT "/tmp/ltt-usertrace"
34 #endif //LTT_USERTRACE_ROOT
35
36
37 /* Buffer offset macros */
38
39 #define BUFFER_OFFSET(offset, buf) (offset & (buf->alloc_size-1))
40 #define SUBBUF_OFFSET(offset, buf) (offset & (buf->subbuf_size-1))
41 #define SUBBUF_ALIGN(offset, buf) \
42 (((offset) + buf->subbuf_size) & (~(buf->subbuf_size-1)))
43 #define SUBBUF_TRUNC(offset, buf) \
44 ((offset) & (~(buf->subbuf_size-1)))
45 #define SUBBUF_INDEX(offset, buf) \
46 (BUFFER_OFFSET(offset,buf)/buf->subbuf_size)
47
48
49 struct ltt_buf {
50 atomic_t offset;
51 atomic_t consumed;
52 atomic_t reserve_count[LTT_N_SUBBUFS];
53 atomic_t commit_count[LTT_N_SUBBUFS];
54
55 atomic_t events_lost;
56 atomic_t full; /* futex on which the writer waits : 1 : full */
57 unsigned int alloc_size;
58 unsigned int subbuf_size;
59 };
60
61 struct ltt_trace_info {
62 int init;
63 int filter;
64 pid_t daemon_id;
65 atomic_t nesting;
66 struct {
67 struct ltt_buf facilities;
68 struct ltt_buf cpu;
69 char facilities_buf[LTT_BUF_SIZE_FACILITIES] __attribute__ ((aligned (8)));
70 char cpu_buf[LTT_BUF_SIZE_CPU] __attribute__ ((aligned (8)));
71 } channel;
72 };
73
74 extern __thread struct ltt_trace_info *thread_trace_info;
75
76 void ltt_thread_init(void);
77
78 void ltt_usertrace_fast_buffer_switch(void);
79
80 #endif //_LTT_USERTRACE_FAST_H
This page took 0.03182 seconds and 3 git commands to generate.