Add disabled compat syscalls detail (work in progress)
[lttng-modules.git] / lttng-context-comm.c
1 /*
2 * (C) Copyright 2009-2011 -
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 *
5 * LTTng comm name context.
6 *
7 * Dual LGPL v2.1/GPL v2 license.
8 */
9
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"
17
18 static
19 size_t comm_get_size(size_t offset)
20 {
21 size_t size = 0;
22
23 size += sizeof(current->comm);
24 return size;
25 }
26
27 /*
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.
32 */
33 static
34 void comm_record(struct lttng_ctx_field *field,
35 struct lib_ring_buffer_ctx *ctx,
36 struct ltt_channel *chan)
37 {
38 chan->ops->event_write(ctx, current->comm, sizeof(current->comm));
39 }
40
41 int lttng_add_comm_to_ctx(struct lttng_ctx **ctx)
42 {
43 struct lttng_ctx_field *field;
44
45 field = lttng_append_context(ctx);
46 if (!field)
47 return -ENOMEM;
48 if (lttng_find_context(*ctx, "comm")) {
49 lttng_remove_context_field(ctx, field);
50 return -EEXIST;
51 }
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);
62
63 field->get_size = comm_get_size;
64 field->record = comm_record;
65 wrapper_vmalloc_sync_all();
66 return 0;
67 }
68 EXPORT_SYMBOL_GPL(lttng_add_comm_to_ctx);
69
70 MODULE_LICENSE("GPL and additional rights");
71 MODULE_AUTHOR("Mathieu Desnoyers");
72 MODULE_DESCRIPTION("Linux Trace Toolkit Perf Support");
This page took 0.030421 seconds and 4 git commands to generate.