2 * lttng-context-interruptible.c
4 * LTTng interruptible context.
6 * Copyright (C) 2009-2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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.
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.
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
23 #include <linux/module.h>
24 #include <linux/slab.h>
25 #include <linux/sched.h>
26 #include <linux/irqflags.h>
27 #include <lttng-events.h>
28 #include <wrapper/ringbuffer/frontend_types.h>
29 #include <wrapper/vmalloc.h>
30 #include <lttng-tracer.h>
33 * Interruptible at value -1 means "unknown".
37 size_t interruptible_get_size(size_t offset
)
41 size
+= lib_ring_buffer_align(offset
, lttng_alignof(int8_t));
42 size
+= sizeof(int8_t);
47 void interruptible_record(struct lttng_ctx_field
*field
,
48 struct lib_ring_buffer_ctx
*ctx
,
49 struct lttng_channel
*chan
)
51 struct lttng_probe_ctx
*lttng_probe_ctx
= ctx
->priv
;
52 int8_t interruptible
= lttng_probe_ctx
->interruptible
;
54 lib_ring_buffer_align_ctx(ctx
, lttng_alignof(interruptible
));
55 chan
->ops
->event_write(ctx
, &interruptible
, sizeof(interruptible
));
59 void interruptible_get_value(struct lttng_ctx_field
*field
,
60 struct lttng_probe_ctx
*lttng_probe_ctx
,
61 union lttng_ctx_value
*value
)
63 int8_t interruptible
= lttng_probe_ctx
->interruptible
;
65 value
->s64
= interruptible
;
68 int lttng_add_interruptible_to_ctx(struct lttng_ctx
**ctx
)
70 struct lttng_ctx_field
*field
;
72 field
= lttng_append_context(ctx
);
75 if (lttng_find_context(*ctx
, "interruptible")) {
76 lttng_remove_context_field(ctx
, field
);
79 field
->event_field
.name
= "interruptible";
80 field
->event_field
.type
.atype
= atype_integer
;
81 field
->event_field
.type
.u
.basic
.integer
.size
= sizeof(int8_t) * CHAR_BIT
;
82 field
->event_field
.type
.u
.basic
.integer
.alignment
= lttng_alignof(int8_t) * CHAR_BIT
;
83 field
->event_field
.type
.u
.basic
.integer
.signedness
= lttng_is_signed_type(int8_t);
84 field
->event_field
.type
.u
.basic
.integer
.reverse_byte_order
= 0;
85 field
->event_field
.type
.u
.basic
.integer
.base
= 10;
86 field
->event_field
.type
.u
.basic
.integer
.encoding
= lttng_encode_none
;
87 field
->get_size
= interruptible_get_size
;
88 field
->record
= interruptible_record
;
89 field
->get_value
= interruptible_get_value
;
90 lttng_context_update(*ctx
);
91 wrapper_vmalloc_sync_all();
94 EXPORT_SYMBOL_GPL(lttng_add_interruptible_to_ctx
);