Fix: use after free in ring buffer clients
[lttng-modules.git] / lttng-ring-buffer-client.h
1 /*
2 * lttng-ring-buffer-client.h
3 *
4 * LTTng lib ring buffer client template.
5 *
6 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; only
11 * version 2.1 of the License.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <linux/module.h>
24 #include <linux/types.h>
25 #include "lib/bitfield.h"
26 #include "wrapper/vmalloc.h" /* for wrapper_vmalloc_sync_all() */
27 #include "wrapper/trace-clock.h"
28 #include "lttng-events.h"
29 #include "lttng-tracer.h"
30 #include "wrapper/ringbuffer/frontend_types.h"
31
32 #define LTTNG_COMPACT_EVENT_BITS 5
33 #define LTTNG_COMPACT_TSC_BITS 27
34
35 static struct lttng_transport lttng_relay_transport;
36
37 /*
38 * Keep the natural field alignment for _each field_ within this structure if
39 * you ever add/remove a field from this header. Packed attribute is not used
40 * because gcc generates poor code on at least powerpc and mips. Don't ever
41 * let gcc add padding between the structure elements.
42 *
43 * The guarantee we have with timestamps is that all the events in a
44 * packet are included (inclusive) within the begin/end timestamps of
45 * the packet. Another guarantee we have is that the "timestamp begin",
46 * as well as the event timestamps, are monotonically increasing (never
47 * decrease) when moving forward in a stream (physically). But this
48 * guarantee does not apply to "timestamp end", because it is sampled at
49 * commit time, which is not ordered with respect to space reservation.
50 */
51
52 struct packet_header {
53 /* Trace packet header */
54 uint32_t magic; /*
55 * Trace magic number.
56 * contains endianness information.
57 */
58 uint8_t uuid[16];
59 uint32_t stream_id;
60
61 struct {
62 /* Stream packet context */
63 uint64_t timestamp_begin; /* Cycle count at subbuffer start */
64 uint64_t timestamp_end; /* Cycle count at subbuffer end */
65 uint64_t content_size; /* Size of data in subbuffer */
66 uint64_t packet_size; /* Subbuffer size (include padding) */
67 unsigned long events_discarded; /*
68 * Events lost in this subbuffer since
69 * the beginning of the trace.
70 * (may overflow)
71 */
72 uint32_t cpu_id; /* CPU id associated with stream */
73 uint8_t header_end; /* End of header */
74 } ctx;
75 };
76
77
78 static inline notrace u64 lib_ring_buffer_clock_read(struct channel *chan)
79 {
80 return trace_clock_read64();
81 }
82
83 static inline
84 size_t ctx_get_size(size_t offset, struct lttng_ctx *ctx)
85 {
86 int i;
87 size_t orig_offset = offset;
88
89 if (likely(!ctx))
90 return 0;
91 for (i = 0; i < ctx->nr_fields; i++)
92 offset += ctx->fields[i].get_size(offset);
93 return offset - orig_offset;
94 }
95
96 static inline
97 void ctx_record(struct lib_ring_buffer_ctx *bufctx,
98 struct lttng_channel *chan,
99 struct lttng_ctx *ctx)
100 {
101 int i;
102
103 if (likely(!ctx))
104 return;
105 for (i = 0; i < ctx->nr_fields; i++)
106 ctx->fields[i].record(&ctx->fields[i], bufctx, chan);
107 }
108
109 /*
110 * record_header_size - Calculate the header size and padding necessary.
111 * @config: ring buffer instance configuration
112 * @chan: channel
113 * @offset: offset in the write buffer
114 * @pre_header_padding: padding to add before the header (output)
115 * @ctx: reservation context
116 *
117 * Returns the event header size (including padding).
118 *
119 * The payload must itself determine its own alignment from the biggest type it
120 * contains.
121 */
122 static __inline__
123 unsigned char record_header_size(const struct lib_ring_buffer_config *config,
124 struct channel *chan, size_t offset,
125 size_t *pre_header_padding,
126 struct lib_ring_buffer_ctx *ctx)
127 {
128 struct lttng_channel *lttng_chan = channel_get_private(chan);
129 struct lttng_event *event = ctx->priv;
130 size_t orig_offset = offset;
131 size_t padding;
132
133 switch (lttng_chan->header_type) {
134 case 1: /* compact */
135 padding = lib_ring_buffer_align(offset, lttng_alignof(uint32_t));
136 offset += padding;
137 if (!(ctx->rflags & (RING_BUFFER_RFLAG_FULL_TSC | LTTNG_RFLAG_EXTENDED))) {
138 offset += sizeof(uint32_t); /* id and timestamp */
139 } else {
140 /* Minimum space taken by LTTNG_COMPACT_EVENT_BITS id */
141 offset += (LTTNG_COMPACT_EVENT_BITS + CHAR_BIT - 1) / CHAR_BIT;
142 /* Align extended struct on largest member */
143 offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
144 offset += sizeof(uint32_t); /* id */
145 offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
146 offset += sizeof(uint64_t); /* timestamp */
147 }
148 break;
149 case 2: /* large */
150 padding = lib_ring_buffer_align(offset, lttng_alignof(uint16_t));
151 offset += padding;
152 offset += sizeof(uint16_t);
153 if (!(ctx->rflags & (RING_BUFFER_RFLAG_FULL_TSC | LTTNG_RFLAG_EXTENDED))) {
154 offset += lib_ring_buffer_align(offset, lttng_alignof(uint32_t));
155 offset += sizeof(uint32_t); /* timestamp */
156 } else {
157 /* Align extended struct on largest member */
158 offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
159 offset += sizeof(uint32_t); /* id */
160 offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
161 offset += sizeof(uint64_t); /* timestamp */
162 }
163 break;
164 default:
165 padding = 0;
166 WARN_ON_ONCE(1);
167 }
168 offset += ctx_get_size(offset, event->ctx);
169 offset += ctx_get_size(offset, lttng_chan->ctx);
170
171 *pre_header_padding = padding;
172 return offset - orig_offset;
173 }
174
175 #include "wrapper/ringbuffer/api.h"
176
177 static
178 void lttng_write_event_header_slow(const struct lib_ring_buffer_config *config,
179 struct lib_ring_buffer_ctx *ctx,
180 uint32_t event_id);
181
182 /*
183 * lttng_write_event_header
184 *
185 * Writes the event header to the offset (already aligned on 32-bits).
186 *
187 * @config: ring buffer instance configuration
188 * @ctx: reservation context
189 * @event_id: event ID
190 */
191 static __inline__
192 void lttng_write_event_header(const struct lib_ring_buffer_config *config,
193 struct lib_ring_buffer_ctx *ctx,
194 uint32_t event_id)
195 {
196 struct lttng_channel *lttng_chan = channel_get_private(ctx->chan);
197 struct lttng_event *event = ctx->priv;
198
199 if (unlikely(ctx->rflags))
200 goto slow_path;
201
202 switch (lttng_chan->header_type) {
203 case 1: /* compact */
204 {
205 uint32_t id_time = 0;
206
207 bt_bitfield_write(&id_time, uint32_t,
208 0,
209 LTTNG_COMPACT_EVENT_BITS,
210 event_id);
211 bt_bitfield_write(&id_time, uint32_t,
212 LTTNG_COMPACT_EVENT_BITS,
213 LTTNG_COMPACT_TSC_BITS,
214 ctx->tsc);
215 lib_ring_buffer_write(config, ctx, &id_time, sizeof(id_time));
216 break;
217 }
218 case 2: /* large */
219 {
220 uint32_t timestamp = (uint32_t) ctx->tsc;
221 uint16_t id = event_id;
222
223 lib_ring_buffer_write(config, ctx, &id, sizeof(id));
224 lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint32_t));
225 lib_ring_buffer_write(config, ctx, &timestamp, sizeof(timestamp));
226 break;
227 }
228 default:
229 WARN_ON_ONCE(1);
230 }
231
232 ctx_record(ctx, lttng_chan, lttng_chan->ctx);
233 ctx_record(ctx, lttng_chan, event->ctx);
234 lib_ring_buffer_align_ctx(ctx, ctx->largest_align);
235
236 return;
237
238 slow_path:
239 lttng_write_event_header_slow(config, ctx, event_id);
240 }
241
242 static
243 void lttng_write_event_header_slow(const struct lib_ring_buffer_config *config,
244 struct lib_ring_buffer_ctx *ctx,
245 uint32_t event_id)
246 {
247 struct lttng_channel *lttng_chan = channel_get_private(ctx->chan);
248 struct lttng_event *event = ctx->priv;
249
250 switch (lttng_chan->header_type) {
251 case 1: /* compact */
252 if (!(ctx->rflags & (RING_BUFFER_RFLAG_FULL_TSC | LTTNG_RFLAG_EXTENDED))) {
253 uint32_t id_time = 0;
254
255 bt_bitfield_write(&id_time, uint32_t,
256 0,
257 LTTNG_COMPACT_EVENT_BITS,
258 event_id);
259 bt_bitfield_write(&id_time, uint32_t,
260 LTTNG_COMPACT_EVENT_BITS,
261 LTTNG_COMPACT_TSC_BITS, ctx->tsc);
262 lib_ring_buffer_write(config, ctx, &id_time, sizeof(id_time));
263 } else {
264 uint8_t id = 0;
265 uint64_t timestamp = ctx->tsc;
266
267 bt_bitfield_write(&id, uint8_t,
268 0,
269 LTTNG_COMPACT_EVENT_BITS,
270 31);
271 lib_ring_buffer_write(config, ctx, &id, sizeof(id));
272 /* Align extended struct on largest member */
273 lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t));
274 lib_ring_buffer_write(config, ctx, &event_id, sizeof(event_id));
275 lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t));
276 lib_ring_buffer_write(config, ctx, &timestamp, sizeof(timestamp));
277 }
278 break;
279 case 2: /* large */
280 {
281 if (!(ctx->rflags & (RING_BUFFER_RFLAG_FULL_TSC | LTTNG_RFLAG_EXTENDED))) {
282 uint32_t timestamp = (uint32_t) ctx->tsc;
283 uint16_t id = event_id;
284
285 lib_ring_buffer_write(config, ctx, &id, sizeof(id));
286 lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint32_t));
287 lib_ring_buffer_write(config, ctx, &timestamp, sizeof(timestamp));
288 } else {
289 uint16_t id = 65535;
290 uint64_t timestamp = ctx->tsc;
291
292 lib_ring_buffer_write(config, ctx, &id, sizeof(id));
293 /* Align extended struct on largest member */
294 lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t));
295 lib_ring_buffer_write(config, ctx, &event_id, sizeof(event_id));
296 lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t));
297 lib_ring_buffer_write(config, ctx, &timestamp, sizeof(timestamp));
298 }
299 break;
300 }
301 default:
302 WARN_ON_ONCE(1);
303 }
304 ctx_record(ctx, lttng_chan, lttng_chan->ctx);
305 ctx_record(ctx, lttng_chan, event->ctx);
306 lib_ring_buffer_align_ctx(ctx, ctx->largest_align);
307 }
308
309 static const struct lib_ring_buffer_config client_config;
310
311 static u64 client_ring_buffer_clock_read(struct channel *chan)
312 {
313 return lib_ring_buffer_clock_read(chan);
314 }
315
316 static
317 size_t client_record_header_size(const struct lib_ring_buffer_config *config,
318 struct channel *chan, size_t offset,
319 size_t *pre_header_padding,
320 struct lib_ring_buffer_ctx *ctx)
321 {
322 return record_header_size(config, chan, offset,
323 pre_header_padding, ctx);
324 }
325
326 /**
327 * client_packet_header_size - called on buffer-switch to a new sub-buffer
328 *
329 * Return header size without padding after the structure. Don't use packed
330 * structure because gcc generates inefficient code on some architectures
331 * (powerpc, mips..)
332 */
333 static size_t client_packet_header_size(void)
334 {
335 return offsetof(struct packet_header, ctx.header_end);
336 }
337
338 static void client_buffer_begin(struct lib_ring_buffer *buf, u64 tsc,
339 unsigned int subbuf_idx)
340 {
341 struct channel *chan = buf->backend.chan;
342 struct packet_header *header =
343 (struct packet_header *)
344 lib_ring_buffer_offset_address(&buf->backend,
345 subbuf_idx * chan->backend.subbuf_size);
346 struct lttng_channel *lttng_chan = channel_get_private(chan);
347 struct lttng_session *session = lttng_chan->session;
348
349 header->magic = CTF_MAGIC_NUMBER;
350 memcpy(header->uuid, session->uuid.b, sizeof(session->uuid));
351 header->stream_id = lttng_chan->id;
352 header->ctx.timestamp_begin = tsc;
353 header->ctx.timestamp_end = 0;
354 header->ctx.content_size = ~0ULL; /* for debugging */
355 header->ctx.packet_size = ~0ULL;
356 header->ctx.events_discarded = 0;
357 header->ctx.cpu_id = buf->backend.cpu;
358 }
359
360 /*
361 * offset is assumed to never be 0 here : never deliver a completely empty
362 * subbuffer. data_size is between 1 and subbuf_size.
363 */
364 static void client_buffer_end(struct lib_ring_buffer *buf, u64 tsc,
365 unsigned int subbuf_idx, unsigned long data_size)
366 {
367 struct channel *chan = buf->backend.chan;
368 struct packet_header *header =
369 (struct packet_header *)
370 lib_ring_buffer_offset_address(&buf->backend,
371 subbuf_idx * chan->backend.subbuf_size);
372 unsigned long records_lost = 0;
373
374 header->ctx.timestamp_end = tsc;
375 header->ctx.content_size =
376 (uint64_t) data_size * CHAR_BIT; /* in bits */
377 header->ctx.packet_size =
378 (uint64_t) PAGE_ALIGN(data_size) * CHAR_BIT; /* in bits */
379 records_lost += lib_ring_buffer_get_records_lost_full(&client_config, buf);
380 records_lost += lib_ring_buffer_get_records_lost_wrap(&client_config, buf);
381 records_lost += lib_ring_buffer_get_records_lost_big(&client_config, buf);
382 header->ctx.events_discarded = records_lost;
383 }
384
385 static int client_buffer_create(struct lib_ring_buffer *buf, void *priv,
386 int cpu, const char *name)
387 {
388 return 0;
389 }
390
391 static void client_buffer_finalize(struct lib_ring_buffer *buf, void *priv, int cpu)
392 {
393 }
394
395 static struct packet_header *client_packet_header(
396 const struct lib_ring_buffer_config *config,
397 struct lib_ring_buffer *buf)
398 {
399 return lib_ring_buffer_read_offset_address(&buf->backend, 0);
400 }
401
402 static int client_timestamp_begin(const struct lib_ring_buffer_config *config,
403 struct lib_ring_buffer *buf,
404 uint64_t *timestamp_begin)
405 {
406 struct packet_header *header = client_packet_header(config, buf);
407 *timestamp_begin = header->ctx.timestamp_begin;
408
409 return 0;
410 }
411
412 static int client_timestamp_end(const struct lib_ring_buffer_config *config,
413 struct lib_ring_buffer *buf,
414 uint64_t *timestamp_end)
415 {
416 struct packet_header *header = client_packet_header(config, buf);
417 *timestamp_end = header->ctx.timestamp_end;
418
419 return 0;
420 }
421
422 static int client_events_discarded(const struct lib_ring_buffer_config *config,
423 struct lib_ring_buffer *buf,
424 uint64_t *events_discarded)
425 {
426 struct packet_header *header = client_packet_header(config, buf);
427 *events_discarded = header->ctx.events_discarded;
428
429 return 0;
430 }
431
432 static int client_content_size(const struct lib_ring_buffer_config *config,
433 struct lib_ring_buffer *buf,
434 uint64_t *content_size)
435 {
436 struct packet_header *header = client_packet_header(config, buf);
437 *content_size = header->ctx.content_size;
438
439 return 0;
440 }
441
442 static int client_packet_size(const struct lib_ring_buffer_config *config,
443 struct lib_ring_buffer *buf,
444 uint64_t *packet_size)
445 {
446 struct packet_header *header = client_packet_header(config, buf);
447 *packet_size = header->ctx.packet_size;
448
449 return 0;
450 }
451
452 static int client_stream_id(const struct lib_ring_buffer_config *config,
453 struct lib_ring_buffer *buf,
454 uint64_t *stream_id)
455 {
456 struct packet_header *header = client_packet_header(config, buf);
457 *stream_id = header->stream_id;
458
459 return 0;
460 }
461
462 static int client_current_timestamp(const struct lib_ring_buffer_config *config,
463 struct lib_ring_buffer *bufb,
464 uint64_t *ts)
465 {
466 *ts = config->cb.ring_buffer_clock_read(bufb->backend.chan);
467
468 return 0;
469 }
470
471 static const struct lib_ring_buffer_config client_config = {
472 .cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
473 .cb.record_header_size = client_record_header_size,
474 .cb.subbuffer_header_size = client_packet_header_size,
475 .cb.buffer_begin = client_buffer_begin,
476 .cb.buffer_end = client_buffer_end,
477 .cb.buffer_create = client_buffer_create,
478 .cb.buffer_finalize = client_buffer_finalize,
479
480 .tsc_bits = LTTNG_COMPACT_TSC_BITS,
481 .alloc = RING_BUFFER_ALLOC_PER_CPU,
482 .sync = RING_BUFFER_SYNC_PER_CPU,
483 .mode = RING_BUFFER_MODE_TEMPLATE,
484 .backend = RING_BUFFER_PAGE,
485 .output = RING_BUFFER_OUTPUT_TEMPLATE,
486 .oops = RING_BUFFER_OOPS_CONSISTENCY,
487 .ipi = RING_BUFFER_IPI_BARRIER,
488 .wakeup = RING_BUFFER_WAKEUP_BY_TIMER,
489 };
490
491 static
492 void release_priv_ops(void *priv_ops)
493 {
494 module_put(THIS_MODULE);
495 }
496
497 static
498 void lttng_channel_destroy(struct channel *chan)
499 {
500 channel_destroy(chan);
501 }
502
503 static
504 struct channel *_channel_create(const char *name,
505 struct lttng_channel *lttng_chan, void *buf_addr,
506 size_t subbuf_size, size_t num_subbuf,
507 unsigned int switch_timer_interval,
508 unsigned int read_timer_interval)
509 {
510 struct channel *chan;
511
512 chan = channel_create(&client_config, name, lttng_chan, buf_addr,
513 subbuf_size, num_subbuf, switch_timer_interval,
514 read_timer_interval);
515 if (chan) {
516 /*
517 * Ensure this module is not unloaded before we finish
518 * using lttng_relay_transport.ops.
519 */
520 if (!try_module_get(THIS_MODULE)) {
521 printk(KERN_WARNING "LTT : Can't lock transport module.\n");
522 goto error;
523 }
524 chan->backend.priv_ops = &lttng_relay_transport.ops;
525 chan->backend.release_priv_ops = release_priv_ops;
526 }
527 return chan;
528
529 error:
530 lttng_channel_destroy(chan);
531 return NULL;
532 }
533
534 static
535 struct lib_ring_buffer *lttng_buffer_read_open(struct channel *chan)
536 {
537 struct lib_ring_buffer *buf;
538 int cpu;
539
540 for_each_channel_cpu(cpu, chan) {
541 buf = channel_get_ring_buffer(&client_config, chan, cpu);
542 if (!lib_ring_buffer_open_read(buf))
543 return buf;
544 }
545 return NULL;
546 }
547
548 static
549 int lttng_buffer_has_read_closed_stream(struct channel *chan)
550 {
551 struct lib_ring_buffer *buf;
552 int cpu;
553
554 for_each_channel_cpu(cpu, chan) {
555 buf = channel_get_ring_buffer(&client_config, chan, cpu);
556 if (!atomic_long_read(&buf->active_readers))
557 return 1;
558 }
559 return 0;
560 }
561
562 static
563 void lttng_buffer_read_close(struct lib_ring_buffer *buf)
564 {
565 lib_ring_buffer_release_read(buf);
566 }
567
568 static
569 int lttng_event_reserve(struct lib_ring_buffer_ctx *ctx,
570 uint32_t event_id)
571 {
572 struct lttng_channel *lttng_chan = channel_get_private(ctx->chan);
573 int ret, cpu;
574
575 cpu = lib_ring_buffer_get_cpu(&client_config);
576 if (cpu < 0)
577 return -EPERM;
578 ctx->cpu = cpu;
579
580 switch (lttng_chan->header_type) {
581 case 1: /* compact */
582 if (event_id > 30)
583 ctx->rflags |= LTTNG_RFLAG_EXTENDED;
584 break;
585 case 2: /* large */
586 if (event_id > 65534)
587 ctx->rflags |= LTTNG_RFLAG_EXTENDED;
588 break;
589 default:
590 WARN_ON_ONCE(1);
591 }
592
593 ret = lib_ring_buffer_reserve(&client_config, ctx);
594 if (ret)
595 goto put;
596 lttng_write_event_header(&client_config, ctx, event_id);
597 return 0;
598 put:
599 lib_ring_buffer_put_cpu(&client_config);
600 return ret;
601 }
602
603 static
604 void lttng_event_commit(struct lib_ring_buffer_ctx *ctx)
605 {
606 lib_ring_buffer_commit(&client_config, ctx);
607 lib_ring_buffer_put_cpu(&client_config);
608 }
609
610 static
611 void lttng_event_write(struct lib_ring_buffer_ctx *ctx, const void *src,
612 size_t len)
613 {
614 lib_ring_buffer_write(&client_config, ctx, src, len);
615 }
616
617 static
618 void lttng_event_write_from_user(struct lib_ring_buffer_ctx *ctx,
619 const void __user *src, size_t len)
620 {
621 lib_ring_buffer_copy_from_user_inatomic(&client_config, ctx, src, len);
622 }
623
624 static
625 void lttng_event_memset(struct lib_ring_buffer_ctx *ctx,
626 int c, size_t len)
627 {
628 lib_ring_buffer_memset(&client_config, ctx, c, len);
629 }
630
631 static
632 wait_queue_head_t *lttng_get_writer_buf_wait_queue(struct channel *chan, int cpu)
633 {
634 struct lib_ring_buffer *buf = channel_get_ring_buffer(&client_config,
635 chan, cpu);
636 return &buf->write_wait;
637 }
638
639 static
640 wait_queue_head_t *lttng_get_hp_wait_queue(struct channel *chan)
641 {
642 return &chan->hp_wait;
643 }
644
645 static
646 int lttng_is_finalized(struct channel *chan)
647 {
648 return lib_ring_buffer_channel_is_finalized(chan);
649 }
650
651 static
652 int lttng_is_disabled(struct channel *chan)
653 {
654 return lib_ring_buffer_channel_is_disabled(chan);
655 }
656
657 static struct lttng_transport lttng_relay_transport = {
658 .name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING,
659 .owner = THIS_MODULE,
660 .ops = {
661 .channel_create = _channel_create,
662 .channel_destroy = lttng_channel_destroy,
663 .buffer_read_open = lttng_buffer_read_open,
664 .buffer_has_read_closed_stream =
665 lttng_buffer_has_read_closed_stream,
666 .buffer_read_close = lttng_buffer_read_close,
667 .event_reserve = lttng_event_reserve,
668 .event_commit = lttng_event_commit,
669 .event_write = lttng_event_write,
670 .event_write_from_user = lttng_event_write_from_user,
671 .event_memset = lttng_event_memset,
672 .packet_avail_size = NULL, /* Would be racy anyway */
673 .get_writer_buf_wait_queue = lttng_get_writer_buf_wait_queue,
674 .get_hp_wait_queue = lttng_get_hp_wait_queue,
675 .is_finalized = lttng_is_finalized,
676 .is_disabled = lttng_is_disabled,
677 .timestamp_begin = client_timestamp_begin,
678 .timestamp_end = client_timestamp_end,
679 .events_discarded = client_events_discarded,
680 .content_size = client_content_size,
681 .packet_size = client_packet_size,
682 .stream_id = client_stream_id,
683 .current_timestamp = client_current_timestamp,
684 },
685 };
686
687 static int __init lttng_ring_buffer_client_init(void)
688 {
689 /*
690 * This vmalloc sync all also takes care of the lib ring buffer
691 * vmalloc'd module pages when it is built as a module into LTTng.
692 */
693 wrapper_vmalloc_sync_all();
694 lttng_transport_register(&lttng_relay_transport);
695 return 0;
696 }
697
698 module_init(lttng_ring_buffer_client_init);
699
700 static void __exit lttng_ring_buffer_client_exit(void)
701 {
702 lttng_transport_unregister(&lttng_relay_transport);
703 }
704
705 module_exit(lttng_ring_buffer_client_exit);
706
707 MODULE_LICENSE("GPL and additional rights");
708 MODULE_AUTHOR("Mathieu Desnoyers");
709 MODULE_DESCRIPTION("LTTng ring buffer " RING_BUFFER_MODE_TEMPLATE_STRING
710 " client");
This page took 0.044358 seconds and 5 git commands to generate.