X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=lttng-context-vppid.c;h=f01b02068d67fa8ef1bdfc8e1a278f93b27cf618;hb=edb5c2da83545004c5f556accb79d010a6b1e3a9;hp=813ccc61115d31a26463ead8ce647d949e2e9d6b;hpb=b64bc438d1c9bbcf241c598ca9f0e00d5770d784;p=lttng-modules.git diff --git a/lttng-context-vppid.c b/lttng-context-vppid.c index 813ccc61..f01b0206 100644 --- a/lttng-context-vppid.c +++ b/lttng-context-vppid.c @@ -31,10 +31,18 @@ void vppid_record(struct lttng_ctx_field *field, struct lib_ring_buffer_ctx *ctx, struct ltt_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)); chan->ops->event_write(ctx, &vppid, sizeof(vppid)); @@ -43,11 +51,14 @@ void vppid_record(struct lttng_ctx_field *field, int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx) { struct lttng_ctx_field *field; - int ret; field = lttng_append_context(ctx); if (!field) - return ret; + 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;