1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
7 * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/sched.h>
13 #include <linux/syscalls.h>
14 #include <lttng-events.h>
15 #include <wrapper/ringbuffer/frontend_types.h>
16 #include <wrapper/vmalloc.h>
17 #include <lttng-tracer.h>
20 size_t ppid_get_size(size_t offset
)
24 size
+= lib_ring_buffer_align(offset
, lttng_alignof(pid_t
));
25 size
+= sizeof(pid_t
);
30 void ppid_record(struct lttng_ctx_field
*field
,
31 struct lib_ring_buffer_ctx
*ctx
,
32 struct lttng_channel
*chan
)
37 * TODO: when we eventually add RCU subsystem instrumentation,
38 * taking the rcu read lock here will trigger RCU tracing
39 * recursively. We should modify the kernel synchronization so
40 * it synchronizes both for RCU and RCU sched, and rely on
41 * rcu_read_lock_sched_notrace.
44 ppid
= task_tgid_nr(current
->real_parent
);
46 lib_ring_buffer_align_ctx(ctx
, lttng_alignof(ppid
));
47 chan
->ops
->event_write(ctx
, &ppid
, sizeof(ppid
));
51 void ppid_get_value(struct lttng_ctx_field
*field
,
52 struct lttng_probe_ctx
*lttng_probe_ctx
,
53 union lttng_ctx_value
*value
)
58 * TODO: when we eventually add RCU subsystem instrumentation,
59 * taking the rcu read lock here will trigger RCU tracing
60 * recursively. We should modify the kernel synchronization so
61 * it synchronizes both for RCU and RCU sched, and rely on
62 * rcu_read_lock_sched_notrace.
65 ppid
= task_tgid_nr(current
->real_parent
);
70 int lttng_add_ppid_to_ctx(struct lttng_ctx
**ctx
)
72 struct lttng_ctx_field
*field
;
74 field
= lttng_append_context(ctx
);
77 if (lttng_find_context(*ctx
, "ppid")) {
78 lttng_remove_context_field(ctx
, field
);
81 field
->event_field
.name
= "ppid";
82 field
->event_field
.type
.atype
= atype_integer
;
83 field
->event_field
.type
.u
.basic
.integer
.size
= sizeof(pid_t
) * CHAR_BIT
;
84 field
->event_field
.type
.u
.basic
.integer
.alignment
= lttng_alignof(pid_t
) * CHAR_BIT
;
85 field
->event_field
.type
.u
.basic
.integer
.signedness
= lttng_is_signed_type(pid_t
);
86 field
->event_field
.type
.u
.basic
.integer
.reverse_byte_order
= 0;
87 field
->event_field
.type
.u
.basic
.integer
.base
= 10;
88 field
->event_field
.type
.u
.basic
.integer
.encoding
= lttng_encode_none
;
89 field
->get_size
= ppid_get_size
;
90 field
->record
= ppid_record
;
91 field
->get_value
= ppid_get_value
;
92 lttng_context_update(*ctx
);
93 wrapper_vmalloc_sync_mappings();
96 EXPORT_SYMBOL_GPL(lttng_add_ppid_to_ctx
);
This page took 0.048117 seconds and 4 git commands to generate.