Fix: statedump namespaced pid, tid and ppid
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 23 Aug 2012 20:19:53 +0000 (16:19 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 23 Aug 2012 20:19:53 +0000 (16:19 -0400)
Use the target process namespace to lookup the value (pid, tid or ppid),
not the current task.

[ Edit by Mathieu Desnoyers: removed extra p->nsproxy check. Already
  performed within rcu read-side critical section. ]

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
instrumentation/events/lttng-module/lttng-statedump.h

index 9757e205799c070572949d454d30decc330a6561..5fc15a88be8234d7a7e576be12ef5e1f8d4a4ad0 100644 (file)
@@ -5,6 +5,7 @@
 #define _TRACE_LTTNG_STATEDUMP_H
 
 #include <linux/tracepoint.h>
+#include <linux/nsproxy.h>
 
 TRACE_EVENT(lttng_statedump_start,
        TP_PROTO(struct lttng_session *session),
@@ -46,9 +47,35 @@ TRACE_EVENT(lttng_statedump_process_state,
        ),
        TP_fast_assign(
                tp_assign(tid, p->pid)
-               tp_assign(vtid, !p->nsproxy ? 0 : task_pid_vnr(p))
+               tp_assign(vtid,
+                       ({
+                               struct nsproxy *proxy;
+                               pid_t ret = 0;
+
+                               rcu_read_lock();
+                               proxy = task_nsproxy(p);
+                               if (proxy) {
+                                       ret = task_pid_nr_ns(p,
+                                               proxy->pid_ns);
+                               }
+                               rcu_read_unlock();
+                               ret;
+                       }))
                tp_assign(pid, p->tgid)
-               tp_assign(vpid, !p->nsproxy ? 0 : task_tgid_vnr(p))
+               tp_assign(vpid,
+                       ({
+                                struct nsproxy *proxy;
+                                pid_t ret = 0;
+
+                                rcu_read_lock();
+                                proxy = task_nsproxy(p);
+                                if (proxy) {
+                                        ret = task_tgid_nr_ns(p,
+                                                proxy->pid_ns);
+                                }
+                                rcu_read_unlock();
+                                ret;
+                        }))
                tp_assign(ppid,
                        ({
                                pid_t ret;
@@ -61,14 +88,16 @@ TRACE_EVENT(lttng_statedump_process_state,
                tp_assign(vppid,
                        ({
                                struct task_struct *parent;
-                               pid_t ret;
+                               struct nsproxy *proxy;
+                               pid_t ret = 0;
 
                                rcu_read_lock();
-                               parent = rcu_dereference(current->real_parent);
-                               if (!parent->nsproxy)
-                                       ret = 0;
-                               else
-                                       ret = task_tgid_nr(parent);
+                               parent = rcu_dereference(p->real_parent);
+                               proxy = task_nsproxy(parent);
+                               if (proxy) {
+                                       ret = task_tgid_nr_ns(parent,
+                                               proxy->pid_ns);
+                               }
                                rcu_read_unlock();
                                ret;
                        }))
This page took 0.027334 seconds and 4 git commands to generate.