From: Mathieu Desnoyers Date: Thu, 23 Jun 2011 15:31:12 +0000 (-0400) Subject: Add pid/ppid/tid/vtid/vpid/vppid contexts X-Git-Tag: v2.0-pre1~49 X-Git-Url: http://git.lttng.org./?a=commitdiff_plain;ds=sidebyside;h=b64bc438d1c9bbcf241c598ca9f0e00d5770d784;hp=c6485006a92b1b86fbb48c2b277732d3405295c9;p=lttng-modules.git Add pid/ppid/tid/vtid/vpid/vppid contexts Use the values returned by gettid(), getpid() and getppid() for vtid, vpid, vppid. Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile b/Makefile index dc44fd40..517d1f75 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,10 @@ obj-m += ltt-relay.o ltt-relay-objs := ltt-events.o ltt-debugfs-abi.o \ ltt-probes.o ltt-core.o ltt-context.o \ lttng-context-pid.o lttng-context-comm.o \ - lttng-context-prio.o lttng-context-nice.o + lttng-context-prio.o lttng-context-nice.o \ + lttng-context-vpid.o lttng-context-tid.o \ + lttng-context-vtid.o lttng-context-ppid.o \ + lttng-context-vppid.o ifneq ($(CONFIG_PERF_EVENTS),) ltt-relay-objs += lttng-context-perf-counters.o diff --git a/ltt-debugfs-abi.c b/ltt-debugfs-abi.c index 53cc35d6..aa8dc0f4 100644 --- a/ltt-debugfs-abi.c +++ b/ltt-debugfs-abi.c @@ -159,6 +159,16 @@ long lttng_abi_add_context(struct file *file, return lttng_add_prio_to_ctx(ctx); case LTTNG_KERNEL_CONTEXT_NICE: return lttng_add_nice_to_ctx(ctx); + case LTTNG_KERNEL_CONTEXT_VPID: + return lttng_add_vpid_to_ctx(ctx); + case LTTNG_KERNEL_CONTEXT_TID: + return lttng_add_tid_to_ctx(ctx); + case LTTNG_KERNEL_CONTEXT_VTID: + return lttng_add_vtid_to_ctx(ctx); + case LTTNG_KERNEL_CONTEXT_PPID: + return lttng_add_ppid_to_ctx(ctx); + case LTTNG_KERNEL_CONTEXT_VPPID: + return lttng_add_vppid_to_ctx(ctx); case LTTNG_KERNEL_CONTEXT_PERF_COUNTER: context_param.u.perf_counter.name[LTTNG_SYM_NAME_LEN - 1] = '\0'; return lttng_add_perf_counter_to_ctx(context_param.u.perf_counter.type, diff --git a/ltt-debugfs-abi.h b/ltt-debugfs-abi.h index dd38507e..8dc0fde9 100644 --- a/ltt-debugfs-abi.h +++ b/ltt-debugfs-abi.h @@ -69,6 +69,11 @@ enum lttng_kernel_context_type { LTTNG_KERNEL_CONTEXT_COMM, LTTNG_KERNEL_CONTEXT_PRIO, LTTNG_KERNEL_CONTEXT_NICE, + LTTNG_KERNEL_CONTEXT_VPID, + LTTNG_KERNEL_CONTEXT_TID, + LTTNG_KERNEL_CONTEXT_VTID, + LTTNG_KERNEL_CONTEXT_PPID, + LTTNG_KERNEL_CONTEXT_VPPID, }; struct lttng_kernel_perf_counter_ctx { diff --git a/ltt-events.h b/ltt-events.h index 787868a9..f3536cec 100644 --- a/ltt-events.h +++ b/ltt-events.h @@ -290,6 +290,11 @@ int lttng_add_pid_to_ctx(struct lttng_ctx **ctx); int lttng_add_comm_to_ctx(struct lttng_ctx **ctx); int lttng_add_prio_to_ctx(struct lttng_ctx **ctx); int lttng_add_nice_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_tid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx); +int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx); int lttng_add_perf_counter_to_ctx(uint32_t type, uint64_t config, const char *name, diff --git a/lttng-context-pid.c b/lttng-context-pid.c index ddd78a5d..5400db96 100644 --- a/lttng-context-pid.c +++ b/lttng-context-pid.c @@ -32,7 +32,7 @@ void pid_record(struct lttng_ctx_field *field, { pid_t pid; - pid = current->pid; + pid = task_tgid_nr(current); lib_ring_buffer_align_ctx(ctx, ltt_alignof(pid)); chan->ops->event_write(ctx, &pid, sizeof(pid)); } diff --git a/lttng-context-ppid.c b/lttng-context-ppid.c new file mode 100644 index 00000000..342aa343 --- /dev/null +++ b/lttng-context-ppid.c @@ -0,0 +1,68 @@ +/* + * (C) Copyright 2009-2011 - + * Mathieu Desnoyers + * + * LTTng PPID context. + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include +#include +#include +#include +#include "ltt-events.h" +#include "wrapper/ringbuffer/frontend_types.h" +#include "wrapper/vmalloc.h" +#include "ltt-tracer.h" + +static +size_t ppid_get_size(size_t offset) +{ + size_t size = 0; + + size += lib_ring_buffer_align(offset, ltt_alignof(pid_t)); + size += sizeof(pid_t); + return size; +} + +static +void ppid_record(struct lttng_ctx_field *field, + struct lib_ring_buffer_ctx *ctx, + struct ltt_channel *chan) +{ + pid_t ppid; + + rcu_read_lock(); + ppid = task_tgid_nr(current->real_parent); + rcu_read_unlock(); + lib_ring_buffer_align_ctx(ctx, ltt_alignof(ppid)); + chan->ops->event_write(ctx, &ppid, sizeof(ppid)); +} + +int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx) +{ + struct lttng_ctx_field *field; + int ret; + + field = lttng_append_context(ctx); + if (!field) + return ret; + field->event_field.name = "ppid"; + 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.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; + field->event_field.type.u.basic.integer.encoding = lttng_encode_none; + field->get_size = ppid_get_size; + field->record = ppid_record; + wrapper_vmalloc_sync_all(); + return 0; +} +EXPORT_SYMBOL_GPL(lttng_add_ppid_to_ctx); + +MODULE_LICENSE("GPL and additional rights"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("Linux Trace Toolkit PPID Context"); diff --git a/lttng-context-tid.c b/lttng-context-tid.c new file mode 100644 index 00000000..4e974f8d --- /dev/null +++ b/lttng-context-tid.c @@ -0,0 +1,65 @@ +/* + * (C) Copyright 2009-2011 - + * Mathieu Desnoyers + * + * LTTng TID context. + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include +#include +#include +#include "ltt-events.h" +#include "wrapper/ringbuffer/frontend_types.h" +#include "wrapper/vmalloc.h" +#include "ltt-tracer.h" + +static +size_t tid_get_size(size_t offset) +{ + size_t size = 0; + + size += lib_ring_buffer_align(offset, ltt_alignof(pid_t)); + size += sizeof(pid_t); + return size; +} + +static +void tid_record(struct lttng_ctx_field *field, + struct lib_ring_buffer_ctx *ctx, + struct ltt_channel *chan) +{ + pid_t tid; + + tid = task_pid_nr(current); + lib_ring_buffer_align_ctx(ctx, ltt_alignof(tid)); + chan->ops->event_write(ctx, &tid, sizeof(tid)); +} + +int lttng_add_tid_to_ctx(struct lttng_ctx **ctx) +{ + struct lttng_ctx_field *field; + int ret; + + field = lttng_append_context(ctx); + if (!field) + return ret; + field->event_field.name = "tid"; + 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.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; + field->event_field.type.u.basic.integer.encoding = lttng_encode_none; + field->get_size = tid_get_size; + field->record = tid_record; + wrapper_vmalloc_sync_all(); + return 0; +} +EXPORT_SYMBOL_GPL(lttng_add_tid_to_ctx); + +MODULE_LICENSE("GPL and additional rights"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("Linux Trace Toolkit TID Context"); diff --git a/lttng-context-vpid.c b/lttng-context-vpid.c new file mode 100644 index 00000000..3bbb87f4 --- /dev/null +++ b/lttng-context-vpid.c @@ -0,0 +1,65 @@ +/* + * (C) Copyright 2009-2011 - + * Mathieu Desnoyers + * + * LTTng vPID context. + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include +#include +#include +#include "ltt-events.h" +#include "wrapper/ringbuffer/frontend_types.h" +#include "wrapper/vmalloc.h" +#include "ltt-tracer.h" + +static +size_t vpid_get_size(size_t offset) +{ + size_t size = 0; + + size += lib_ring_buffer_align(offset, ltt_alignof(pid_t)); + size += sizeof(pid_t); + return size; +} + +static +void vpid_record(struct lttng_ctx_field *field, + struct lib_ring_buffer_ctx *ctx, + struct ltt_channel *chan) +{ + pid_t vpid; + + vpid = task_tgid_vnr(current); + lib_ring_buffer_align_ctx(ctx, ltt_alignof(vpid)); + chan->ops->event_write(ctx, &vpid, sizeof(vpid)); +} + +int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx) +{ + struct lttng_ctx_field *field; + int ret; + + field = lttng_append_context(ctx); + if (!field) + return ret; + field->event_field.name = "vpid"; + 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.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; + field->event_field.type.u.basic.integer.encoding = lttng_encode_none; + field->get_size = vpid_get_size; + field->record = vpid_record; + wrapper_vmalloc_sync_all(); + return 0; +} +EXPORT_SYMBOL_GPL(lttng_add_vpid_to_ctx); + +MODULE_LICENSE("GPL and additional rights"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("Linux Trace Toolkit vPID Context"); diff --git a/lttng-context-vppid.c b/lttng-context-vppid.c new file mode 100644 index 00000000..813ccc61 --- /dev/null +++ b/lttng-context-vppid.c @@ -0,0 +1,68 @@ +/* + * (C) Copyright 2009-2011 - + * Mathieu Desnoyers + * + * LTTng vPPID context. + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include +#include +#include +#include +#include "ltt-events.h" +#include "wrapper/ringbuffer/frontend_types.h" +#include "wrapper/vmalloc.h" +#include "ltt-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 += sizeof(pid_t); + return size; +} + +static +void vppid_record(struct lttng_ctx_field *field, + struct lib_ring_buffer_ctx *ctx, + struct ltt_channel *chan) +{ + pid_t vppid; + + rcu_read_lock(); + vppid = task_tgid_vnr(current->real_parent); + rcu_read_unlock(); + lib_ring_buffer_align_ctx(ctx, ltt_alignof(vppid)); + chan->ops->event_write(ctx, &vppid, sizeof(vppid)); +} + +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; + 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.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; + field->event_field.type.u.basic.integer.encoding = lttng_encode_none; + field->get_size = vppid_get_size; + field->record = vppid_record; + wrapper_vmalloc_sync_all(); + return 0; +} +EXPORT_SYMBOL_GPL(lttng_add_vppid_to_ctx); + +MODULE_LICENSE("GPL and additional rights"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("Linux Trace Toolkit vPPID Context"); diff --git a/lttng-context-vtid.c b/lttng-context-vtid.c new file mode 100644 index 00000000..665e1a9c --- /dev/null +++ b/lttng-context-vtid.c @@ -0,0 +1,65 @@ +/* + * (C) Copyright 2009-2011 - + * Mathieu Desnoyers + * + * LTTng vTID context. + * + * Dual LGPL v2.1/GPL v2 license. + */ + +#include +#include +#include +#include "ltt-events.h" +#include "wrapper/ringbuffer/frontend_types.h" +#include "wrapper/vmalloc.h" +#include "ltt-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 += sizeof(pid_t); + return size; +} + +static +void vtid_record(struct lttng_ctx_field *field, + struct lib_ring_buffer_ctx *ctx, + struct ltt_channel *chan) +{ + pid_t vtid; + + vtid = task_pid_vnr(current); + lib_ring_buffer_align_ctx(ctx, ltt_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 ret; + 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.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; + field->event_field.type.u.basic.integer.encoding = lttng_encode_none; + field->get_size = vtid_get_size; + field->record = vtid_record; + wrapper_vmalloc_sync_all(); + return 0; +} +EXPORT_SYMBOL_GPL(lttng_add_vtid_to_ctx); + +MODULE_LICENSE("GPL and additional rights"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("Linux Trace Toolkit vTID Context");