Commit 7764a385 authored by David Ahern's avatar David Ahern Committed by Arnaldo Carvalho de Melo

perf tools: Fix synthesizing fork_event.ppid for non-main thread

Commit ca6c41c5 sets the ppid based on what is read from the
/proc/pid/status file when synthesizing fork events.

This is correct thing to do for new processes but not threads of a
process.

Fix ppid for threads to be the main thread when synthesizing fork events
(ie., assume main thread spawned all sub-threads in a process).
Reported-by: default avatarArnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Signed-off-by: default avatarDavid Ahern <david.ahern@oracle.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: default avatarDon Zickus <dzickus@redhat.com>
Link: http://lkml.kernel.org/r/1428598107-178999-1-git-send-email-david.ahern@oracle.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 51ab7155
...@@ -183,8 +183,18 @@ static int perf_event__synthesize_fork(struct perf_tool *tool, ...@@ -183,8 +183,18 @@ static int perf_event__synthesize_fork(struct perf_tool *tool,
{ {
memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size); memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size);
event->fork.ppid = ppid; /*
event->fork.ptid = ppid; * for main thread set parent to ppid from status file. For other
* threads set parent pid to main thread. ie., assume main thread
* spawns all threads in a process
*/
if (tgid == pid) {
event->fork.ppid = ppid;
event->fork.ptid = ppid;
} else {
event->fork.ppid = tgid;
event->fork.ptid = tgid;
}
event->fork.pid = tgid; event->fork.pid = tgid;
event->fork.tid = pid; event->fork.tid = pid;
event->fork.header.type = PERF_RECORD_FORK; event->fork.header.type = PERF_RECORD_FORK;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment