From: Julien Desfossez Date: Thu, 23 Aug 2012 20:19:53 +0000 (-0400) Subject: Fix: statedump namespaced pid, tid and ppid X-Git-Tag: v2.1.0-rc1~9 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=90fffd13d9803770838eab195e4f091753cbc7b5;p=lttng-modules.git Fix: statedump namespaced pid, tid and ppid 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 Signed-off-by: Mathieu Desnoyers --- diff --git a/instrumentation/events/lttng-module/lttng-statedump.h b/instrumentation/events/lttng-module/lttng-statedump.h index 9757e205..5fc15a88 100644 --- a/instrumentation/events/lttng-module/lttng-statedump.h +++ b/instrumentation/events/lttng-module/lttng-statedump.h @@ -5,6 +5,7 @@ #define _TRACE_LTTNG_STATEDUMP_H #include +#include 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; }))