|
@@ -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);
|
|
|
|
|
|
- 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.tid = pid;
|
|
|
event->fork.header.type = PERF_RECORD_FORK;
|