X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=lttng-context-vppid.c;h=2fe2ffd1c1a0d02606f77f6232db27bf12797efe;hb=4d1704b64f53c4e188eff3e61f857fac20860ac6;hp=d55e12db6b2541afd1d7da7274fdb6385f326088;hpb=09fec6b43d11b3e0ece36f9e9e44b9627c1b565d;p=lttng-modules.git diff --git a/lttng-context-vppid.c b/lttng-context-vppid.c index d55e12db..2fe2ffd1 100644 --- a/lttng-context-vppid.c +++ b/lttng-context-vppid.c @@ -11,17 +11,17 @@ #include #include #include -#include "ltt-events.h" +#include "lttng-events.h" #include "wrapper/ringbuffer/frontend_types.h" #include "wrapper/vmalloc.h" -#include "ltt-tracer.h" +#include "lttng-tracer.h" static size_t vppid_get_size(size_t offset) { size_t size = 0; - size += lib_ring_buffer_align(offset, ltt_alignof(pid_t)); + size += lib_ring_buffer_align(offset, lttng_alignof(pid_t)); size += sizeof(pid_t); return size; } @@ -29,14 +29,22 @@ size_t vppid_get_size(size_t offset) static void vppid_record(struct lttng_ctx_field *field, struct lib_ring_buffer_ctx *ctx, - struct ltt_channel *chan) + struct lttng_channel *chan) { + struct task_struct *parent; pid_t vppid; + /* + * nsproxy can be NULL when scheduled out of exit. + */ rcu_read_lock(); - vppid = task_tgid_vnr(current->real_parent); + parent = rcu_dereference(current->real_parent); + if (!parent->nsproxy) + vppid = 0; + else + vppid = task_tgid_vnr(parent); rcu_read_unlock(); - lib_ring_buffer_align_ctx(ctx, ltt_alignof(vppid)); + lib_ring_buffer_align_ctx(ctx, lttng_alignof(vppid)); chan->ops->event_write(ctx, &vppid, sizeof(vppid)); } @@ -47,10 +55,14 @@ int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx) field = lttng_append_context(ctx); if (!field) return -ENOMEM; + if (lttng_find_context(*ctx, "vppid")) { + lttng_remove_context_field(ctx, field); + return -EEXIST; + } field->event_field.name = "vppid"; field->event_field.type.atype = atype_integer; field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT; - field->event_field.type.u.basic.integer.alignment = ltt_alignof(pid_t) * CHAR_BIT; + field->event_field.type.u.basic.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT; field->event_field.type.u.basic.integer.signedness = is_signed_type(pid_t); field->event_field.type.u.basic.integer.reverse_byte_order = 0; field->event_field.type.u.basic.integer.base = 10;