Blame view
include/linux/ring_buffer.h
6.78 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
7a8e76a38 tracing: unified ... |
2 3 4 5 6 |
#ifndef _LINUX_RING_BUFFER_H #define _LINUX_RING_BUFFER_H #include <linux/mm.h> #include <linux/seq_file.h> |
15693458c tracing/ring-buff... |
7 |
#include <linux/poll.h> |
7a8e76a38 tracing: unified ... |
8 9 10 11 12 |
struct ring_buffer; struct ring_buffer_iter; /* |
c3706f005 tracing: fix typo... |
13 |
* Don't refer to this struct directly, use functions below. |
7a8e76a38 tracing: unified ... |
14 15 |
*/ struct ring_buffer_event { |
334d4169a ring_buffer: comp... |
16 |
u32 type_len:5, time_delta:27; |
1744a21d5 trace: annotate b... |
17 |
|
7a8e76a38 tracing: unified ... |
18 19 20 21 22 23 |
u32 array[]; }; /** * enum ring_buffer_type - internal ring buffer types * |
2d622719f tracing: add ring... |
24 25 26 27 |
* @RINGBUF_TYPE_PADDING: Left over page padding or discarded event * If time_delta is 0: * array is ignored * size is variable depending on how much |
7a8e76a38 tracing: unified ... |
28 |
* padding is needed |
2d622719f tracing: add ring... |
29 |
* If time_delta is non zero: |
334d4169a ring_buffer: comp... |
30 31 |
* array[0] holds the actual length * size = 4 + length (bytes) |
7a8e76a38 tracing: unified ... |
32 33 34 35 36 37 |
* * @RINGBUF_TYPE_TIME_EXTEND: Extend the time delta * array[0] = time delta (28 .. 59) * size = 8 bytes * * @RINGBUF_TYPE_TIME_STAMP: Sync time stamp with external clock |
361b73d5c ring_buffer: fix ... |
38 39 |
* array[0] = tv_nsec * array[1..2] = tv_sec |
7a8e76a38 tracing: unified ... |
40 41 |
* size = 16 bytes * |
334d4169a ring_buffer: comp... |
42 43 44 |
* <= @RINGBUF_TYPE_DATA_TYPE_LEN_MAX: * Data record * If type_len is zero: |
7a8e76a38 tracing: unified ... |
45 |
* array[0] holds the actual length |
361b73d5c ring_buffer: fix ... |
46 |
* array[1..(length+3)/4] holds data |
334d4169a ring_buffer: comp... |
47 |
* size = 4 + length (bytes) |
7a8e76a38 tracing: unified ... |
48 |
* else |
334d4169a ring_buffer: comp... |
49 |
* length = type_len << 2 |
361b73d5c ring_buffer: fix ... |
50 51 |
* array[0..(length+3)/4-1] holds data * size = 4 + length (bytes) |
7a8e76a38 tracing: unified ... |
52 53 |
*/ enum ring_buffer_type { |
334d4169a ring_buffer: comp... |
54 |
RINGBUF_TYPE_DATA_TYPE_LEN_MAX = 28, |
7a8e76a38 tracing: unified ... |
55 56 57 58 |
RINGBUF_TYPE_PADDING, RINGBUF_TYPE_TIME_EXTEND, /* FIXME: RINGBUF_TYPE_TIME_STAMP not implemented */ RINGBUF_TYPE_TIME_STAMP, |
7a8e76a38 tracing: unified ... |
59 60 61 62 |
}; unsigned ring_buffer_event_length(struct ring_buffer_event *event); void *ring_buffer_event_data(struct ring_buffer_event *event); |
fa1b47dd8 ring-buffer: add ... |
63 |
/* |
fa1b47dd8 ring-buffer: add ... |
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
* ring_buffer_discard_commit will remove an event that has not * ben committed yet. If this is used, then ring_buffer_unlock_commit * must not be called on the discarded event. This function * will try to remove the event from the ring buffer completely * if another event has not been written after it. * * Example use: * * if (some_condition) * ring_buffer_discard_commit(buffer, event); * else * ring_buffer_unlock_commit(buffer, event); */ void ring_buffer_discard_commit(struct ring_buffer *buffer, struct ring_buffer_event *event); /* |
7a8e76a38 tracing: unified ... |
81 82 83 |
* size is in bytes for each per CPU buffer. */ struct ring_buffer * |
1f8a6a10f ring-buffer: pass... |
84 85 86 87 88 89 90 91 92 93 94 95 |
__ring_buffer_alloc(unsigned long size, unsigned flags, struct lock_class_key *key); /* * Because the ring buffer is generic, if other users of the ring buffer get * traced by ftrace, it can produce lockdep warnings. We need to keep each * ring buffer's lock class separate. */ #define ring_buffer_alloc(size, flags) \ ({ \ static struct lock_class_key __key; \ __ring_buffer_alloc((size), (flags), &__key); \ }) |
e30f53aad tracing: Do not b... |
96 |
int ring_buffer_wait(struct ring_buffer *buffer, int cpu, bool full); |
15693458c tracing/ring-buff... |
97 98 |
int ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu, struct file *filp, poll_table *poll_table); |
438ced172 ring-buffer: Add ... |
99 |
#define RING_BUFFER_ALL_CPUS -1 |
7a8e76a38 tracing: unified ... |
100 |
void ring_buffer_free(struct ring_buffer *buffer); |
438ced172 ring-buffer: Add ... |
101 |
int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size, int cpu); |
7a8e76a38 tracing: unified ... |
102 |
|
750912fa3 tracing: Add an '... |
103 |
void ring_buffer_change_overwrite(struct ring_buffer *buffer, int val); |
0a9877514 ring_buffer: remo... |
104 105 |
struct ring_buffer_event *ring_buffer_lock_reserve(struct ring_buffer *buffer, unsigned long length); |
7a8e76a38 tracing: unified ... |
106 |
int ring_buffer_unlock_commit(struct ring_buffer *buffer, |
0a9877514 ring_buffer: remo... |
107 |
struct ring_buffer_event *event); |
7a8e76a38 tracing: unified ... |
108 109 110 111 |
int ring_buffer_write(struct ring_buffer *buffer, unsigned long length, void *data); struct ring_buffer_event * |
66a8cb95e ring-buffer: Add ... |
112 113 |
ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts, unsigned long *lost_events); |
7a8e76a38 tracing: unified ... |
114 |
struct ring_buffer_event * |
66a8cb95e ring-buffer: Add ... |
115 116 |
ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts, unsigned long *lost_events); |
7a8e76a38 tracing: unified ... |
117 118 |
struct ring_buffer_iter * |
72c9ddfd4 ring-buffer: Make... |
119 120 121 |
ring_buffer_read_prepare(struct ring_buffer *buffer, int cpu); void ring_buffer_read_prepare_sync(void); void ring_buffer_read_start(struct ring_buffer_iter *iter); |
7a8e76a38 tracing: unified ... |
122 123 124 125 126 127 128 129 |
void ring_buffer_read_finish(struct ring_buffer_iter *iter); struct ring_buffer_event * ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts); struct ring_buffer_event * ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts); void ring_buffer_iter_reset(struct ring_buffer_iter *iter); int ring_buffer_iter_empty(struct ring_buffer_iter *iter); |
438ced172 ring-buffer: Add ... |
130 |
unsigned long ring_buffer_size(struct ring_buffer *buffer, int cpu); |
7a8e76a38 tracing: unified ... |
131 132 133 |
void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu); void ring_buffer_reset(struct ring_buffer *buffer); |
85bac32c4 ring-buffer: only... |
134 |
#ifdef CONFIG_RING_BUFFER_ALLOW_SWAP |
7a8e76a38 tracing: unified ... |
135 136 |
int ring_buffer_swap_cpu(struct ring_buffer *buffer_a, struct ring_buffer *buffer_b, int cpu); |
85bac32c4 ring-buffer: only... |
137 138 139 140 141 142 143 144 |
#else static inline int ring_buffer_swap_cpu(struct ring_buffer *buffer_a, struct ring_buffer *buffer_b, int cpu) { return -ENODEV; } #endif |
7a8e76a38 tracing: unified ... |
145 |
|
3d4e204d8 ring_buffer: ring... |
146 147 |
bool ring_buffer_empty(struct ring_buffer *buffer); bool ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu); |
7a8e76a38 tracing: unified ... |
148 149 150 |
void ring_buffer_record_disable(struct ring_buffer *buffer); void ring_buffer_record_enable(struct ring_buffer *buffer); |
499e54705 tracing/ring-buff... |
151 152 153 |
void ring_buffer_record_off(struct ring_buffer *buffer); void ring_buffer_record_on(struct ring_buffer *buffer); int ring_buffer_record_is_on(struct ring_buffer *buffer); |
60baabc37 ring_buffer: trac... |
154 |
int ring_buffer_record_is_set_on(struct ring_buffer *buffer); |
7a8e76a38 tracing: unified ... |
155 156 |
void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu); void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu); |
50ecf2c3a ring-buffer: Chan... |
157 |
u64 ring_buffer_oldest_event_ts(struct ring_buffer *buffer, int cpu); |
c64e148a3 trace: Add ring b... |
158 |
unsigned long ring_buffer_bytes_cpu(struct ring_buffer *buffer, int cpu); |
7a8e76a38 tracing: unified ... |
159 160 |
unsigned long ring_buffer_entries(struct ring_buffer *buffer); unsigned long ring_buffer_overruns(struct ring_buffer *buffer); |
e09373f22 ring_buffer: add ... |
161 162 |
unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu); unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu); |
f0d2c681a ring-buffer: add ... |
163 |
unsigned long ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu); |
884bfe89a ring-buffer: Add ... |
164 |
unsigned long ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu); |
ad964704b ring-buffer: Add ... |
165 |
unsigned long ring_buffer_read_events_cpu(struct ring_buffer *buffer, int cpu); |
7a8e76a38 tracing: unified ... |
166 |
|
37886f6a9 ring-buffer: add ... |
167 168 169 170 171 |
u64 ring_buffer_time_stamp(struct ring_buffer *buffer, int cpu); void ring_buffer_normalize_time_stamp(struct ring_buffer *buffer, int cpu, u64 *ts); void ring_buffer_set_clock(struct ring_buffer *buffer, u64 (*clock)(void)); |
7a8e76a38 tracing: unified ... |
172 |
|
ef7a4a161 ring-buffer: fix ... |
173 |
size_t ring_buffer_page_len(void *page); |
7ea590640 tracing: Use NUMA... |
174 |
void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu); |
73a757e63 ring-buffer: Retu... |
175 |
void ring_buffer_free_read_page(struct ring_buffer *buffer, int cpu, void *data); |
ef7a4a161 ring-buffer: fix ... |
176 177 |
int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page, size_t len, int cpu, int full); |
8789a9e7d ring-buffer: read... |
178 |
|
d1b182a8d tracing/events/ri... |
179 180 181 182 |
struct trace_seq; int ring_buffer_print_entry_header(struct trace_seq *s); int ring_buffer_print_page_header(struct trace_seq *s); |
7a8e76a38 tracing: unified ... |
183 184 185 |
enum ring_buffer_flags { RB_FL_OVERWRITE = 1 << 0, }; |
b32614c03 tracing/rb: Conve... |
186 187 188 189 190 |
#ifdef CONFIG_RING_BUFFER int trace_rb_cpu_prepare(unsigned int cpu, struct hlist_node *node); #else #define trace_rb_cpu_prepare NULL #endif |
7a8e76a38 tracing: unified ... |
191 |
#endif /* _LINUX_RING_BUFFER_H */ |