Add pid/ppid/tid/vtid/vpid/vppid contexts
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 23 Jun 2011 15:31:12 +0000 (11:31 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 23 Jun 2011 15:31:12 +0000 (11:31 -0400)
Use the values returned by gettid(), getpid() and getppid() for vtid,
vpid, vppid.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Makefile
ltt-debugfs-abi.c
ltt-debugfs-abi.h
ltt-events.h
lttng-context-pid.c
lttng-context-ppid.c [new file with mode: 0644]
lttng-context-tid.c [new file with mode: 0644]
lttng-context-vpid.c [new file with mode: 0644]
lttng-context-vppid.c [new file with mode: 0644]
lttng-context-vtid.c [new file with mode: 0644]

index dc44fd40b6cfb2834ef0b1e89861aa5e85ecafc4..517d1f7502f49476be05c95c2b78b94d77d59b0c 100644 (file)
--- 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
index 53cc35d673c5e65a943e2dfea6ccbec96918ba8d..aa8dc0f4a0d973af21f4739aa373170cfb63a9d6 100644 (file)
@@ -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,
index dd38507ee252ab9e75d356f6286d08263872af38..8dc0fde9b8c4cd59738438f41f9ec76bb4f86326 100644 (file)
@@ -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 {
index 787868a99156bae9f960c86670e9ade05f56512e..f3536cec1e76645a87f2da30fc9e394711ae0a16 100644 (file)
@@ -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,
index ddd78a5d8dfb3f4b4e0eb296286a8c6d1a8cde3f..5400db9632ab1f7f5ef332e88df78f219fce3c5f 100644 (file)
@@ -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 (file)
index 0000000..342aa34
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * (C) Copyright       2009-2011 -
+ *             Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * LTTng PPID context.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/syscalls.h>
+#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 (file)
index 0000000..4e974f8
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright       2009-2011 -
+ *             Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * LTTng TID context.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#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 (file)
index 0000000..3bbb87f
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright       2009-2011 -
+ *             Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * LTTng vPID context.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#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 (file)
index 0000000..813ccc6
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * (C) Copyright       2009-2011 -
+ *             Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * LTTng vPPID context.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/syscalls.h>
+#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 (file)
index 0000000..665e1a9
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright       2009-2011 -
+ *             Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * LTTng vTID context.
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#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");
This page took 0.031584 seconds and 4 git commands to generate.