X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=lttng-context-vtid.c;h=3dd34ae3f3a16f5b9fe39c0bcca61db9f587a6fd;hb=f97eaafb28e11d68919a6d53278b117343f33d60;hp=f81fff636acd35d914a2756c567e68d03d562c24;hpb=09fec6b43d11b3e0ece36f9e9e44b9627c1b565d;p=lttng-modules.git diff --git a/lttng-context-vtid.c b/lttng-context-vtid.c index f81fff63..3dd34ae3 100644 --- a/lttng-context-vtid.c +++ b/lttng-context-vtid.c @@ -10,17 +10,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 vtid_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; } @@ -28,27 +28,36 @@ size_t vtid_get_size(size_t offset) static void vtid_record(struct lttng_ctx_field *field, struct lib_ring_buffer_ctx *ctx, - struct ltt_channel *chan) + struct lttng_channel *chan) { pid_t vtid; - vtid = task_pid_vnr(current); - lib_ring_buffer_align_ctx(ctx, ltt_alignof(vtid)); + /* + * nsproxy can be NULL when scheduled out of exit. + */ + if (!current->nsproxy) + vtid = 0; + else + vtid = task_pid_vnr(current); + lib_ring_buffer_align_ctx(ctx, lttng_alignof(vtid)); chan->ops->event_write(ctx, &vtid, sizeof(vtid)); } int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx) { struct lttng_ctx_field *field; - int ret; field = lttng_append_context(ctx); if (!field) return -ENOMEM; + if (lttng_find_context(*ctx, "vtid")) { + lttng_remove_context_field(ctx, field); + return -EEXIST; + } field->event_field.name = "vtid"; 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;