Update nohz
[lttng-modules.git] / ltt-event-header.c
CommitLineData
1c8284eb
MD
1/*
2 * ltt/ltt-event-header.c
3 *
4 * (C) Copyright 2010 - Mathieu Desnoyers (mathieu.desnoyers@efficios.com)
5 *
6 * LTTng event header.
7 *
8 * Author:
9 * Mathieu Desnoyers (mathieu.desnoyers@efficios.com)
10 *
11 * Dual LGPL v2.1/GPL v2 license.
12 */
13
14#include <linux/module.h>
1c8284eb 15#include "ltt-tracer.h"
1c8284eb 16
1c25284c 17void ltt_write_event_header_slow(const struct lib_ring_buffer_config *config,
7514523f
MD
18 struct lib_ring_buffer_ctx *ctx,
19 u16 eID, u32 event_size)
1c8284eb 20{
7514523f 21 struct event_header header;
1c8284eb
MD
22 u16 small_size;
23
1c25284c 24 switch (ctx->rflags) {
1c8284eb
MD
25 case LTT_RFLAG_ID_SIZE_TSC:
26 header.id_time = 29 << LTT_TSC_BITS;
27 break;
28 case LTT_RFLAG_ID_SIZE:
29 header.id_time = 30 << LTT_TSC_BITS;
30 break;
31 case LTT_RFLAG_ID:
32 header.id_time = 31 << LTT_TSC_BITS;
33 break;
34 default:
35 WARN_ON_ONCE(1);
36 header.id_time = 0;
37 }
38
1c25284c 39 header.id_time |= (u32)ctx->tsc & LTT_TSC_MASK;
7514523f 40 lib_ring_buffer_write(config, ctx, &header, sizeof(header));
1c8284eb 41
1c25284c 42 switch (ctx->rflags) {
1c8284eb
MD
43 case LTT_RFLAG_ID_SIZE_TSC:
44 small_size = (u16)min_t(u32, event_size, LTT_MAX_SMALL_SIZE);
7514523f
MD
45 lib_ring_buffer_write(config, ctx, &eID, sizeof(u16));
46 lib_ring_buffer_write(config, ctx, &small_size, sizeof(u16));
47 if (small_size == LTT_MAX_SMALL_SIZE)
48 lib_ring_buffer_write(config, ctx, &event_size,
49 sizeof(u32));
6db3d13b 50 lib_ring_buffer_align_ctx(ctx, sizeof(u64));
7514523f 51 lib_ring_buffer_write(config, ctx, &ctx->tsc, sizeof(u64));
1c8284eb
MD
52 break;
53 case LTT_RFLAG_ID_SIZE:
54 small_size = (u16)min_t(u32, event_size, LTT_MAX_SMALL_SIZE);
7514523f
MD
55 lib_ring_buffer_write(config, ctx, &eID, sizeof(u16));
56 lib_ring_buffer_write(config, ctx, &small_size, sizeof(u16));
57 if (small_size == LTT_MAX_SMALL_SIZE)
58 lib_ring_buffer_write(config, ctx, &event_size,
59 sizeof(u32));
1c8284eb
MD
60 break;
61 case LTT_RFLAG_ID:
7514523f 62 lib_ring_buffer_write(config, ctx, &eID, sizeof(u16));
1c8284eb
MD
63 break;
64 }
1c8284eb
MD
65}
66EXPORT_SYMBOL_GPL(ltt_write_event_header_slow);
This page took 0.026002 seconds and 4 git commands to generate.