Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d953111 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Ingo Molnar
Browse files

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: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarPeter 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: default avatarIngo Molnar <mingo@kernel.org>
parent 6ae5fa61
Loading
Loading
Loading
Loading
+14 −9
Original line number Original line Diff line number Diff line
@@ -1249,26 +1249,31 @@ unclone_ctx(struct perf_event_context *ctx)
	return parent_ctx;
	return parent_ctx;
}
}


static u32 perf_event_pid(struct perf_event *event, struct task_struct *p)
static u32 perf_event_pid_type(struct perf_event *event, struct task_struct *p,
				enum pid_type type)
{
{
	u32 nr;
	/*
	/*
	 * only top level events have the pid namespace they were created in
	 * only top level events have the pid namespace they were created in
	 */
	 */
	if (event->parent)
	if (event->parent)
		event = event->parent;
		event = event->parent;


	return task_tgid_nr_ns(p, event->ns);
	nr = __task_pid_nr_ns(p, type, event->ns);
	/* avoid -1 if it is idle thread or runs in another ns */
	if (!nr && !pid_alive(p))
		nr = -1;
	return nr;
}
}


static u32 perf_event_tid(struct perf_event *event, struct task_struct *p)
static u32 perf_event_pid(struct perf_event *event, struct task_struct *p)
{
{
	/*
	return perf_event_pid_type(event, p, __PIDTYPE_TGID);
	 * only top level events have the pid namespace they were created in
}
	 */
	if (event->parent)
		event = event->parent;


	return task_pid_nr_ns(p, event->ns);
static u32 perf_event_tid(struct perf_event *event, struct task_struct *p)
{
	return perf_event_pid_type(event, p, PIDTYPE_PID);
}
}


/*
/*