Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ring_buffer.h
Go to the documentation of this file.
1 #ifndef _LINUX_RING_BUFFER_H
2 #define _LINUX_RING_BUFFER_H
3 
4 #include <linux/kmemcheck.h>
5 #include <linux/mm.h>
6 #include <linux/seq_file.h>
7 
8 struct ring_buffer;
9 struct ring_buffer_iter;
10 
11 /*
12  * Don't refer to this struct directly, use functions below.
13  */
18 
20 };
21 
58  /* FIXME: RINGBUF_TYPE_TIME_STAMP not implemented */
60 };
61 
64 
65 /*
66  * ring_buffer_discard_commit will remove an event that has not
67  * ben committed yet. If this is used, then ring_buffer_unlock_commit
68  * must not be called on the discarded event. This function
69  * will try to remove the event from the ring buffer completely
70  * if another event has not been written after it.
71  *
72  * Example use:
73  *
74  * if (some_condition)
75  * ring_buffer_discard_commit(buffer, event);
76  * else
77  * ring_buffer_unlock_commit(buffer, event);
78  */
80  struct ring_buffer_event *event);
81 
82 /*
83  * size is in bytes for each per CPU buffer.
84  */
85 struct ring_buffer *
86 __ring_buffer_alloc(unsigned long size, unsigned flags, struct lock_class_key *key);
87 
88 /*
89  * Because the ring buffer is generic, if other users of the ring buffer get
90  * traced by ftrace, it can produce lockdep warnings. We need to keep each
91  * ring buffer's lock class separate.
92  */
93 #define ring_buffer_alloc(size, flags) \
94 ({ \
95  static struct lock_class_key __key; \
96  __ring_buffer_alloc((size), (flags), &__key); \
97 })
98 
99 #define RING_BUFFER_ALL_CPUS -1
100 
101 void ring_buffer_free(struct ring_buffer *buffer);
102 
103 int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size, int cpu);
104 
106 
108  unsigned long length);
110  struct ring_buffer_event *event);
112  unsigned long length, void *data);
113 
114 struct ring_buffer_event *
116  unsigned long *lost_events);
117 struct ring_buffer_event *
119  unsigned long *lost_events);
120 
121 struct ring_buffer_iter *
124 void ring_buffer_read_start(struct ring_buffer_iter *iter);
125 void ring_buffer_read_finish(struct ring_buffer_iter *iter);
126 
127 struct ring_buffer_event *
129 struct ring_buffer_event *
130 ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts);
131 void ring_buffer_iter_reset(struct ring_buffer_iter *iter);
132 int ring_buffer_iter_empty(struct ring_buffer_iter *iter);
133 
134 unsigned long ring_buffer_size(struct ring_buffer *buffer, int cpu);
135 
136 void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu);
137 void ring_buffer_reset(struct ring_buffer *buffer);
138 
139 #ifdef CONFIG_RING_BUFFER_ALLOW_SWAP
140 int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
141  struct ring_buffer *buffer_b, int cpu);
142 #else
143 static inline int
144 ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
145  struct ring_buffer *buffer_b, int cpu)
146 {
147  return -ENODEV;
148 }
149 #endif
150 
152 int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu);
153 
161 
162 unsigned long ring_buffer_oldest_event_ts(struct ring_buffer *buffer, int cpu);
163 unsigned long ring_buffer_bytes_cpu(struct ring_buffer *buffer, int cpu);
164 unsigned long ring_buffer_entries(struct ring_buffer *buffer);
165 unsigned long ring_buffer_overruns(struct ring_buffer *buffer);
166 unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu);
167 unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu);
168 unsigned long ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu);
169 
172  int cpu, u64 *ts);
174  u64 (*clock)(void));
175 
176 size_t ring_buffer_page_len(void *page);
177 
178 
179 void *ring_buffer_alloc_read_page(struct ring_buffer *buffer, int cpu);
180 void ring_buffer_free_read_page(struct ring_buffer *buffer, void *data);
181 int ring_buffer_read_page(struct ring_buffer *buffer, void **data_page,
182  size_t len, int cpu, int full);
183 
184 struct trace_seq;
185 
188 
190  RB_FL_OVERWRITE = 1 << 0,
191 };
192 
193 #endif /* _LINUX_RING_BUFFER_H */