2 * (C) Copyright 2009-2011 -
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * LTTng comm name context.
7 * Dual LGPL v2.1/GPL v2 license.
10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/sched.h>
13 #include "ltt-events.h"
14 #include "wrapper/ringbuffer/frontend_types.h"
15 #include "wrapper/vmalloc.h"
16 #include "ltt-tracer.h"
19 size_t comm_get_size(size_t offset
)
23 size
+= sizeof(current
->comm
);
28 * Racy read of comm. We simply copy its whole array size.
29 * Races with /proc/<task>/comm write only.
30 * Otherwise having to take a mutex for each event is cumbersome and
31 * could lead to crash in IRQ context and deadlock of the lockdep tracer.
34 void comm_record(struct lttng_ctx_field
*field
,
35 struct lib_ring_buffer_ctx
*ctx
,
36 struct ltt_channel
*chan
)
38 chan
->ops
->event_write(ctx
, current
->comm
, sizeof(current
->comm
));
41 int lttng_add_comm_to_ctx(struct lttng_ctx
**ctx
)
43 struct lttng_ctx_field
*field
;
45 field
= lttng_append_context(ctx
);
48 if (lttng_find_context(*ctx
, "comm")) {
49 lttng_remove_context_field(ctx
, field
);
52 field
->event_field
.name
= "comm";
53 field
->event_field
.type
.atype
= atype_array
;
54 field
->event_field
.type
.u
.array
.elem_type
.atype
= atype_integer
;
55 field
->event_field
.type
.u
.array
.elem_type
.u
.basic
.integer
.size
= sizeof(char) * CHAR_BIT
;
56 field
->event_field
.type
.u
.array
.elem_type
.u
.basic
.integer
.alignment
= ltt_alignof(char) * CHAR_BIT
;
57 field
->event_field
.type
.u
.array
.elem_type
.u
.basic
.integer
.signedness
= is_signed_type(char);
58 field
->event_field
.type
.u
.array
.elem_type
.u
.basic
.integer
.reverse_byte_order
= 0;
59 field
->event_field
.type
.u
.array
.elem_type
.u
.basic
.integer
.base
= 10;
60 field
->event_field
.type
.u
.array
.elem_type
.u
.basic
.integer
.encoding
= lttng_encode_UTF8
;
61 field
->event_field
.type
.u
.array
.length
= sizeof(current
->comm
);
63 field
->get_size
= comm_get_size
;
64 field
->record
= comm_record
;
65 wrapper_vmalloc_sync_all();
68 EXPORT_SYMBOL_GPL(lttng_add_comm_to_ctx
);
70 MODULE_LICENSE("GPL and additional rights");
71 MODULE_AUTHOR("Mathieu Desnoyers");
72 MODULE_DESCRIPTION("Linux Trace Toolkit Perf Support");
This page took 0.032058 seconds and 4 git commands to generate.