1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
3 * lttng-context-interruptible.c
5 * LTTng interruptible context.
7 * Copyright (C) 2009-2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/sched.h>
13 #include <linux/irqflags.h>
14 #include <lttng-events.h>
15 #include <wrapper/ringbuffer/frontend_types.h>
16 #include <wrapper/vmalloc.h>
17 #include <lttng-tracer.h>
20 * Interruptible at value -1 means "unknown".
24 size_t interruptible_get_size(size_t offset
)
28 size
+= lib_ring_buffer_align(offset
, lttng_alignof(int8_t));
29 size
+= sizeof(int8_t);
34 void interruptible_record(struct lttng_ctx_field
*field
,
35 struct lib_ring_buffer_ctx
*ctx
,
36 struct lttng_channel
*chan
)
38 struct lttng_probe_ctx
*lttng_probe_ctx
= ctx
->priv
;
39 int8_t interruptible
= lttng_probe_ctx
->interruptible
;
41 lib_ring_buffer_align_ctx(ctx
, lttng_alignof(interruptible
));
42 chan
->ops
->event_write(ctx
, &interruptible
, sizeof(interruptible
));
46 void interruptible_get_value(struct lttng_ctx_field
*field
,
47 struct lttng_probe_ctx
*lttng_probe_ctx
,
48 union lttng_ctx_value
*value
)
50 int8_t interruptible
= lttng_probe_ctx
->interruptible
;
52 value
->s64
= interruptible
;
55 int lttng_add_interruptible_to_ctx(struct lttng_ctx
**ctx
)
57 struct lttng_ctx_field
*field
;
59 field
= lttng_append_context(ctx
);
62 if (lttng_find_context(*ctx
, "interruptible")) {
63 lttng_remove_context_field(ctx
, field
);
66 field
->event_field
.name
= "interruptible";
67 field
->event_field
.type
.atype
= atype_integer
;
68 field
->event_field
.type
.u
.basic
.integer
.size
= sizeof(int8_t) * CHAR_BIT
;
69 field
->event_field
.type
.u
.basic
.integer
.alignment
= lttng_alignof(int8_t) * CHAR_BIT
;
70 field
->event_field
.type
.u
.basic
.integer
.signedness
= lttng_is_signed_type(int8_t);
71 field
->event_field
.type
.u
.basic
.integer
.reverse_byte_order
= 0;
72 field
->event_field
.type
.u
.basic
.integer
.base
= 10;
73 field
->event_field
.type
.u
.basic
.integer
.encoding
= lttng_encode_none
;
74 field
->get_size
= interruptible_get_size
;
75 field
->record
= interruptible_record
;
76 field
->get_value
= interruptible_get_value
;
77 lttng_context_update(*ctx
);
78 wrapper_vmalloc_sync_all();
81 EXPORT_SYMBOL_GPL(lttng_add_interruptible_to_ctx
);