Add namespace info in sched_fork and statedump
authorSebastien Lorrain <sebastien.lorrain01@gmail.com>
Wed, 15 Apr 2015 15:53:53 +0000 (11:53 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 6 May 2015 20:03:55 +0000 (16:03 -0400)
Modifications to sched_fork : Add a field for parent and child pid
namespace inode (as in /proc/$PID/ns/pid). Also add a field for the
child VTID.

Modifications to lttng_statedump_process_state : Add a field for the pid
namespace inode of the task.

Signed-off-by: Sebastien Lorrain <sebastien.lorrain01@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
instrumentation/events/lttng-module/lttng-statedump.h
instrumentation/events/lttng-module/sched.h

index 23690370774aaf4120b08a1a030b71ee4f4761a0..916a6c5c3450b2b126e1f7929e6f498b25117322 100644 (file)
@@ -8,6 +8,14 @@
 #include <linux/nsproxy.h>
 #include <linux/pid_namespace.h>
 #include <linux/types.h>
+#include <linux/version.h>
+
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
+#define lttng_proc_inum ns.inum
+#else
+#define lttng_proc_inum proc_inum
+#endif
 
 LTTNG_TRACEPOINT_EVENT(lttng_statedump_start,
        TP_PROTO(struct lttng_session *session),
@@ -60,6 +68,9 @@ LTTNG_TRACEPOINT_EVENT(lttng_statedump_process_state,
                ctf_integer(int, submode, submode)
                ctf_integer(int, status, status)
                ctf_integer(int, ns_level, pid_ns ? pid_ns->level : 0)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+               ctf_integer(unsigned int, ns_inum, pid_ns ? pid_ns->lttng_proc_inum : 0)
+#endif
        )
 )
 
index ac61bcef3d4a79335a53166574d9b39a99c79813..6e42fc62d4d3c779bca162d441656aa56aff3475 100644 (file)
@@ -6,12 +6,21 @@
 
 #include "../../../probes/lttng-tracepoint-event.h"
 #include <linux/sched.h>
+#include <linux/pid_namespace.h>
 #include <linux/binfmts.h>
 #include <linux/version.h>
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
 #include <linux/sched/rt.h>
 #endif
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0))
+#define lttng_proc_inum ns.inum
+#else
+#define lttng_proc_inum proc_inum
+#endif
+
+#define LTTNG_MAX_PID_NS_LEVEL 32
+
 #ifndef _TRACE_SCHED_DEF_
 #define _TRACE_SCHED_DEF_
 
@@ -288,19 +297,71 @@ LTTNG_TRACEPOINT_EVENT(sched_process_wait,
  * == child_pid, while creation of a thread yields to child_tid !=
  * child_pid.
  */
-LTTNG_TRACEPOINT_EVENT(sched_process_fork,
+LTTNG_TRACEPOINT_EVENT_CODE(sched_process_fork,
 
        TP_PROTO(struct task_struct *parent, struct task_struct *child),
 
        TP_ARGS(parent, child),
 
+       TP_locvar(
+               pid_t vtids[LTTNG_MAX_PID_NS_LEVEL];
+               unsigned int ns_level;
+       ),
+
+       TP_code(
+               if (child) {
+                       struct pid *child_pid;
+                       unsigned int i;
+
+                       child_pid = task_pid(child);
+                       tp_locvar->ns_level =
+                               min_t(unsigned int, child_pid->level + 1,
+                                       LTTNG_MAX_PID_NS_LEVEL);
+                       for (i = 0; i < tp_locvar->ns_level; i++)
+                               tp_locvar->vtids[i] = child_pid->numbers[i].nr;
+               }
+       ),
+
        TP_FIELDS(
                ctf_array_text(char, parent_comm, parent->comm, TASK_COMM_LEN)
                ctf_integer(pid_t, parent_tid, parent->pid)
                ctf_integer(pid_t, parent_pid, parent->tgid)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+               ctf_integer(unsigned int, parent_ns_inum,
+                       ({
+                               unsigned int parent_ns_inum = 0;
+
+                               if (parent) {
+                                       struct pid_namespace *pid_ns;
+
+                                       pid_ns = task_active_pid_ns(parent);
+                                       if (pid_ns)
+                                               parent_ns_inum =
+                                                       pid_ns->lttng_proc_inum;
+                               }
+                               parent_ns_inum;
+                       }))
+#endif
                ctf_array_text(char, child_comm, child->comm, TASK_COMM_LEN)
                ctf_integer(pid_t, child_tid, child->pid)
+               ctf_sequence(pid_t, vtids, tp_locvar->vtids, u8, tp_locvar->ns_level)
                ctf_integer(pid_t, child_pid, child->tgid)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+               ctf_integer(unsigned int, child_ns_inum,
+                       ({
+                               unsigned int child_ns_inum = 0;
+
+                               if (child) {
+                                       struct pid_namespace *pid_ns;
+
+                                       pid_ns = task_active_pid_ns(child);
+                                       if (pid_ns)
+                                               child_ns_inum =
+                                                       pid_ns->lttng_proc_inum;
+                               }
+                               child_ns_inum;
+                       }))
+#endif
        )
 )
 
This page took 0.028428 seconds and 4 git commands to generate.