Fix: timer_expire_entry changed in 4.19.312
[lttng-modules.git] / src / lttng-context-prio.c
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
9f36eaed 2 *
886d51a3 3 * lttng-context-prio.c
a8ad3613
MD
4 *
5 * LTTng priority context.
6 *
886d51a3 7 * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
a8ad3613
MD
8 */
9
10#include <linux/module.h>
11#include <linux/slab.h>
12#include <linux/sched.h>
2df37e95 13#include <lttng/events.h>
437d5aa5 14#include <lttng/events-internal.h>
24591303 15#include <ringbuffer/frontend_types.h>
241ae9a8 16#include <wrapper/vmalloc.h>
2df37e95 17#include <lttng/tracer.h>
a8ad3613 18
3dfec228 19/*
ff024e66
MD
20 * task_prio() has been implemented as p->prio - MAX_RT_PRIO since at
21 * least kernel v3.0.
3dfec228 22 */
ff024e66
MD
23static
24int wrapper_task_prio(struct task_struct *p)
3dfec228 25{
ff024e66 26 return p->prio - MAX_RT_PRIO;
3dfec228
MJ
27}
28
a8ad3613 29static
a92e844e 30size_t prio_get_size(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, size_t offset)
a8ad3613
MD
31{
32 size_t size = 0;
33
a90917c3 34 size += lib_ring_buffer_align(offset, lttng_alignof(int));
a8ad3613
MD
35 size += sizeof(int);
36 return size;
37}
38
39static
a92e844e 40void prio_record(void *priv, struct lttng_kernel_probe_ctx *probe_ctx,
8a57ec02 41 struct lttng_kernel_ring_buffer_ctx *ctx,
f7d06400 42 struct lttng_kernel_channel_buffer *chan)
a8ad3613
MD
43{
44 int prio;
45
ff024e66 46 prio = wrapper_task_prio(current);
f5ffbd77 47 chan->ops->event_write(ctx, &prio, sizeof(prio), lttng_alignof(prio));
a8ad3613
MD
48}
49
f127e61e 50static
2dc781e0 51void prio_get_value(void *priv,
a92e844e 52 struct lttng_kernel_probe_ctx *lttng_probe_ctx,
2dc781e0 53 struct lttng_ctx_value *value)
f127e61e 54{
ff024e66 55 value->u.s64 = wrapper_task_prio(current);
f127e61e
MD
56}
57
437d5aa5
MD
58static const struct lttng_kernel_ctx_field *ctx_field = lttng_kernel_static_ctx_field(
59 lttng_kernel_static_event_field("prio",
60 lttng_kernel_static_type_integer_from_type(int, __BYTE_ORDER, 10),
4697aac7 61 false, false),
437d5aa5 62 prio_get_size,
437d5aa5
MD
63 prio_record,
64 prio_get_value,
65 NULL, NULL);
66
67int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx)
a8ad3613 68{
a8ad3613
MD
69 int ret;
70
437d5aa5 71 if (lttng_kernel_find_context(*ctx, ctx_field->event_field->name))
44252f0f 72 return -EEXIST;
437d5aa5 73 ret = lttng_kernel_context_append(ctx, ctx_field);
263b6c88 74 wrapper_vmalloc_sync_mappings();
437d5aa5 75 return ret;
a8ad3613
MD
76}
77EXPORT_SYMBOL_GPL(lttng_add_prio_to_ctx);
This page took 0.059568 seconds and 4 git commands to generate.