This source file includes following definitions.
- ring_buffer_swap_cpu
1
2 #ifndef _LINUX_RING_BUFFER_H
3 #define _LINUX_RING_BUFFER_H
4
5 #include <linux/mm.h>
6 #include <linux/seq_file.h>
7 #include <linux/poll.h>
8
9 struct ring_buffer;
10 struct ring_buffer_iter;
11
12
13
14
15 struct ring_buffer_event {
16 u32 type_len:5, time_delta:27;
17
18 u32 array[];
19 };
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 enum ring_buffer_type {
56 RINGBUF_TYPE_DATA_TYPE_LEN_MAX = 28,
57 RINGBUF_TYPE_PADDING,
58 RINGBUF_TYPE_TIME_EXTEND,
59 RINGBUF_TYPE_TIME_STAMP,
60 };
61
62 unsigned ring_buffer_event_length(struct ring_buffer_event *event);
63 void *ring_buffer_event_data(struct ring_buffer_event *event);
64 u64 ring_buffer_event_time_stamp(struct ring_buffer_event *event);
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 void ring_buffer_discard_commit(struct ring_buffer *buffer,
81 struct ring_buffer_event *event);
82
83
84
85
86 struct ring_buffer *
87 __ring_buffer_alloc(unsigned long size, unsigned flags, struct lock_class_key *key);
88
89
90
91
92
93
94 #define ring_buffer_alloc(size, flags) \
95 ({ \
96 static struct lock_class_key __key; \
97 __ring_buffer_alloc((size), (flags), &__key); \
98 })
99
100 int ring_buffer_wait(struct ring_buffer *buffer, int cpu, int full);
101 __poll_t ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu,
102 struct file *filp, poll_table *poll_table);
103
104
105 #define RING_BUFFER_ALL_CPUS -1
106
107 void ring_buffer_free(struct ring_buffer *buffer);
108
109 int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size, int cpu);
110
111 void ring_buffer_change_overwrite(struct ring_buffer *buffer, int val);
112
113 struct ring_buffer_event *ring_buffer_lock_reserve(struct ring_buffer *buffer,
114 unsigned long length);
115 int ring_buffer_unlock_commit(struct ring_buffer *buffer,
116 struct ring_buffer_event *event);
117 int ring_buffer_write(struct ring_buffer *buffer,
118 unsigned long length, void *data);
119
120 void ring_buffer_nest_start(struct ring_buffer *buffer);
121 void ring_buffer_nest_end(struct ring_buffer *buffer);
122
123 struct ring_buffer_event *
124 ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts,
125 unsigned long *lost_events);
126 struct ring_buffer_event *
127 ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts,
128 unsigned long *lost_events);
129
130 struct ring_buffer_iter *
131 ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu, gfp_t flags);
132 void ring_buffer_read_prepare_sync(void);
133 void ring_buffer_read_start(struct ring_buffer_iter *iter);
134 void ring_buffer_read_finish(struct ring_buffer_iter *iter);
135
136 struct ring_buffer_event *
137 ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts);
138 struct ring_buffer_event *
139 ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts);
140 void ring_buffer_iter_reset(struct ring_buffer_iter *iter);
141 int ring_buffer_iter_empty(struct ring_buffer_iter *iter);
142
143 unsigned long ring_buffer_size(struct ring_buffer *buffer, int cpu);
144
145 void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu);
146 void ring_buffer_reset(struct ring_buffer *buffer);
147
148 #ifdef CONFIG_RING_BUFFER_ALLOW_SWAP
149 int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
150 struct ring_buffer *buffer_b, int cpu);
151 #else
152 static inline int
153 ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
154 struct ring_buffer *buffer_b, int cpu)
155 {
156 return -ENODEV;
157 }
158 #endif
159
160 bool ring_buffer_empty(struct ring_buffer *buffer);
161 bool ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu);
162
163 void ring_buffer_record_disable(struct ring_buffer *buffer);
164 void ring_buffer_record_enable(struct ring_buffer *buffer);
165 void ring_buffer_record_off(struct ring_buffer *buffer);
166 void ring_buffer_record_on(struct ring_buffer *buffer);
167 bool ring_buffer_record_is_on(struct ring_buffer *buffer);
168 bool ring_buffer_record_is_set_on(struct ring_buffer *buffer);
169 void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu);
170 void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu);
171
172 u64 ring_buffer_oldest_event_ts(struct ring_buffer *buffer, int cpu);
173 unsigned long ring_buffer_bytes_cpu(struct ring_buffer *buffer, int cpu);
174 unsigned long ring_buffer_entries(struct ring_buffer *buffer);
175 unsigned long ring_buffer_overruns(struct ring_buffer *buffer);
176 unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu);
177 unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu);
178 unsigned long ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu);
179 unsigned long ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu);
180 unsigned long ring_buffer_read_events_cpu(struct ring_buffer *buffer, int cpu);
181
182 u64 ring_buffer_time_stamp(struct ring_buffer *buffer, int cpu);
183 void ring_buffer_normalize_time_stamp(struct ring_buffer *buffer,
184 int cpu, u64 *ts);
185 void ring_buffer_set_clock(struct ring_buffer *buffer,
186 u64 (*clock)(void));
187 void ring_buffer_set_time_stamp_abs(struct ring_buffer *buffer, bool abs);
188 bool ring_buffer_time_stamp_abs(struct ring_buffer *buffer);
189
190 size_t ring_buffer_nr_pages(struct ring_buffer *buffer, int cpu);
191 size_t ring_buffer_nr_dirty_pages(struct ring_buffer *buffer, int cpu);
192
193 void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu);
194 void ring_buffer_free_read_page(struct ring_buffer *buffer, int cpu, void *data);
195 int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page,
196 size_t len, int cpu, int full);
197
198 struct trace_seq;
199
200 int ring_buffer_print_entry_header(struct trace_seq *s);
201 int ring_buffer_print_page_header(struct trace_seq *s);
202
203 enum ring_buffer_flags {
204 RB_FL_OVERWRITE = 1 << 0,
205 };
206
207 #ifdef CONFIG_RING_BUFFER
208 int trace_rb_cpu_prepare(unsigned int cpu, struct hlist_node *node);
209 #else
210 #define trace_rb_cpu_prepare NULL
211 #endif
212
213 #endif