aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2017-08-22 11:59:28 -0400
committerIngo Molnar <mingo@kernel.org>2017-08-25 05:04:17 -0400
commit1d953111b648e48923171c3c9cf17be2250544fa (patch)
treeb72fe2f9c20633a7de8f0668c5cab85cb515160a
parent6ae5fa61d27dcb055f4198bcf6c8dbbf1bb33f52 (diff)
perf/core: Don't report zero PIDs for exiting tasks
The exiting/dead task has no PIDs and in this case perf_event_pid/tid() return zero, change them to return -1 to distinguish this case from idle threads. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Arnaldo Carvalho <acme@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20170822155928.GA6892@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--kernel/events/core.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 1ac5015bab04..b411321b6c26 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1249,26 +1249,31 @@ unclone_ctx(struct perf_event_context *ctx)
1249 return parent_ctx; 1249 return parent_ctx;
1250} 1250}
1251 1251
1252static u32 perf_event_pid(struct perf_event *event, struct task_struct *p) 1252static u32 perf_event_pid_type(struct perf_event *event, struct task_struct *p,
1253 enum pid_type type)
1253{ 1254{
1255 u32 nr;
1254 /* 1256 /*
1255 * only top level events have the pid namespace they were created in 1257 * only top level events have the pid namespace they were created in
1256 */ 1258 */
1257 if (event->parent) 1259 if (event->parent)
1258 event = event->parent; 1260 event = event->parent;
1259 1261
1260 return task_tgid_nr_ns(p, event->ns); 1262 nr = __task_pid_nr_ns(p, type, event->ns);
1263 /* avoid -1 if it is idle thread or runs in another ns */
1264 if (!nr && !pid_alive(p))
1265 nr = -1;
1266 return nr;
1261} 1267}
1262 1268
1263static u32 perf_event_tid(struct perf_event *event, struct task_struct *p) 1269static u32 perf_event_pid(struct perf_event *event, struct task_struct *p)
1264{ 1270{
1265 /* 1271 return perf_event_pid_type(event, p, __PIDTYPE_TGID);
1266 * only top level events have the pid namespace they were created in 1272}
1267 */
1268 if (event->parent)
1269 event = event->parent;
1270 1273
1271 return task_pid_nr_ns(p, event->ns); 1274static u32 perf_event_tid(struct perf_event *event, struct task_struct *p)
1275{
1276 return perf_event_pid_type(event, p, PIDTYPE_PID);
1272} 1277}
1273 1278
1274/* 1279/*